]> www.ginac.de Git - ginac.git/commitdiff
Replace use of NULL by C++11 nullptr.
authorRichard Kreckel <kreckel@ginac.de>
Sun, 1 Nov 2015 22:48:05 +0000 (23:48 +0100)
committerRichard Kreckel <kreckel@ginac.de>
Sun, 1 Nov 2015 22:48:05 +0000 (23:48 +0100)
13 files changed:
check/randomize_serials.cpp
check/test_runner.h
ginac/basic.cpp
ginac/class_info.h
ginac/container.h
ginac/excompiler.cpp
ginac/function.cppy
ginac/function.hppy
ginac/normal.cpp
ginac/normal.h
ginac/power.cpp
ginac/pseries.cpp
ginac/symmetry.cpp

index 5016a0c007a2feb9460700609b1a2a31cefd3c9a..5603452a412d4ea4e701d4a8add40b6a05e0cbdf 100644 (file)
@@ -45,7 +45,7 @@ using namespace std;
  */
 void randomify_symbol_serials()
 {
  */
 void randomify_symbol_serials()
 {
-       srand(time(NULL));
+       srand(time(nullptr));
        const int m = rand() % 666;
        for (int s=0; s<m; ++s ) {
                symbol("dummy");
        const int m = rand() % 666;
        for (int s=0; s<m; ++s ) {
                symbol("dummy");
index fbc5a3298f1fc9359fc04c231e41508f9b17d47a..48df1f44d927cfdb0ccc36e7f843c8a91ea1638f 100644 (file)
@@ -70,7 +70,7 @@ static int run_expensive_timings_p()
        static const std::string env_name("GINAC_RUN_EXPENSIVE_TIMINGS");
        if (cc++ == 0) {
                char* envvar = std::getenv(env_name.c_str());
        static const std::string env_name("GINAC_RUN_EXPENSIVE_TIMINGS");
        if (cc++ == 0) {
                char* envvar = std::getenv(env_name.c_str());
-               if (envvar != NULL) {
+               if (envvar != nullptr) {
                        value = std::atoi(envvar);
                        if (value < 0 || value > 2)
                                value = 0;
                        value = std::atoi(envvar);
                        if (value < 0 || value > 2)
                                value = 0;
index 79d83b555d5fea54e0e814faacd593eb012ee58b..563dd7d5b6455fe9453885111bb0aac7a4259ed9 100644 (file)
@@ -297,12 +297,12 @@ ex basic::map(map_function & f) const
        if (num == 0)
                return *this;
 
        if (num == 0)
                return *this;
 
-       basic *copy = NULL;
+       basic *copy = nullptr;
        for (size_t i=0; i<num; i++) {
                const ex & o = op(i);
                const ex & n = f(o);
                if (!are_ex_trivially_equal(o, n)) {
        for (size_t i=0; i<num; i++) {
                const ex & o = op(i);
                const ex & n = f(o);
                if (!are_ex_trivially_equal(o, n)) {
-                       if (copy == NULL)
+                       if (copy == nullptr)
                                copy = duplicate();
                        copy->let_op(i) = n;
                }
                                copy = duplicate();
                        copy->let_op(i) = n;
                }
index 588a73b9c6a21375d9d5fa763ef609d411604d7f..1d3ed3d21b20d0fa4f43466e3152e60ff90b0a3d 100644 (file)
@@ -40,13 +40,13 @@ namespace GiNaC {
 template <class OPT>
 class class_info {
 public:
 template <class OPT>
 class class_info {
 public:
-       class_info(const OPT & o) : options(o), next(first), parent(NULL)
+       class_info(const OPT & o) : options(o), next(first), parent(nullptr)
        {
                first = this;
                parents_identified = false;
        }
 
        {
                first = this;
                parents_identified = false;
        }
 
-       /** Get pointer to class_info of parent class (or NULL). */
+       /** Get pointer to class_info of parent class (or nullptr). */
        class_info *get_parent() const
        {
                identify_parents();
        class_info *get_parent() const
        {
                identify_parents();
@@ -155,7 +155,7 @@ void class_info<OPT>::dump_hierarchy(bool verbose)
                tree.push_back(tree_node(p));
 
        // Identify children for all nodes and find the root
                tree.push_back(tree_node(p));
 
        // Identify children for all nodes and find the root
-       tree_node *root = NULL;
+       tree_node *root = nullptr;
        for (typename std::vector<tree_node>::iterator i = tree.begin(); i != tree.end(); ++i) {
                class_info *p = i->info->get_parent();
                if (p) {
        for (typename std::vector<tree_node>::iterator i = tree.begin(); i != tree.end(); ++i) {
                class_info *p = i->info->get_parent();
                if (p) {
@@ -190,7 +190,7 @@ void class_info<OPT>::identify_parents()
        }
 }
 
        }
 }
 
-template <class OPT> class_info<OPT> *class_info<OPT>::first = NULL;
+template <class OPT> class_info<OPT> *class_info<OPT>::first = nullptr;
 template <class OPT> bool class_info<OPT>::parents_identified = false;
 
 } // namespace GiNaC
 template <class OPT> bool class_info<OPT>::parents_identified = false;
 
 } // namespace GiNaC
index 6cdc7cb729eaafcf5feac6d79cf1b01a27459930..3c9d560132dcfced847f2397c24ed1c69ce1bd0a 100644 (file)
@@ -394,7 +394,7 @@ public:
 protected:
        ex conjugate() const
        {
 protected:
        ex conjugate() const
        {
-               STLT *newcont = NULL;
+               STLT *newcont = nullptr;
                for (const_iterator i=this->seq.begin(); i!=this->seq.end(); ++i) {
                        if (newcont) {
                                newcont->push_back(i->conjugate());
                for (const_iterator i=this->seq.begin(); i!=this->seq.end(); ++i) {
                        if (newcont) {
                                newcont->push_back(i->conjugate());
index d7897c014e92827374ebcc70d0ff11f86dc01e45..36cb8ffcf01fe203ef5ddcad686a4c521b81cb72 100644 (file)
@@ -153,9 +153,9 @@ public:
         */
        void* link_so_file(const std::string filename, bool clean_up)
        {
         */
        void* link_so_file(const std::string filename, bool clean_up)
        {
-               void* module = NULL;
+               void* module = nullptr;
                module = dlopen(filename.c_str(), RTLD_NOW);
                module = dlopen(filename.c_str(), RTLD_NOW);
-               if (module == NULL)     {
+               if (module == nullptr)  {
                        throw std::runtime_error("excompiler::link_so_file: could not open compiled module!");
                }
 
                        throw std::runtime_error("excompiler::link_so_file: could not open compiled module!");
                }
 
index 517f4566dff8799027cba532e24f9df6df39dd46..45f33ec16b53ba32d6e020067bf708f0ba262ced 100644 (file)
@@ -304,7 +304,7 @@ void function::print(const print_context & c, unsigned level) const
 
 next_context:
        unsigned id = pc_info->options.get_id();
 
 next_context:
        unsigned id = pc_info->options.get_id();
-       if (id >= pdt.size() || pdt[id] == NULL) {
+       if (id >= pdt.size() || pdt[id] == nullptr) {
 
                // Method not found, try parent print_context class
                const print_context_class_info *parent_pc_info = pc_info->get_parent();
 
                // Method not found, try parent print_context class
                const print_context_class_info *parent_pc_info = pc_info->get_parent();
@@ -736,7 +736,7 @@ ex function::pderivative(unsigned diff_param) const // partial differentiation
        const function_options &opt = registered_functions()[serial];
        
        // No derivative defined? Then return abstract derivative object
        const function_options &opt = registered_functions()[serial];
        
        // No derivative defined? Then return abstract derivative object
-       if (opt.derivative_f == NULL)
+       if (opt.derivative_f == nullptr)
                return fderivative(serial, diff_param, seq);
 
        current_serial = serial;
                return fderivative(serial, diff_param, seq);
 
        current_serial = serial;
@@ -759,7 +759,7 @@ ex function::expl_derivative(const symbol & s) const // explicit differentiation
        const function_options &opt = registered_functions()[serial];
 
        // No explicit derivative defined? Then this function shall not be called!
        const function_options &opt = registered_functions()[serial];
 
        // No explicit derivative defined? Then this function shall not be called!
-       if (opt.expl_derivative_f == NULL)
+       if (opt.expl_derivative_f == nullptr)
                throw(std::logic_error("function::expl_derivative(): explicit derivation is called, but no such function defined"));
 
        current_serial = serial;
                throw(std::logic_error("function::expl_derivative(): explicit derivation is called, but no such function defined"));
 
        current_serial = serial;
@@ -780,7 +780,7 @@ ex function::power(const ex & power_param) const // power of function
        GINAC_ASSERT(serial<registered_functions().size());
        const function_options &opt = registered_functions()[serial];
        
        GINAC_ASSERT(serial<registered_functions().size());
        const function_options &opt = registered_functions()[serial];
        
-       if (opt.power_f == NULL)
+       if (opt.power_f == nullptr)
                return (new GiNaC::power(*this, power_param))->setflag(status_flags::dynallocated |
                                                                       status_flags::evaluated);
 
                return (new GiNaC::power(*this, power_param))->setflag(status_flags::dynallocated |
                                                                       status_flags::evaluated);
 
@@ -804,7 +804,7 @@ ex function::expand(unsigned options) const
        const function_options &opt = registered_functions()[serial];
 
        // No expand defined? Then return the same function with expanded arguments (if required)
        const function_options &opt = registered_functions()[serial];
 
        // No expand defined? Then return the same function with expanded arguments (if required)
-       if (opt.expand_f == NULL) {
+       if (opt.expand_f == nullptr) {
                // Only expand arguments when asked to do so
                if (options & expand_options::expand_function_args)
                        return inherited::expand(options);
                // Only expand arguments when asked to do so
                if (options & expand_options::expand_function_args)
                        return inherited::expand(options);
index b84364da1bdf0245662c68bf07f28d777c362d0b..a5605115164e97cd8e8982c1abb0790abb1dfea6 100644 (file)
@@ -145,8 +145,8 @@ public:
        unsigned get_nparams() const { return nparams; }
 
 protected:
        unsigned get_nparams() const { return nparams; }
 
 protected:
-       bool has_derivative() const { return derivative_f != NULL; }
-       bool has_power() const { return power_f != NULL; }
+       bool has_derivative() const { return derivative_f != nullptr; }
+       bool has_power() const { return power_f != nullptr; }
        void test_and_set_nparams(unsigned n);
        void set_print_func(unsigned id, print_funcp f);
 
        void test_and_set_nparams(unsigned n);
        void set_print_func(unsigned id, print_funcp f);
 
index 18b4637c4cbee1b3d51dcdd25732b70ea6d58a1d..6870b77f4b7c8b589d05a1ceafd842cfadb82e88 100644 (file)
@@ -961,7 +961,7 @@ ex ex::content(const ex &x) const
                return lcoeff * c / lcoeff.unit(x);
        ex cont = _ex0;
        for (int i=ldeg; i<=deg; i++)
                return lcoeff * c / lcoeff.unit(x);
        ex cont = _ex0;
        for (int i=ldeg; i<=deg; i++)
-               cont = gcd(r.coeff(x, i), cont, NULL, NULL, false);
+               cont = gcd(r.coeff(x, i), cont, nullptr, nullptr, false);
        return cont * c;
 }
 
        return cont * c;
 }
 
@@ -1101,7 +1101,7 @@ static ex sr_gcd(const ex &a, const ex &b, sym_desc_vec::const_iterator var)
        // Remove content from c and d, to be attached to GCD later
        ex cont_c = c.content(x);
        ex cont_d = d.content(x);
        // Remove content from c and d, to be attached to GCD later
        ex cont_c = c.content(x);
        ex cont_d = d.content(x);
-       ex gamma = gcd(cont_c, cont_d, NULL, NULL, false);
+       ex gamma = gcd(cont_c, cont_d, nullptr, nullptr, false);
        if (ddeg == 0)
                return gamma;
        c = c.primpart(x, cont_c);
        if (ddeg == 0)
                return gamma;
        c = c.primpart(x, cont_c);
@@ -1272,9 +1272,9 @@ class gcdheu_failed {};
  *
  *  @param a  first integer multivariate polynomial (expanded)
  *  @param b  second integer multivariate polynomial (expanded)
  *
  *  @param a  first integer multivariate polynomial (expanded)
  *  @param b  second integer multivariate polynomial (expanded)
- *  @param ca  cofactor of polynomial a (returned), NULL to suppress
+ *  @param ca  cofactor of polynomial a (returned), nullptr to suppress
  *             calculation of cofactor
  *             calculation of cofactor
- *  @param cb  cofactor of polynomial b (returned), NULL to suppress
+ *  @param cb  cofactor of polynomial b (returned), nullptr to suppress
  *             calculation of cofactor
  *  @param var iterator to first element of vector of sym_desc structs
  *  @param res the GCD (returned)
  *             calculation of cofactor
  *  @param var iterator to first element of vector of sym_desc structs
  *  @param res the GCD (returned)
@@ -1365,9 +1365,9 @@ static bool heur_gcd_z(ex& res, const ex &a, const ex &b, ex *ca, ex *cb,
  *
  *  @param a  first rational multivariate polynomial (expanded)
  *  @param b  second rational multivariate polynomial (expanded)
  *
  *  @param a  first rational multivariate polynomial (expanded)
  *  @param b  second rational multivariate polynomial (expanded)
- *  @param ca  cofactor of polynomial a (returned), NULL to suppress
+ *  @param ca  cofactor of polynomial a (returned), nullptr to suppress
  *             calculation of cofactor
  *             calculation of cofactor
- *  @param cb  cofactor of polynomial b (returned), NULL to suppress
+ *  @param cb  cofactor of polynomial b (returned), nullptr to suppress
  *             calculation of cofactor
  *  @param var iterator to first element of vector of sym_desc structs
  *  @param res the GCD (returned)
  *             calculation of cofactor
  *  @param var iterator to first element of vector of sym_desc structs
  *  @param res the GCD (returned)
@@ -1431,8 +1431,8 @@ static ex gcd_pf_mul(const ex& a, const ex& b, ex* ca, ex* cb);
  *
  *  @param a  first multivariate polynomial
  *  @param b  second multivariate polynomial
  *
  *  @param a  first multivariate polynomial
  *  @param b  second multivariate polynomial
- *  @param ca pointer to expression that will receive the cofactor of a, or NULL
- *  @param cb pointer to expression that will receive the cofactor of b, or NULL
+ *  @param ca pointer to expression that will receive the cofactor of a, or nullptr
+ *  @param cb pointer to expression that will receive the cofactor of b, or nullptr
  *  @param check_args  check whether a and b are polynomials with rational
  *         coefficients (defaults to "true")
  *  @return the GCD as a new expression */
  *  @param check_args  check whether a and b are polynomials with rational
  *         coefficients (defaults to "true")
  *  @return the GCD as a new expression */
index f249cb1ac4e8e2df7ac7e8217d11a319dfbbd3c1..deb69a97f40db5d21b13053d80f49d791d0c2e76 100644 (file)
@@ -85,8 +85,8 @@ extern ex sprem(const ex &a, const ex &b, const ex &x, bool check_args = true);
 extern bool divide(const ex &a, const ex &b, ex &q, bool check_args = true);
 
 // Polynomial GCD in Z[X], cofactors are returned in ca and cb, if desired
 extern bool divide(const ex &a, const ex &b, ex &q, bool check_args = true);
 
 // Polynomial GCD in Z[X], cofactors are returned in ca and cb, if desired
-extern ex gcd(const ex &a, const ex &b, ex *ca = NULL, ex *cb = NULL,
-             bool check_args = true, unsigned options = 0);
+extern ex gcd(const ex &a, const ex &b, ex *ca = nullptr, ex *cb = nullptr,
+              bool check_args = true, unsigned options = 0);
 
 // Polynomial LCM in Z[X]
 extern ex lcm(const ex &a, const ex &b, bool check_args = true);
 
 // Polynomial LCM in Z[X]
 extern ex lcm(const ex &a, const ex &b, bool check_args = true);
index 99a5a3c4e635273d3eb1dd05da15e760eb4d70a8..72806768dea4564b754b912f3734651331559e22 100644 (file)
@@ -384,8 +384,8 @@ ex power::eval(int level) const
        const ex & ebasis    = level==1 ? basis    : basis.eval(level-1);
        const ex & eexponent = level==1 ? exponent : exponent.eval(level-1);
        
        const ex & ebasis    = level==1 ? basis    : basis.eval(level-1);
        const ex & eexponent = level==1 ? exponent : exponent.eval(level-1);
        
-       const numeric *num_basis = NULL;
-       const numeric *num_exponent = NULL;
+       const numeric *num_basis = nullptr;
+       const numeric *num_exponent = nullptr;
        
        if (is_exactly_a<numeric>(ebasis)) {
                num_basis = &ex_to<numeric>(ebasis);
        
        if (is_exactly_a<numeric>(ebasis)) {
                num_basis = &ex_to<numeric>(ebasis);
@@ -1007,7 +1007,7 @@ private:
                // NB: Partition must be sorted in non-decreasing order.
                explicit coolmulti(const std::vector<int>& partition)
                {
                // NB: Partition must be sorted in non-decreasing order.
                explicit coolmulti(const std::vector<int>& partition)
                {
-                       head = NULL;
+                       head = nullptr;
                        for (unsigned n = 0; n < partition.size(); ++n) {
                                head = new element(partition[n], head);
                                if (n <= 1)
                        for (unsigned n = 0; n < partition.size(); ++n) {
                                head = new element(partition[n], head);
                                if (n <= 1)
@@ -1022,7 +1022,7 @@ private:
                void next_permutation()
                {
                        element *before_k;
                void next_permutation()
                {
                        element *before_k;
-                       if (after_i->next != NULL && i->value >= after_i->next->value)
+                       if (after_i->next != nullptr && i->value >= after_i->next->value)
                                before_k = after_i;
                        else
                                before_k = i;
                                before_k = after_i;
                        else
                                before_k = i;
@@ -1036,7 +1036,7 @@ private:
                }
                bool finished() const
                {
                }
                bool finished() const
                {
-                       return after_i->next == NULL && after_i->value >= head->value;
+                       return after_i->next == nullptr && after_i->value >= head->value;
                }
        } cmgen;
        bool atend;  // needed for simplifying iteration over permutations
                }
        } cmgen;
        bool atend;  // needed for simplifying iteration over permutations
@@ -1053,7 +1053,7 @@ public:
        {
                coolmulti::element* it = cmgen.head;
                size_t i = 0;
        {
                coolmulti::element* it = cmgen.head;
                size_t i = 0;
-               while (it != NULL) {
+               while (it != nullptr) {
                        composition[i] = it->value;
                        it = it->next;
                        ++i;
                        composition[i] = it->value;
                        it = it->next;
                        ++i;
index ead7a777ae963687cac855aa55897b0936565585..e50af5150ff22eb0ecd3ac7310ba0501c4552cad 100644 (file)
@@ -465,7 +465,7 @@ ex pseries::imag_part() const
 
 ex pseries::eval_integ() const
 {
 
 ex pseries::eval_integ() const
 {
-       epvector *newseq = NULL;
+       epvector *newseq = nullptr;
        for (epvector::const_iterator i=seq.begin(); i!=seq.end(); ++i) {
                if (newseq) {
                        newseq->push_back(expair(i->rest.eval_integ(), i->coeff));
        for (epvector::const_iterator i=seq.begin(); i!=seq.end(); ++i) {
                if (newseq) {
                        newseq->push_back(expair(i->rest.eval_integ(), i->coeff));
index 270344e990a3b294e33cc395ca08fdae5386d8df..71932ffa0362b72bb4275a326cd0030e53a6f2a5 100644 (file)
@@ -504,7 +504,7 @@ static ex symm(const ex & e, exvector::const_iterator first, exvector::const_ite
        unsigned *iv = new unsigned[num], *iv2;
        for (unsigned i=0; i<num; i++)
                iv[i] = i;
        unsigned *iv = new unsigned[num], *iv2;
        for (unsigned i=0; i<num; i++)
                iv[i] = i;
-       iv2 = (asymmetric ? new unsigned[num] : NULL);
+       iv2 = (asymmetric ? new unsigned[num] : nullptr);
 
        // Loop over all permutations (the first permutation, which is the
        // identity, is unrolled)
 
        // Loop over all permutations (the first permutation, which is the
        // identity, is unrolled)