* Implementation of GiNaC's ABC. */
/*
- * GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2003 Johannes Gutenberg University Mainz, Germany
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include "print.h"
#include "archive.h"
#include "utils.h"
-#include "debugmsg.h"
namespace GiNaC {
GINAC_IMPLEMENT_REGISTERED_CLASS_NO_CTORS(basic, void)
//////////
-// default ctor, dtor, copy ctor assignment operator and helpers
+// default ctor, dtor, copy ctor, assignment operator and helpers
//////////
// public
basic::basic(const basic & other) : tinfo_key(TINFO_basic), flags(0), refcount(0)
{
- debugmsg("basic copy ctor", LOGLEVEL_CONSTRUCT);
copy(other);
}
const basic & basic::operator=(const basic & other)
{
- debugmsg("basic operator=", LOGLEVEL_ASSIGNMENT);
if (this != &other) {
destroy(true);
copy(other);
/** Construct object from archive_node. */
basic::basic(const archive_node &n, const lst &sym_lst) : flags(0), refcount(0)
{
- debugmsg("basic ctor from archive_node", LOGLEVEL_CONSTRUCT);
-
// Reconstruct tinfo_key from class name
std::string class_name;
if (n.find_string("class", class_name))
* level for placing parentheses and formatting */
void basic::print(const print_context & c, unsigned level) const
{
- debugmsg("basic print", LOGLEVEL_PRINT);
-
if (is_of_type(c, print_tree)) {
c.s << std::string(level, ' ') << class_name()
* construction of an ex from a basic. */
basic * basic::duplicate() const
{
- debugmsg("basic duplicate",LOGLEVEL_DUPLICATE);
return new basic(*this);
}
/** Return degree of highest power in object s. */
int basic::degree(const ex & s) const
{
- return 0;
+ return is_equal(ex_to<basic>(s)) ? 1 : 0;
}
/** Return degree of lowest power in object s. */
int basic::ldegree(const ex & s) const
{
- return 0;
+ return is_equal(ex_to<basic>(s)) ? 1 : 0;
}
/** Return coefficient of degree n in object s. */
ex basic::coeff(const ex & s, int n) const
{
- return n==0 ? *this : _ex0();
+ if (is_equal(ex_to<basic>(s)))
+ return n==1 ? _ex1 : _ex0;
+ else
+ return n==0 ? *this : _ex0;
}
/** Sort expanded expression in terms of powers of some object(s).
while (true) {
// Calculate coeff*x1^c1*...*xn^cn
- ex y = _ex1();
+ ex y = _ex1;
for (int i=0; i<num; i++) {
int cnt = si[i].cnt;
y *= power(si[i].sym, cnt);
ex basic::derivative(const symbol & s) const
{
if (nops() == 0)
- return _ex0();
+ return _ex0;
else {
derivative_map_function map_derivative(s);
return map(map_derivative);