- added relational::rhs() and relational::lhs() also available from ex.
- added two new checks in check/linear_solve.cpp (formerly
check/lsolve_onedim.cpp) shamelessly ripped from the Maple online-help.
- added keyword warranty to ginsh as dictated by the bible (emacs).
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
- cp -pr $$/$$file $(distdir)/$$file; \
+ cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
check_PROGRAMS = check_ginac
check_ginac_SOURCES = paranoia_check.cpp numeric_output.cpp \
numeric_consist.cpp powerlaws.cpp expand_subs.cpp inifcns_consist.cpp \
- differentiation.cpp poly_gcd.cpp normalization.cpp lsolve_onedim.cpp \
- matrix_checks.cpp series_expansion.cpp lortensor_check.cpp \
+ differentiation.cpp poly_gcd.cpp normalization.cpp matrix_checks.cpp \
+ linear_solve.cpp series_expansion.cpp lortensor_check.cpp \
fcntimer.cpp main.cpp check.h
check_ginac_LDADD = ../ginac/libginac.la
INCLUDES = -I$(srcdir)/../ginac
TESTS = run_checks
check_PROGRAMS = check_ginac
-check_ginac_SOURCES = paranoia_check.cpp numeric_output.cpp numeric_consist.cpp powerlaws.cpp expand_subs.cpp inifcns_consist.cpp differentiation.cpp poly_gcd.cpp normalization.cpp lsolve_onedim.cpp matrix_checks.cpp series_expansion.cpp lortensor_check.cpp fcntimer.cpp main.cpp check.h
+check_ginac_SOURCES = paranoia_check.cpp numeric_output.cpp numeric_consist.cpp powerlaws.cpp expand_subs.cpp inifcns_consist.cpp differentiation.cpp poly_gcd.cpp normalization.cpp matrix_checks.cpp linear_solve.cpp series_expansion.cpp lortensor_check.cpp fcntimer.cpp main.cpp check.h
check_ginac_LDADD = ../ginac/libginac.la
INCLUDES = -I$(srcdir)/../ginac
LIBS = @LIBS@
check_ginac_OBJECTS = paranoia_check.o numeric_output.o \
numeric_consist.o powerlaws.o expand_subs.o inifcns_consist.o \
-differentiation.o poly_gcd.o normalization.o lsolve_onedim.o \
-matrix_checks.o series_expansion.o lortensor_check.o fcntimer.o main.o
+differentiation.o poly_gcd.o normalization.o matrix_checks.o \
+linear_solve.o series_expansion.o lortensor_check.o fcntimer.o main.o
check_ginac_DEPENDENCIES = ../ginac/libginac.la
check_ginac_LDFLAGS =
CXXFLAGS = @CXXFLAGS@
TAR = tar
GZIP_ENV = --best
DEP_FILES = .deps/differentiation.P .deps/expand_subs.P \
-.deps/fcntimer.P .deps/inifcns_consist.P .deps/lortensor_check.P \
-.deps/lsolve_onedim.P .deps/main.P .deps/matrix_checks.P \
+.deps/fcntimer.P .deps/inifcns_consist.P .deps/linear_solve.P \
+.deps/lortensor_check.P .deps/main.P .deps/matrix_checks.P \
.deps/normalization.P .deps/numeric_consist.P .deps/numeric_output.P \
.deps/paranoia_check.P .deps/poly_gcd.P .deps/powerlaws.P \
.deps/series_expansion.P
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
- cp -pr $$/$$file $(distdir)/$$file; \
+ cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
unsigned poly_gcd();
unsigned normalization();
unsigned matrix_checks();
-unsigned lsolve_onedim();
+unsigned linear_solve();
unsigned series_expansion();
unsigned lortensor_check();
--- /dev/null
+/** @file linear_solve.cpp
+ *
+ * These test routines do some simple checks on solving linear systems of
+ * symbolic equations. */
+
+/*
+ * GiNaC Copyright (C) 1999-2000 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 "ginac.h"
+
+#ifndef NO_NAMESPACE_GINAC
+using namespace GiNaC;
+#endif // ndef NO_NAMESPACE_GINAC
+
+static unsigned lsolve1(void)
+{
+ unsigned result = 0;
+ symbol x("x");
+ ex eq, aux;
+
+ eq = (3*x+5 == numeric(8));
+ aux = lsolve(eq, x);
+ if (aux != 1) {
+ result++;
+ clog << "solution of 3*x+5==8 erroneously returned "
+ << aux << endl;
+ }
+
+ return result;
+}
+
+static unsigned lsolve2a(void)
+{
+ unsigned result = 0;
+ symbol a("a"), b("b"), x("x"), y("y");
+ lst eqns, vars;
+ ex sol;
+
+ // Create the linear system [a*x+b*y==3,x-y==b]...
+ eqns.append(a*x+b*y==3).append(x-y==b);
+ // ...to be solved for [x,y]...
+ vars.append(x).append(y);
+ // ...and solve it:
+ sol = lsolve(eqns, vars);
+ ex sol_x = sol.op(0).rhs(); // rhs of solution for first variable (x)
+ ex sol_y = sol.op(1).rhs(); // rhs of solution for second variable (y)
+
+ // It should have returned [x==(3+b^2)/(a+b),y==(3-a*b)/(a+b)]
+ if (!(sol_x - (3+pow(b,2))/(a+b)).is_zero() ||
+ !(sol_y - (3-a*b)/(a+b)).is_zero()) {
+ result++;
+ clog << "solution of the system " << eqns << " for " << vars
+ << " erroneously returned " << sol << endl;
+ }
+
+ return result;
+}
+
+static unsigned lsolve2b(void)
+{
+ unsigned result = 0;
+ symbol x("x"), y("y");
+ lst eqns, vars;
+ ex sol;
+
+ // Create the linear system [I*x+y==1,I*x-y==2]...
+ eqns.append(I*x+y==1).append(I*x-y==2);
+ // ...to be solved for [x,y]...
+ vars.append(x).append(y);
+ // ...and solve it:
+ sol = lsolve(eqns, vars);
+ ex sol_x = sol.op(0).rhs(); // rhs of solution for first variable (x)
+ ex sol_y = sol.op(1).rhs(); // rhs of solution for second variable (y)
+
+ // It should have returned [x==-3/2*I,y==-1/2]
+ if (!(sol_x - numeric(-3,2)*I).is_zero() ||
+ !(sol_y - numeric(-1,2)).is_zero()) {
+ result++;
+ clog << "solution of the system " << eqns << " for " << vars
+ << " erroneously returned " << sol << endl;
+ }
+
+ return result;
+}
+
+unsigned linear_solve(void)
+{
+ unsigned result = 0;
+
+ cout << "checking linear solve..." << flush;
+ clog << "---------linear solve:" << endl;
+
+ result += lsolve1();
+ result += lsolve2a();
+ result += lsolve2b();
+
+ if (!result) {
+ cout << " passed ";
+ clog << "(no output)" << endl;
+ } else {
+ cout << " failed ";
+ }
+
+ return result;
+}
+++ /dev/null
-/** @file lsolve_onedim.cpp
- *
- * This test routine does some simple checks on solving a polynomial for a
- * variable. */
-
-/*
- * GiNaC Copyright (C) 1999-2000 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 "ginac.h"
-
-#ifndef NO_NAMESPACE_GINAC
-using namespace GiNaC;
-#endif // ndef NO_NAMESPACE_GINAC
-
-unsigned lsolve_onedim(void)
-{
- unsigned result = 0;
- symbol x("x");
- ex eq, aux;
-
- cout << "checking linear solve..." << flush;
- clog << "---------linear solve:" << endl;
-
- eq = (3*x+5 == numeric(8));
- aux = lsolve(eq,x);
- if (aux != 1) {
- result++;
- clog << "solution of 3*x+5==8 erroneously returned "
- << aux << endl;
- }
-
- if (!result) {
- cout << " passed ";
- clog << "(no output)" << endl;
- } else {
- cout << " failed ";
- }
-
- return result;
-}
result += fcntimer(poly_gcd);
result += fcntimer(normalization);
result += fcntimer(matrix_checks);
- result += fcntimer(lsolve_onedim);
+ result += fcntimer(linear_solve);
result += fcntimer(series_expansion);
result += fcntimer(lortensor_check);
}
# Files which are generated by perl scripts
$(srcdir)/dummies.h $(srcdir)/dummies.cpp: $(srcdir)/dummies.pl
- cd $(srcdir) && perl dummies.pl
+ cd $(srcdir) && perl -w dummies.pl
# Force build of headers before compilation
$(srcdir)/ginaccint.bin.cpp: $(srcdir)/dummies.h
-# Force make clean to call Makecint's own Makefile
+# Force targets clean and distclean to call Makecint's own Makefile
makecint_clean:
(if [ -f Makefile.makecint ]; then $(MAKE) -f Makefile.makecint clean; fi)
+
clean: makecint_clean
+ -rm -f libginac.*
+
+distclean: makecint_clean
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
- cp -pr $$/$$file $(distdir)/$$file; \
+ cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
# Files which are generated by perl scripts
$(srcdir)/dummies.h $(srcdir)/dummies.cpp: $(srcdir)/dummies.pl
- cd $(srcdir) && perl dummies.pl
+ cd $(srcdir) && perl -w dummies.pl
# Force build of headers before compilation
$(srcdir)/ginaccint.bin.cpp: $(srcdir)/dummies.h
-# Force make clean to call Makecint's own Makefile
+# Force targets clean and distclean to call Makecint's own Makefile
makecint_clean:
(if [ -f Makefile.makecint ]; then $(MAKE) -f Makefile.makecint clean; fi)
+
clean: makecint_clean
+ -rm -f libginac.*
+
+distclean: makecint_clean
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.PP
\fBginsh\fP(1)
.SH COPYRIGHT
-.SS CINT COPYRIGHT
-Copyright \(co of Cint and associated tools are owned by Agilent
-Technologies Japan Company and the author. Acknowledgement to the
-author by e-mail is recommended at installation. Source code, binary
-executable or library of Cint and associated tools can be used,
-modified and distributed free of charge for any purpose provided that
-the copyright notice appear in all copies and that both that copyright
-notice and this permission notice appear in documentation.
-Registration is requested, at this moment, for commercial use. Send
-e-mail to the author <MXJ02154@niftyserve.or.jp>. The registration is
-free.
.SS GINAC COPYRIGHT
Copyright \(co 1999-2000 Johannes Gutenberg Universit\(:at Mainz, Germany
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., 675 Mass Ave, Cambridge, MA 02139, USA.
+.SS CINT COPYRIGHT
+Copyright \(co of Cint and associated tools are owned by Agilent
+Technologies Japan Company and the author. Acknowledgement to the
+author by e-mail is recommended at installation. Source code, binary
+executable or library of Cint and associated tools can be used,
+modified and distributed free of charge for any purpose provided that
+the copyright notice appear in all copies and that both that copyright
+notice and this permission notice appear in documentation.
+Registration is requested, at this moment, for commercial use. Send
+e-mail to the author <MXJ02154@niftyserve.or.jp>. The registration is
+free.
<< " __, _______ requested, at this moment, for commercial use. Send e-mail to" << endl
<< " (__) * | <MXJ02154@niftyserve.or.jp>. The registration is free." << endl
<< " ._) i N a C | The GiNaC framework is Copyright by Johannes Gutenberg Univ.," << endl
- << "<-------------' Germany and licensed under the terms and conditions of the GPL." << endl << endl;
+ << "<-------------' Germany and licensed under the terms and conditions of the GPL." << endl
+ << endl;
}
int main(void)
string command;
while (!end_of_command) {
line = G__input(prompt);
-
+
int pos = 0;
bool double_quote=false;
bool single_quote=false;
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
- cp -pr $$/$$file $(distdir)/$$file; \
+ cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
- cp -pr $$/$$file $(distdir)/$$file; \
+ cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
- cp -pr $$/$$file $(distdir)/$$file; \
+ cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
- cp -pr $$/$$file $(distdir)/$$file; \
+ cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
#include "ncmul.h"
#include "numeric.h"
#include "power.h"
+#include "relational.h"
#include "debugmsg.h"
#include "utils.h"
return (*bp)[i];
}
+/** Return operand/member at position i. */
ex ex::op(int i) const
{
debugmsg("ex op()",LOGLEVEL_MEMBER_FUNCTION);
return bp->op(i);
}
+/** Return modifyable operand/member at position i. */
ex & ex::let_op(int i)
{
debugmsg("ex let_op()",LOGLEVEL_MEMBER_FUNCTION);
return bp->let_op(i);
}
+/** Left hand side of relational expression. */
+ex ex::lhs(void) const
+{
+ debugmsg("ex lhs()",LOGLEVEL_MEMBER_FUNCTION);
+ GINAC_ASSERT(is_ex_of_type(*this,relational));
+ return (*static_cast<relational *>(bp)).lhs();
+}
+
+/** Right hand side of relational expression. */
+ex ex::rhs(void) const
+{
+ debugmsg("ex rhs()",LOGLEVEL_MEMBER_FUNCTION);
+ GINAC_ASSERT(is_ex_of_type(*this,relational));
+ return (*static_cast<relational *>(bp)).rhs();
+}
+
#ifndef INLINE_EX_CONSTRUCTORS
int ex::compare(const ex & other) const
{
ex operator[](int i) const;
ex op(int i) const;
ex & let_op(int i);
+ ex lhs(void) const;
+ ex rhs(void) const;
int compare(const ex & other) const
#ifdef INLINE_EX_CONSTRUCTORS
{
inline ex subs(const ex & thisex, const lst & ls, const lst & lr)
{ return thisex.subs(ls, lr); }
+inline ex op(const ex & thisex, int i)
+{ return thisex.op(i); }
+
+inline ex lhs(const ex & thisex)
+{ return thisex.lhs(); }
+
+inline ex rhs(const ex & thisex)
+{ return thisex.rhs(); }
+
+inline bool is_zero(const ex & thisex)
+{ return thisex.is_zero(); }
+
inline void swap(ex & e1, ex & e2)
{ e1.swap(e2); }
/** Ctor from CLN types. This is for the initiated user or internal use
* only. */
-numeric::numeric(cl_N const & z) : basic(TINFO_numeric)
+numeric::numeric(const cl_N & z) : basic(TINFO_numeric)
{
debugmsg("numeric constructor from cl_N", LOGLEVEL_CONSTRUCT);
value = new cl_N(z);
explicit numeric(long numer, long denom);
explicit numeric(double d);
explicit numeric(const char *);
- numeric(cl_N const & z);
-
+ numeric(const cl_N & z);
+
// functions overriding virtual functions from bases classes
public:
basic * duplicate() const;
// new virtual functions which can be overridden by derived classes
//////////
-// none
+/** Left hand side of relational. */
+ex relational::lhs(void) const
+{
+ return lh;
+}
+
+/** Right hand side of relational. */
+ex relational::rhs(void) const
+{
+ return rh;
+}
//////////
// non-virtual functions in this class
unsigned return_type_tinfo(void) const;
// new virtual functions which can be overridden by derived classes
- // none
+public:
+ virtual ex lhs(void) const;
+ virtual ex rhs(void) const;
// non-virtual functions in this class
public:
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
- cp -pr $$/$$file $(distdir)/$$file; \
+ cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
/* keywords */
quit|exit return T_QUIT;
+warranty return T_WARRANTY;
print return T_PRINT;
read return T_READ;
write return T_WRITE;
%token T_NUMBER T_SYMBOL T_LITERAL T_DIGITS T_QUOTE T_QUOTE2 T_QUOTE3
%token T_EQUAL T_NOTEQ T_LESSEQ T_GREATEREQ T_MATRIX_BEGIN T_MATRIX_END
-%token T_QUIT T_PRINT T_READ T_WRITE T_TIME T_XYZZY T_INVENTORY T_LOOK T_SCORE
+%token T_QUIT T_WARRANTY T_PRINT T_READ T_WRITE T_TIME T_XYZZY T_INVENTORY T_LOOK T_SCORE
/* Operator precedence and associativity */
%right '='
| '?' T_SYMBOL {print_help(ex_to_symbol($2).getname());}
| '?' '?' {print_help_topics();}
| T_QUIT {YYACCEPT;}
+ | T_WARRANTY {
+ cout << "This program is free software; you can redistribute it and/or modify it under\n";
+ cout << "the terms of the GNU General Public License as published by the Free Software\n";
+ cout << "Foundation; either version 2 of the License, or (at your option) any later\n";
+ cout << "version.\n";
+ cout << "This program is distributed in the hope that it will be useful, but WITHOUT\n";
+ cout << "ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n";
+ cout << "FOR A PARTICULAR PURPOSE. See the GNU General Public License for more\n";
+ cout << "details.\n";
+ cout << "You should have received a copy of the GNU General Public License along with\n";
+ cout << "this program. If not, write to the Free Software Foundation, 675 Mass Ave,\n";
+ cout << "Cambridge, MA 02139, USA.\n";
+
+ }
| T_XYZZY {cout << "Nothing happens.\n";}
| T_INVENTORY {cout << "You're not carrying anything.\n";}
| T_LOOK {cout << "You're in a twisty little maze of passages, all alike.\n";}
cout << " __, _______ Copyright (C) 1999-2000 Johannes Gutenberg University Mainz,\n"
<< " (__) * | Germany. This is free software with ABSOLUTELY NO WARRANTY.\n"
<< " ._) i N a C | You are welcome to redistribute it under certain conditions;\n"
- << "<-------------' see the file COPYING for details." << endl;
+ << "<-------------' see the file COPYING for details.\n" << endl;
cout << "Type ?? for a list of help topics." << endl;
}
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
- cp -pr $$/$$file $(distdir)/$$file; \
+ cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \