working implementation has been available since GCC-2.95.3. GCC-3.0
and later have an even better, fully standard-conforming
implementation, by default. If you are stuck with GCC-2.95.2 or
-earliear and you cannot upgrade your compiler we recommend obtaining
+earlier and you cannot upgrade your compiler we recommend obtaining
the libstdc++-v2 <sstream> header written by Magnus Fromreide. It was
posted to the gcc-patches mailing list on November 21 2000:
<http://gcc.gnu.org/ml/gcc-patches/2000-11/msg01152.html>.
*/
#include <stdexcept>
-#include <iostream>
#include <time.h>
#include "checks.h"
#ifndef CHECKS_H
#define CHECKS_H
-// For rand() and friends:
-#include <stdlib.h>
-using namespace std;
+#include <iostream>
+
#include "config.h"
#include "ginac.h"
+using namespace std;
using namespace GiNaC;
// prototypes for the expression generating functions in:
*/
#include <stdexcept>
-#include <iostream>
#include "exams.h"
#ifndef EXAMS_H
#define EXAMS_H
+#include <iostream>
#include "ginac.h"
using namespace std;
using namespace GiNaC;
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-// For rand() and friends:
-#include <stdlib.h>
-
+#include <cstdlib>
#include "ginac.h"
+using namespace std;
using namespace GiNaC;
/* Create a dense univariate random polynomial in x.
*/
#include <stdexcept>
-#include <iostream>
-
#include "times.h"
int main()
#define CHECKS_H
#include <sys/resource.h>
-#include <stdlib.h>
+#include <cstdlib>
+#include <iostream>
#include <sstream>
#include <vector>
#include "config.h"
pointless) bivariate polynomial with some large coefficients:
@example
+#include <iostream>
#include <ginac/ginac.h>
using namespace std;
using namespace GiNaC;
generates Hermite polynomials in a specified free variable.
@example
+#include <iostream>
#include <ginac/ginac.h>
using namespace std;
using namespace GiNaC;
[[1,1],[2,-1]]+2*[[1,3],[-3,2]]
> evalm(");
[[3,7],[-4,3]]
+> B = [ [0, 0, a], [b, 1, -b], [-1/a, 0, 0] ];
+> evalm(B^(2^12345));
+[[1,0,0],[0,1,0],[0,0,1]]
@end example
Multivariate polynomials and rational functions may be expanded,
integers, construction from C-float and construction from a string:
@example
+#include <iostream>
#include <ginac/ginac.h>
using namespace GiNaC;
digits:
@example
+#include <iostream>
#include <ginac/ginac.h>
using namespace std;
using namespace GiNaC;
some multiple of its denominator and test what comes out:
@example
+#include <iostream>
#include <ginac/ginac.h>
using namespace std;
using namespace GiNaC;
A simple example shall illustrate the concepts:
@example
+#include <iostream>
#include <ginac/ginac.h>
using namespace std;
using namespace GiNaC;
polynomial is analyzed:
@example
-#include <ginac/ginac.h>
-using namespace std;
-using namespace GiNaC;
-
-int main()
@{
symbol x("x"), y("y");
ex PolyInp = 4*pow(x,3)*y + 5*x*pow(y,2) + 3*y
@code{.to_rational()}, described below.
This means that both expressions @code{t1} and @code{t2} are indeed
-simplified in this little program:
+simplified in this little code snippet:
@example
-#include <ginac/ginac.h>
-using namespace GiNaC;
-
-int main()
@{
symbol x("x");
ex t1 = (pow(x,2) + 2*x + 1)/(x + 1);
the derivatives of all the monomials:
@example
-#include <ginac/ginac.h>
-using namespace GiNaC;
-
-int main()
@{
symbol x("x"), y("y"), z("z");
ex P = pow(x, 5) + pow(x, 2) + y;
- cout << P.diff(x,2) << endl; // 20*x^3 + 2
+ cout << P.diff(x,2) << endl;
+ // -> 20*x^3 + 2
cout << P.diff(y) << endl; // 1
+ // -> 1
cout << P.diff(z) << endl; // 0
+ // -> 0
@}
@end example
as you try to change the second. Consider the simple sequence of code:
@example
+#include <iostream>
#include <ginac/ginac.h>
using namespace std;
using namespace GiNaC;
can be:
@example
-#include <ginac/ginac.h>
-using namespace std;
-using namespace GiNaC;
-
-int main()
@{
symbol x("x"), y("y");
lib_LTLIBRARIES = libginac.la
libginac_la_SOURCES = add.cpp archive.cpp basic.cpp constant.cpp ex.cpp \
- expairseq.cpp exprseq.cpp fail.cpp function.cpp inifcns.cpp \
+ expair.cpp expairseq.cpp exprseq.cpp fail.cpp function.cpp inifcns.cpp \
inifcns_trans.cpp inifcns_zeta.cpp inifcns_gamma.cpp matrix.cpp mul.cpp \
normal.cpp numeric.cpp operators.cpp power.cpp registrar.cpp relational.cpp \
symbol.cpp pseries.cpp utils.cpp ncmul.cpp structure.cpp exprseq_suppl.cpp \
lst.cpp lst_suppl.cpp input_parser.yy input_lexer.ll input_lexer.h \
remember.h remember.cpp utils.h idx.cpp indexed.cpp tensor.cpp color.cpp \
- clifford.cpp wildcard.cpp symmetry.cpp fderivative.cpp tostring.h
+ clifford.cpp wildcard.cpp print.cpp symmetry.cpp fderivative.cpp tostring.h
libginac_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
-release $(LT_RELEASE)
ginacincludedir = $(includedir)/ginac
GINAC_DECLARE_REGISTERED_CLASS(add, expairseq)
friend class mul;
- friend class ncmul;
friend class power;
// other constructors
#include "ex.h"
+#include <iosfwd>
#include <string>
#include <vector>
-#include <iostream>
namespace GiNaC {
#ifndef __GINAC_BASIC_H__
#define __GINAC_BASIC_H__
-#include <iostream>
#include <vector>
-
// CINT needs <algorithm> to work properly with <vector>
#include <algorithm>
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <iostream>
+#include <stdexcept>
+
#include "clifford.h"
#include "ex.h"
#include "idx.h"
#include "archive.h"
#include "utils.h"
-#include <stdexcept>
-
namespace GiNaC {
GINAC_IMPLEMENT_REGISTERED_CLASS(clifford, indexed)
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <algorithm>
+#include <iostream>
#include <stdexcept>
#include "color.h"
#include <string>
#include <stdexcept>
+#include <iostream>
#include "constant.h"
#include "numeric.h"
#ifndef __GINAC_EX_H__
#define __GINAC_EX_H__
+#include <iosfwd>
+#include <functional>
+
#include "basic.h"
#include "operators.h"
-#include <functional>
-
namespace GiNaC {
/** Helper class to initialize the library. There must be one static object
--- /dev/null
+/** @file expair.cpp
+ *
+ * Implementation of expression pairs (building blocks of expairseq). */
+
+/*
+ * GiNaC Copyright (C) 1999-2001 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <iostream>
+
+#include "expair.h"
+
+namespace GiNaC {
+
+void expair::print(std::ostream & os) const
+{
+ os << "expair:";
+ print_tree c(os);
+ rest.print(c, c.delta_indent);
+ coeff.print(c, c.delta_indent);
+}
+
+} // namespace GiNaC
return coeff.compare(other.coeff);
}
- void print(std::ostream & os) const
- {
- os << "expair:";
- print_tree c(os);
- rest.print(c, c.delta_indent);
- coeff.print(c, c.delta_indent);
- }
+ void print(std::ostream & os) const;
/** True if this is of the form (numeric,ex(1)). */
bool is_canonical_numeric(void) const
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <iostream>
#include <algorithm>
#include <string>
#include <stdexcept>
/** Brings this expairseq into a sorted (canonical) form. */
void expairseq::canonicalize(void)
{
- sort(seq.begin(), seq.end(), expair_is_less());
+ std::sort(seq.begin(), seq.end(), expair_is_less());
}
/** @file fail.cpp
*
- * Implementation of class signaling failure of operation. Considered obsolete
- * (all of this is replaced by exceptions). */
+ * Implementation of class signaling failure of operation. Considered
+ * somewhat obsolete (most of this can be replaced by exceptions). */
/*
* GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <iostream>
+
#include "fail.h"
#include "print.h"
#include "archive.h"
/** @file fail.h
*
* Interface to class signaling failure of operation. Considered obsolete
- * (all of this is replaced by exceptions). */
+ * somewhat obsolete (most of this can be replaced by exceptions). */
/*
* GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <iostream>
+
#include "fderivative.h"
#include "print.h"
#include "archive.h"
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <iostream>
#include <string>
#include <stdexcept>
#include <list>
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <iostream>
#include <stdexcept>
-#include <algorithm>
#include "idx.h"
#include "symbol.h"
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <iostream>
#include <stdexcept>
-#include <algorithm>
#include "indexed.h"
#include "idx.h"
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <iostream>
#include <algorithm>
#include <map>
#include <stdexcept>
++acc;
c_zeros.push_back(uintpair(acc,c));
}
- sort(c_zeros.begin(),c_zeros.end());
+ std::sort(c_zeros.begin(),c_zeros.end());
std::vector<unsigned> pre_sort;
for (std::vector<uintpair>::const_iterator i=c_zeros.begin(); i!=c_zeros.end(); ++i)
pre_sort.push_back(i->second);
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <iostream>
#include <vector>
#include <stdexcept>
static struct _stat_print {
_stat_print() {}
~_stat_print() {
- cout << "gcd() called " << gcd_called << " times\n";
- cout << "sr_gcd() called " << sr_gcd_called << " times\n";
- cout << "heur_gcd() called " << heur_gcd_called << " times\n";
- cout << "heur_gcd() failed " << heur_gcd_failed << " times\n";
+ std::cout << "gcd() called " << gcd_called << " times\n";
+ std::cout << "sr_gcd() called " << sr_gcd_called << " times\n";
+ std::cout << "heur_gcd() called " << heur_gcd_called << " times\n";
+ std::cout << "heur_gcd() failed " << heur_gcd_failed << " times\n";
}
} stat_print;
#endif
#ifndef __GINAC_OPERATORS_H__
#define __GINAC_OPERATORS_H__
-#include <iostream>
+#include <iosfwd>
namespace GiNaC {
--- /dev/null
+/** @file print.cpp
+ *
+ * Implementation of helper classes for expression output. */
+
+/*
+ * GiNaC Copyright (C) 1999-2001 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <iostream>
+
+#include "print.h"
+
+namespace GiNaC {
+
+print_context::print_context()
+ : s(std::cout) {}
+print_context::print_context(std::ostream & os)
+ : s(os) {}
+
+print_latex::print_latex()
+ : print_context(std::cout) {}
+print_latex::print_latex(std::ostream & os)
+ : print_context(os) {}
+
+print_tree::print_tree(unsigned d)
+ : print_context(std::cout), delta_indent(d) {}
+print_tree::print_tree(std::ostream & os, unsigned d)
+ : print_context(os), delta_indent(d) {}
+
+print_csrc::print_csrc()
+ : print_context(std::cout) {}
+print_csrc::print_csrc(std::ostream & os)
+ : print_context(os) {}
+
+print_csrc_float::print_csrc_float()
+ : print_csrc(std::cout) {}
+print_csrc_float::print_csrc_float(std::ostream & os)
+ : print_csrc(os) {}
+
+print_csrc_double::print_csrc_double()
+ : print_csrc(std::cout) {}
+print_csrc_double::print_csrc_double(std::ostream & os)
+ : print_csrc(os) {}
+
+print_csrc_cl_N::print_csrc_cl_N()
+ : print_csrc(std::cout) {}
+print_csrc_cl_N::print_csrc_cl_N(std::ostream & os)
+ : print_csrc(os) {}
+
+} // namespace GiNaC
/** @file print.h
*
- * Helper classes for expression output. */
+ * Definition of helper classes for expression output. */
/*
* GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
#ifndef __GINAC_PRINT_H__
#define __GINAC_PRINT_H__
-#include <iostream>
+#include <iosfwd>
#include <string>
namespace GiNaC {
class print_context
{
public:
- print_context(std::ostream & os = std::cout) : s(os) {}
- std::ostream & s; /**< stream to output to */
+ print_context();
+ print_context(std::ostream &);
+ std::ostream & s; /**< stream to output to */
+private:
// dummy virtual function to make the class polymorphic
virtual void dummy(void) {}
};
class print_latex : public print_context
{
public:
- print_latex(std::ostream & os = std::cout)
- : print_context(os) {}
+ print_latex();
+ print_latex(std::ostream &);
};
/** Context for tree-like output for debugging. */
class print_tree : public print_context
{
public:
- print_tree(std::ostream & os = std::cout, unsigned d = 4)
- : print_context(os), delta_indent(d) {}
- unsigned delta_indent; /**< size of indentation step */
+ print_tree(unsigned d = 4);
+ print_tree(std::ostream &, unsigned d = 4);
+ const unsigned delta_indent; /**< size of indentation step */
};
/** Base context for C source output. */
class print_csrc : public print_context
{
public:
- print_csrc(std::ostream & os = std::cout)
- : print_context(os) {}
+ print_csrc();
+ print_csrc(std::ostream &);
};
/** Context for C source output using float numbers. */
class print_csrc_float : public print_csrc
{
public:
- print_csrc_float(std::ostream & os = std::cout)
- : print_csrc(os) {}
+ print_csrc_float();
+ print_csrc_float(std::ostream &);
};
/** Context for C source output using double numbers. */
class print_csrc_double : public print_csrc
{
public:
- print_csrc_double(std::ostream & os = std::cout)
- : print_csrc(os) {}
+ print_csrc_double();
+ print_csrc_double(std::ostream &);
};
/** Context for C source output using CLN numbers. */
class print_csrc_cl_N : public print_csrc
{
public:
- print_csrc_cl_N(std::ostream & os = std::cout)
- : print_csrc(os) {}
+ print_csrc_cl_N();
+ print_csrc_cl_N(std::ostream &);
};
/** Check if obj is a T, including base classes. */
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <iostream>
#include <stdexcept>
#include "pseries.h"
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <iostream>
#include <stdexcept>
#include "relational.h"
#ifndef __GINAC_REMEMBER_H__
#define __GINAC_REMEMBER_H__
+#include <iosfwd>
#include <vector>
#include <list>
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <iostream>
#include <string>
#include "structure.h"
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <iostream>
#include <stdexcept>
#include <functional>
-#include <algorithm>
#include "symmetry.h"
#include "lst.h"
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <iostream>
#include <stdexcept>
#include <vector>
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <iostream>
+
#include "wildcard.h"
#include "print.h"
#include "archive.h"
#include <string.h>
#include <map>
+#include <iostream>
#include <string>
using namespace std;
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <stdio.h>
-#include <stdlib.h>
+#include <cstdlib>
+#include <iostream>
#include <fstream>
#include <stdexcept>
#include "ginac.h"
+using namespace std;
using namespace GiNaC;
int main(int argc, char **argv)
{
if (argc < 2) {
- fprintf(stderr, "Usage: %s [-d] file...\n", argv[0]);
+ cerr << "Usage: " << argv[0] << " [-d] file..." << endl;
exit(1);
}
--argc; ++argv;