*/
void randomify_symbol_serials()
{
- srand(time(NULL));
+ srand(time(nullptr));
const int m = rand() % 666;
for (int s=0; s<m; ++s ) {
symbol("dummy");
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;
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)) {
- if (copy == NULL)
+ if (copy == nullptr)
copy = duplicate();
copy->let_op(i) = n;
}
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;
}
- /** 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();
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) {
}
}
-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
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());
*/
void* link_so_file(const std::string filename, bool clean_up)
{
- void* module = NULL;
+ void* module = nullptr;
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!");
}
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();
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;
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;
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);
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);
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);
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;
}
// 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);
*
* @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
- * @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)
*
* @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
- * @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)
*
* @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 */
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);
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);
// 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)
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;
}
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
{
coolmulti::element* it = cmgen.head;
size_t i = 0;
- while (it != NULL) {
+ while (it != nullptr) {
composition[i] = it->value;
it = it->next;
++i;
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));
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)