]> www.ginac.de Git - ginac.git/log
ginac.git
13 years ago[bugfix] chinrem_gcd: handle polynomials over rationals properly.
Alexei Sheplyakov [Tue, 23 Nov 2010 16:45:52 +0000 (17:45 +0100)]
[bugfix] chinrem_gcd: handle polynomials over rationals properly.

* extract_integer_content():
  integer_content() can also return a rational number, e.g if the expression
  is a polynomial over rationals (in this case expr/content is polynomial
  over integers with integer content being 1). Therefore check if
  integer_content() is really an integer (and if it's not just return 1,
  GCD for polynomials over a field is defined up to arbitrary element of
  the field).

  This fixes possible segfault when computing GCD of polynomials over
  rationals (this is not theoretical, see the added test case).

Thanks to Ernst Moritz Hahn for reporting this bug.
(cherry picked from commit 3d09388a8ea144a19949c216fae43ccba92e47aa)

13 years ago[bugfix] chinrem_gcd: handle polynomials over rationals properly.
Alexei Sheplyakov [Tue, 23 Nov 2010 16:45:52 +0000 (17:45 +0100)]
[bugfix] chinrem_gcd: handle polynomials over rationals properly.

* extract_integer_content():
  integer_content() can also return a rational number, e.g if the expression
  is a polynomial over rationals (in this case expr/content is polynomial
  over integers with integer content being 1). Therefore check if
  integer_content() is really an integer (and if it's not just return 1,
  GCD for polynomials over a field is defined up to arbitrary element of
  the field).

  This fixes possible segfault when computing GCD of polynomials over
  rationals (this is not theoretical, see the added test case).

Thanks to Ernst Moritz Hahn for reporting this bug.

13 years agopower::series(): handle someg (trivial) singularities of the exponent...
Alexei Sheplyakov [Tue, 9 Nov 2010 07:27:47 +0000 (08:27 +0100)]
power::series(): handle someg (trivial) singularities of the exponent...

... so GiNaC can expand expressions like

cos(x)^(sin(x)/x) // (x -> 0)
(1 + x)^(1/x) // x -> 0

and so on.

[Reported by Camille Gillot.]
(cherry picked from commit 079c558d4f9758cd2777a2808a02d64cb1f70c8e)

13 years agopower::series(): handle someg (trivial) singularities of the exponent...
Alexei Sheplyakov [Tue, 9 Nov 2010 07:27:47 +0000 (08:27 +0100)]
power::series(): handle someg (trivial) singularities of the exponent...

... so GiNaC can expand expressions like

cos(x)^(sin(x)/x) // (x -> 0)
(1 + x)^(1/x) // x -> 0

and so on.

[Reported by Camille Gillot.]

13 years agomul: algebraic_subs_mul(), has(): don't write beyond the end of array
Alexei Sheplyakov [Sat, 9 Oct 2010 16:39:41 +0000 (18:39 +0200)]
mul: algebraic_subs_mul(), has(): don't write beyond the end of array

algebraic_match_mul_with_mul() iterates over operands of mul, that is

for (size_t i=0; i<e.nops(); ++i)

However, the size of arrays (`vectors' in STL speak) passed to this
function is seq.size(), which is nops() - 1 for any mul object. Thus
algebraic_match_mul_with_mul() accesses beyond the arrays limit. Usually
it's not a problem, since any reasonable implementation of std::vector<bool>
packs booleans into ints (or longs). However, some STL implementations
(in particular, the one shipped with msvc) are more picky, and access
beyond the vector<bool> limits results in a segfault. Therefore let's
play safe and allocate proper number of elements (that is, nops()) for
those arrays (subsed and currsubsed).
(cherry picked from commit cbb93fadabbd56ba006902967b15b2b2aebb037c)

13 years agomul: algebraic_subs_mul(), has(): don't write beyond the end of array
Alexei Sheplyakov [Sat, 9 Oct 2010 16:39:41 +0000 (18:39 +0200)]
mul: algebraic_subs_mul(), has(): don't write beyond the end of array

algebraic_match_mul_with_mul() iterates over operands of mul, that is

for (size_t i=0; i<e.nops(); ++i)

However, the size of arrays (`vectors' in STL speak) passed to this
function is seq.size(), which is nops() - 1 for any mul object. Thus
algebraic_match_mul_with_mul() accesses beyond the arrays limit. Usually
it's not a problem, since any reasonable implementation of std::vector<bool>
packs booleans into ints (or longs). However, some STL implementations
(in particular, the one shipped with msvc) are more picky, and access
beyond the vector<bool> limits results in a segfault. Therefore let's
play safe and allocate proper number of elements (that is, nops()) for
those arrays (subsed and currsubsed).

13 years agoAvoid infinite loop when unarchiving realsymbol and possymbol.
Alexei Sheplyakov [Mon, 4 Oct 2010 07:21:05 +0000 (09:21 +0200)]
Avoid infinite loop when unarchiving realsymbol and possymbol.

symbol::read_archive(): explicitly set status_flags::evaluated (and
status_flags::expanded) on object being unarchived. These flags get
reset by basic::operator=(const basic&) for realsymbol and possymbol,
and nothing sets (except symbol ctor), so automatic evaluation never
terminates (or rather, terminates due to a stack overflow). Therefore
it's necessary need to set status_flags::evaluated explicitly.

Thanks to Markus Fröb for a bugreport and a test case.
(cherry picked from commit e99d0d58c1bbaa8ee73e4a90a90aa1086f2f813d)

13 years agoAvoid infinite loop when unarchiving realsymbol and possymbol.
Alexei Sheplyakov [Mon, 4 Oct 2010 07:21:05 +0000 (09:21 +0200)]
Avoid infinite loop when unarchiving realsymbol and possymbol.

symbol::read_archive(): explicitly set status_flags::evaluated (and
status_flags::expanded) on object being unarchived. These flags get
reset by basic::operator=(const basic&) for realsymbol and possymbol,
and nothing sets (except symbol ctor), so automatic evaluation never
terminates (or rather, terminates due to a stack overflow). Therefore
it's necessary need to set status_flags::evaluated explicitly.

Thanks to Markus Fröb for a bugreport and a test case.

13 years agoncmul::eval(): don't write beyond the end of the vector.
Alexei Sheplyakov [Sat, 8 Aug 2009 10:03:38 +0000 (13:03 +0300)]
ncmul::eval(): don't write beyond the end of the vector.

13 years agoMake sure add::eval() collects all numeric terms.
Richard Kreckel [Wed, 22 Sep 2010 22:40:38 +0000 (00:40 +0200)]
Make sure add::eval() collects all numeric terms.

Apparently, add::eval() assumed that none of the elements of its epvector
has a numeric rest. However, nothing guarantees that -- in particular
evalchildren() doesn't (and actually cannot) do so. Since there are many
places where a new add is constructed directly from an epvector, enforcing
this doesn't make sense either. One example where it did fail was found by
Burgin Erocal: real_part(1+2*(sqrt(2)+1)*(sqrt(2)-1)) returned 1+2*1, not 3.

Thanks to Burcin Erocal for reporting this bug.
(cherry picked from commit e08cda1854bdb82f6706ec269233577690ae00e4)

13 years agoMake sure add::eval() collects all numeric terms.
Richard Kreckel [Wed, 22 Sep 2010 22:40:38 +0000 (00:40 +0200)]
Make sure add::eval() collects all numeric terms.

Apparently, add::eval() assumed that none of the elements of its epvector
has a numeric rest. However, nothing guarantees that -- in particular
evalchildren() doesn't (and actually cannot) do so. Since there are many
places where a new add is constructed directly from an epvector, enforcing
this doesn't make sense either. One example where it did fail was found by
Burgin Erocal: real_part(1+2*(sqrt(2)+1)*(sqrt(2)-1)) returned 1+2*1, not 3.

Thanks to Burcin Erocal for reporting this bug.

13 years agoBe more careful about final top-level substitution.
Richard Kreckel [Wed, 15 Sep 2010 07:11:57 +0000 (09:11 +0200)]
Be more careful about final top-level substitution.

Substituting x==log(x) in exp(x) erroneously returned log(x) because of a
final subst(x==log(x)) after having eval'ed exp(log(x)) -> x. This final
substitution is wrong in the general case. On the other hand, the intent
is to syntactically substitute functions of a given kind etc. This patch
suppresses the final top-level substitution unless the intermediate result
is a container.

Thanks to Burcin Erocal for reporting this bug (originally described by
Kees van Schaik on sage-support@googlegroops.com).

13 years agoBe more careful about final top-level substitution.
Richard Kreckel [Wed, 15 Sep 2010 07:11:57 +0000 (09:11 +0200)]
Be more careful about final top-level substitution.

Substituting x==log(x) in exp(x) erroneously returned log(x) because of a
final subst(x==log(x)) after having eval'ed exp(log(x)) -> x. This final
substitution is wrong in the general case. On the other hand, the intent
is to syntactically substitute functions of a given kind etc. This patch
suppresses the final top-level substitution unless the intermediate result
is a container.

Thanks to Burcin Erocal for reporting this bug (originally described by
Kees van Schaik on sage-support@googlegroops.com).

13 years agoFix autoconf warning about AC_INIT use.
Richard Kreckel [Mon, 13 Sep 2010 20:39:05 +0000 (22:39 +0200)]
Fix autoconf warning about AC_INIT use.

Apparently, autoconf doesn't like the angle brackets in the bug-report
argument any more. It comlains "not a literal: <ginac-list@ginac.de>".
So let's remove it. And while at it, also provide tarname and url
arguments.

13 years agoFix autoconf warning about AC_INIT use.
Richard Kreckel [Mon, 13 Sep 2010 20:39:05 +0000 (22:39 +0200)]
Fix autoconf warning about AC_INIT use.

Apparently, autoconf doesn't like the angle brackets in the bug-report
argument any more. It comlains "not a literal: <ginac-list@ginac.de>".
So let's remove it. And while at it, also provide tarname and url
arguments.

13 years agopower::eval(): fix several memory leaks
Alexei Sheplyakov [Sun, 22 Aug 2010 20:09:18 +0000 (23:09 +0300)]
power::eval(): fix several memory leaks

While working on fsolve bug I've noticed the following in valgrind log:

==17455== 136 (56 direct, 80 indirect) bytes in 1 blocks are definitely lost in loss record 16 of 19
==17455==    at 0x4C249C7: operator new(unsigned long) (vg_replace_malloc.c:220)
==17455==    by 0x516CA70: GiNaC::power::eval(int) const (power.cpp:540)
==17455==    by 0x4FC1E39: GiNaC::ex::construct_from_basic(GiNaC::basic const&) (ex.cpp:310)
==17455==    by 0x406FBF: main (ex.h:255)

Heap allocated objects definitely need the status_flags::dyncallocated flag.
(cherry picked from commit 5f896fa7f59bbce727e4bba23df9c4bbdbb55c29)

13 years agofsolve: avoid useless numerical evaluation of the function
Alexei Sheplyakov [Sat, 21 Aug 2010 16:13:29 +0000 (19:13 +0300)]
fsolve: avoid useless numerical evaluation of the function

Don't compute f(x) if new x is outside of the interval. We don't need that
value anyway, and the function might be difficult to compute numerically or
even ill defined outside the interval.

As a result fsolve is able to find root(s) of some weird functions.
For example

fsolve((1/(sqrt(2*Pi)))*integral(t, 0, x, exp(-1/2*t^2)) == 0.5, x, 0, 100)

actually works now.
(cherry picked from commit beeb0818e9cdb1b5de0ba2754286ad7bb2a9d032)

13 years agointegral::evalf(): don't attempt to ignore problems.
Alexei Sheplyakov [Thu, 19 Aug 2010 08:10:25 +0000 (11:10 +0300)]
integral::evalf(): don't attempt to ignore problems.

Don't ignore exceptions thrown by numerical integration routine.
In general, the code like this

try {
// blah-blah
} catch (std::exception& err) { }

is just plain evil. Case in the point:

fsolve((1/(sqrt(2*Pi)))*integral(t,0,x,exp(-1/2*t^2))==0.5,x,0,100)
(cherry picked from commit 515171f0bcd42099c266713c3d605cd92cedd2e2)

13 years agofsolve: check if evalf() return value is actually a number.
Alexei Sheplyakov [Wed, 18 Aug 2010 21:07:13 +0000 (00:07 +0300)]
fsolve: check if evalf() return value is actually a number.

Fixes the segfault triggered by

fsolve((1/(sqrt(2*Pi)))*integral(t,0,x,exp(-1/2*t^2))==0.5,x,0,100)

In general, ex_to is unsafe, and should be used only after proper checks.
evalf() may return non-numeric expression for various reasons (bad
convergence, floating point over- or underflow, out of memory, etc).
So let's add missing checks.

Thanks to Ernst Moritz Hahn for a bug report.
(cherry picked from commit 9993a7aac97abf383624fc5dae4beecb29531fbd)

13 years agopower::eval(): fix several memory leaks
Alexei Sheplyakov [Sun, 22 Aug 2010 20:09:18 +0000 (23:09 +0300)]
power::eval(): fix several memory leaks

While working on fsolve bug I've noticed the following in valgrind log:

==17455== 136 (56 direct, 80 indirect) bytes in 1 blocks are definitely lost in loss record 16 of 19
==17455==    at 0x4C249C7: operator new(unsigned long) (vg_replace_malloc.c:220)
==17455==    by 0x516CA70: GiNaC::power::eval(int) const (power.cpp:540)
==17455==    by 0x4FC1E39: GiNaC::ex::construct_from_basic(GiNaC::basic const&) (ex.cpp:310)
==17455==    by 0x406FBF: main (ex.h:255)

Heap allocated objects definitely need the status_flags::dyncallocated flag.

13 years agofsolve: avoid useless numerical evaluation of the function
Alexei Sheplyakov [Sat, 21 Aug 2010 16:13:29 +0000 (19:13 +0300)]
fsolve: avoid useless numerical evaluation of the function

Don't compute f(x) if new x is outside of the interval. We don't need that
value anyway, and the function might be difficult to compute numerically or
even ill defined outside the interval.

As a result fsolve is able to find root(s) of some weird functions.
For example

fsolve((1/(sqrt(2*Pi)))*integral(t, 0, x, exp(-1/2*t^2)) == 0.5, x, 0, 100)

actually works now.

13 years agointegral::evalf(): don't attempt to ignore problems.
Alexei Sheplyakov [Thu, 19 Aug 2010 08:10:25 +0000 (11:10 +0300)]
integral::evalf(): don't attempt to ignore problems.

Don't ignore exceptions thrown by numerical integration routine.
In general, the code like this

try {
// blah-blah
} catch (std::exception& err) { }

is just plain evil. Case in the point:

fsolve((1/(sqrt(2*Pi)))*integral(t,0,x,exp(-1/2*t^2))==0.5,x,0,100)

13 years agofsolve: check if evalf() return value is actually a number.
Alexei Sheplyakov [Wed, 18 Aug 2010 21:07:13 +0000 (00:07 +0300)]
fsolve: check if evalf() return value is actually a number.

Fixes the segfault triggered by

fsolve((1/(sqrt(2*Pi)))*integral(t,0,x,exp(-1/2*t^2))==0.5,x,0,100)

In general, ex_to is unsafe, and should be used only after proper checks.
evalf() may return non-numeric expression for various reasons (bad
convergence, floating point over- or underflow, out of memory, etc).
So let's add missing checks.

Thanks to Ernst Moritz Hahn for a bug report.

13 years agoPreparing for release 1.5.8. release_1-5-8
Jens Vollinga [Tue, 6 Jul 2010 13:30:23 +0000 (15:30 +0200)]
Preparing for release 1.5.8.

13 years agoRemoved trailing spaces.
Jens Vollinga [Tue, 6 Jul 2010 12:38:36 +0000 (14:38 +0200)]
Removed trailing spaces.
(cherry picked from commit dbde7117e88ba61597d6fee18615fe396c291a87)

13 years agoRemoved trailing spaces.
Jens Vollinga [Tue, 6 Jul 2010 12:38:36 +0000 (14:38 +0200)]
Removed trailing spaces.

13 years agoTexinfo interprets @strong{Note...} as a cross reference and gives a
Jens Vollinga [Tue, 6 Jul 2010 09:23:21 +0000 (11:23 +0200)]
Texinfo interprets @strong{Note...} as a cross reference and gives a
warning about it. Changed the text to avoid this.
(cherry picked from commit 7769ce49235ed6510785baa0a29801e3a59b563e)

13 years agoTexinfo interprets @strong{Note...} as a cross reference and gives a
Jens Vollinga [Tue, 6 Jul 2010 09:23:21 +0000 (11:23 +0200)]
Texinfo interprets @strong{Note...} as a cross reference and gives a
warning about it. Changed the text to avoid this.

13 years agoParser: handle abbreviations as advertized in the manual.
Alexei Sheplyakov [Mon, 5 Jul 2010 07:15:20 +0000 (09:15 +0200)]
Parser: handle abbreviations as advertized in the manual.

The following example from the tutorial

GiNaC::symbol x, y;
GiNaC::symtab table;
table["x"] = x+log(y)+1;
GiNaC::parser reader(table);
GiNaC::ex e = reader("5*x3 - x2");

fails with the following exception:

terminate called after throwing an instance of 'std::invalid_argument'
what(): find_or_insert_symbol: name "x" does not correspond to a symbol

Remove silly checks from find_or_insert_symbol, and fix its return value
(should be ex, not symbol).

13 years agoParser: handle abbreviations as advertized in the manual.
Alexei Sheplyakov [Mon, 5 Jul 2010 07:15:20 +0000 (09:15 +0200)]
Parser: handle abbreviations as advertized in the manual.

The following example from the tutorial

GiNaC::symbol x, y;
GiNaC::symtab table;
table["x"] = x+log(y)+1;
GiNaC::parser reader(table);
GiNaC::ex e = reader("5*x3 - x2");

fails with the following exception:

terminate called after throwing an instance of 'std::invalid_argument'
what(): find_or_insert_symbol: name "x" does not correspond to a symbol

Remove silly checks from find_or_insert_symbol, and fix its return value
(should be ex, not symbol).

13 years agoBe more careful with conjugate(f(x)) -> f(conjugate(x)).
Richard Kreckel [Sat, 22 May 2010 20:34:42 +0000 (22:34 +0200)]
Be more careful with conjugate(f(x)) -> f(conjugate(x)).

That identity is correct for holomorphic functions, but we have to be
careful with some functions not being holomorphic everywhere. On branch
cuts, it is wrong. For a discussion, see:
<http://www.ginac.de/pipermail/ginac-list/2010-April/001601.html>.

This patch changes the default behavior of user-defined functions. From
now on, a user-defined conjugate_func must be registered, in order to
evaluate conjugate(f(x)) -> f(conjugate(x)). This patch also adds such
functions for most initially known functions.

13 years agoBe more careful with conjugate(f(x)) -> f(conjugate(x)).
Richard Kreckel [Sat, 22 May 2010 20:34:42 +0000 (22:34 +0200)]
Be more careful with conjugate(f(x)) -> f(conjugate(x)).

That identity is correct for holomorphic functions, but we have to be
careful with some functions not being holomorphic everywhere. On branch
cuts, it is wrong. For a discussion, see:
<http://www.ginac.de/pipermail/ginac-list/2010-April/001601.html>.

This patch changes the default behavior of user-defined functions. From
now on, a user-defined conjugate_func must be registered, in order to
evaluate conjugate(f(x)) -> f(conjugate(x)). This patch also adds such
functions for most initially known functions.

13 years agoFix dangerous iterator use.
Richard Kreckel [Tue, 18 May 2010 22:18:35 +0000 (00:18 +0200)]
Fix dangerous iterator use.

This was detected by cppcheck and reported by Martin Ettl <ettl.martin@gmx.de>.

13 years agoFix dangerous iterator use.
Richard Kreckel [Tue, 18 May 2010 22:18:35 +0000 (00:18 +0200)]
Fix dangerous iterator use.

This was detected by cppcheck and reported by Martin Ettl <ettl.martin@gmx.de>.

13 years agopgcd(), chinrem_gcd(): use appropriate definition of the degree.
Alexei Sheplyakov [Mon, 17 May 2010 22:23:03 +0000 (00:23 +0200)]
pgcd(), chinrem_gcd(): use appropriate definition of the degree.

Effect: fixes (rare) GCD miscalculation.

pgcd() treats polynomials Z_p[x_0, ..., x_n] as R[x_0, ..., x_{n - 1}], where
R = Z_p[x_n]. Therefore one should use correct definition of the degree
(i.e. compute it w.r.t. x_0, ..., x_{n-1}, but NOT w.r.t. x_n!).

One should use appropriate definition of degree (that is, w.r.t.  x_0, ..., x_n)
in chinrem_gcd() too.

Thanks to Aless Lasaruk for a bug report.

13 years agoAdded `degree_vector' utility function.
Alexei Sheplyakov [Mon, 17 May 2010 22:21:53 +0000 (00:21 +0200)]
Added `degree_vector' utility function.

It's a generalization of degree(expr, var) for multivariate polynomials.

13 years agoprimpart_content: correctly handle monomials.
Alexei Sheplyakov [Mon, 17 May 2010 22:20:08 +0000 (00:20 +0200)]
primpart_content: correctly handle monomials.

Impact: fixes (rare) incorrect gcd calculation and (potential) segfault.

Thanks to Aless Lasaruk for a bug report.

13 years agopgcd(): avoid infinite loop if the first GCD candidate coincides with GCD
Alexei Sheplyakov [Mon, 17 May 2010 22:17:26 +0000 (00:17 +0200)]
pgcd(): avoid infinite loop if the first GCD candidate coincides with GCD

136 if (H_lcoeff.is_equal(lc_gcd)) {
137 if ((Hprev-H).expand().smod(pn).is_zero()) // (*)
138 continue;

The check (*) can result in infinite loop if the (very) first GCD candidate
gives the correct GCD: any subsequent iterations give the same result, so
Hprev and H will be equal (hence the infinite loop). That check is not very
useful (AFAIR I was trying to avoid extra division checks), so let's remove it.

13 years agopgcd(), chinrem_gcd(): use appropriate definition of the degree.
Alexei Sheplyakov [Mon, 17 May 2010 22:23:03 +0000 (00:23 +0200)]
pgcd(), chinrem_gcd(): use appropriate definition of the degree.

Effect: fixes (rare) GCD miscalculation.

pgcd() treats polynomials Z_p[x_0, ..., x_n] as R[x_0, ..., x_{n - 1}], where
R = Z_p[x_n]. Therefore one should use correct definition of the degree
(i.e. compute it w.r.t. x_0, ..., x_{n-1}, but NOT w.r.t. x_n!).

One should use appropriate definition of degree (that is, w.r.t.  x_0, ..., x_n)
in chinrem_gcd() too.

Thanks to Aless Lasaruk for a bug report.

13 years agoAdded `degree_vector' utility function.
Alexei Sheplyakov [Mon, 17 May 2010 22:21:53 +0000 (00:21 +0200)]
Added `degree_vector' utility function.

It's a generalization of degree(expr, var) for multivariate polynomials.

13 years agoprimpart_content: correctly handle monomials.
Alexei Sheplyakov [Mon, 17 May 2010 22:20:08 +0000 (00:20 +0200)]
primpart_content: correctly handle monomials.

Impact: fixes (rare) incorrect gcd calculation and (potential) segfault.

Thanks to Aless Lasaruk for a bug report.

13 years agopgcd(): avoid infinite loop if the first GCD candidate coincides with GCD
Alexei Sheplyakov [Mon, 17 May 2010 22:17:26 +0000 (00:17 +0200)]
pgcd(): avoid infinite loop if the first GCD candidate coincides with GCD

136 if (H_lcoeff.is_equal(lc_gcd)) {
137 if ((Hprev-H).expand().smod(pn).is_zero()) // (*)
138 continue;

The check (*) can result in infinite loop if the (very) first GCD candidate
gives the correct GCD: any subsequent iterations give the same result, so
Hprev and H will be equal (hence the infinite loop). That check is not very
useful (AFAIR I was trying to avoid extra division checks), so let's remove it.

13 years agoFix URL of CODA.
Richard Kreckel [Mon, 17 May 2010 06:37:08 +0000 (08:37 +0200)]
Fix URL of CODA.

13 years agoFix URL of CODA.
Richard Kreckel [Mon, 17 May 2010 06:37:08 +0000 (08:37 +0200)]
Fix URL of CODA.

13 years agoFix memory leak in excompiler due to use of wrong operator delete.
Richard Kreckel [Thu, 13 May 2010 20:54:52 +0000 (22:54 +0200)]
Fix memory leak in excompiler due to use of wrong operator delete.

This was reported by Martin Ettl <ettl.martin@gmx.de>.

13 years agoFix memory leak in excompiler due to use of wrong operator delete.
Richard Kreckel [Thu, 13 May 2010 20:54:52 +0000 (22:54 +0200)]
Fix memory leak in excompiler due to use of wrong operator delete.

This was reported by Martin Ettl <ettl.martin@gmx.de>.

13 years agoExplicit function disambiguation.
Richard Kreckel [Thu, 13 May 2010 16:30:40 +0000 (18:30 +0200)]
Explicit function disambiguation.

This is necessary for compilers where the hyperbolic and the tgamma function
templates are pulled in from <cmath> and compete with GiNaC's function
templates. GCC 4.4 and 4.5 need this, when compiling with -std=cxx0x.

13 years agoExplicit function disambiguation.
Richard Kreckel [Thu, 13 May 2010 16:30:40 +0000 (18:30 +0200)]
Explicit function disambiguation.

This is necessary for compilers where the hyperbolic and the tgamma function
templates are pulled in from <cmath> and compete with GiNaC's function
templates. GCC 4.4 and 4.5 need this, when compiling with -std=cxx0x.

13 years agoFix weird ctor invocation syntax.
Richard Kreckel [Tue, 27 Apr 2010 20:44:35 +0000 (22:44 +0200)]
Fix weird ctor invocation syntax.

This patch is required for GCC-4.5.

13 years agoFix weird ctor invocation syntax.
Richard Kreckel [Tue, 27 Apr 2010 20:44:35 +0000 (22:44 +0200)]
Fix weird ctor invocation syntax.

This patch is required for GCC-4.5.

14 years agoPreparing for release 1.5.7. release_1-5-7
Jens Vollinga [Mon, 29 Mar 2010 00:34:52 +0000 (02:34 +0200)]
Preparing for release 1.5.7.

14 years agoProducts (class mul) now answer correctly to info_flags::negative and
Jens Vollinga [Sun, 28 Mar 2010 22:21:18 +0000 (00:21 +0200)]
Products (class mul) now answer correctly to info_flags::negative and
info_flags::negint.
(cherry picked from commit 8a30acc990818792ec4e8f8f4d48f5dd8286dbed)

14 years agoProducts (class mul) now answer correctly to info_flags::negative and
Jens Vollinga [Sun, 28 Mar 2010 22:21:18 +0000 (00:21 +0200)]
Products (class mul) now answer correctly to info_flags::negative and
info_flags::negint.

14 years agoReally fixed the atan2(-Pi, 0) bug.
Richard Kreckel [Thu, 25 Mar 2010 22:08:54 +0000 (23:08 +0100)]
Really fixed the atan2(-Pi, 0) bug.

The problem was that atan2_eval assumed that if y is real and not
positive, it must be negative. But this neglects the fact that in
symbolic compution it may just not be possible to determine the
sign. Now, the expression is returned as it is. Ugly, but correct.

14 years agoReally fixed the atan2(-Pi, 0) bug.
Richard Kreckel [Thu, 25 Mar 2010 22:08:54 +0000 (23:08 +0100)]
Really fixed the atan2(-Pi, 0) bug.

The problem was that atan2_eval assumed that if y is real and not
positive, it must be negative. But this neglects the fact that in
symbolic compution it may just not be possible to determine the
sign. Now, the expression is returned as it is. Ugly, but correct.

14 years agoMerge branch 'master' of ssh://www.ginac.de/srv/git/ginac
Richard Kreckel [Thu, 25 Mar 2010 21:23:13 +0000 (22:23 +0100)]
Merge branch 'master' of ssh://www.ginac.de/srv/git/ginac

14 years agoFixed a bug in atan2. It gave a division by zero error for calls like
Jens Vollinga [Thu, 25 Mar 2010 09:36:41 +0000 (10:36 +0100)]
Fixed a bug in atan2. It gave a division by zero error for calls like
atan2(-Pi,0), because arguments like -Pi were not recognized (via
info_flags) as negative but as real nevertheless.
(cherry picked from commit 9e13d46552bb7852399867b9eb355732b9ded59e)

14 years agoFixed a bug in atan2. It gave a division by zero error for calls like
Jens Vollinga [Thu, 25 Mar 2010 09:36:41 +0000 (10:36 +0100)]
Fixed a bug in atan2. It gave a division by zero error for calls like
atan2(-Pi,0), because arguments like -Pi were not recognized (via
info_flags) as negative but as real nevertheless.

14 years agoCopyright goes 2010.
Jens Vollinga [Fri, 5 Mar 2010 20:37:19 +0000 (21:37 +0100)]
Copyright goes 2010.
(cherry picked from commit 95ede03f00106be5fb087d76c86ca5c27edb9122)

14 years agoCopyright goes 2010.
Jens Vollinga [Fri, 5 Mar 2010 20:37:19 +0000 (21:37 +0100)]
Copyright goes 2010.

14 years agoUpdate copyright notice.
Richard Kreckel [Sat, 27 Feb 2010 14:00:22 +0000 (15:00 +0100)]
Update copyright notice.

14 years agopgcd(): detect relatively prime polynomials properly...
Alexei Sheplyakov [Tue, 23 Feb 2010 10:01:23 +0000 (12:01 +0200)]
pgcd(): detect relatively prime polynomials properly...

... so pgcd() doesn't loop forever any more. Division test does not handle
relatively prime polynomials (because C = 1 divides any polynomial). So we
should stop interpolation (and return gcd of contents) if we got relatively
prime images (we should do that for efficiency reasons too).

Thanks to Jörg Arndt for a bug report.
(cherry picked from commit 6afbb9793e359cf388462c471ea256a6662b0cd4)

14 years agopgcd(): detect relatively prime polynomials properly...
Alexei Sheplyakov [Tue, 23 Feb 2010 10:01:23 +0000 (12:01 +0200)]
pgcd(): detect relatively prime polynomials properly...

... so pgcd() doesn't loop forever any more. Division test does not handle
relatively prime polynomials (because C = 1 divides any polynomial). So we
should stop interpolation (and return gcd of contents) if we got relatively
prime images (we should do that for efficiency reasons too).

Thanks to Jörg Arndt for a bug report.

14 years agoPreparing for release 1.5.6. release_1-5-6
Jens Vollinga [Thu, 28 Jan 2010 14:25:01 +0000 (15:25 +0100)]
Preparing for release 1.5.6.

14 years agoUse C style cast when converting void* into function pointer.
Alexei Sheplyakov [Wed, 6 Jan 2010 17:55:43 +0000 (19:55 +0200)]
Use C style cast when converting void* into function pointer.

Building GiNaC 1.5.5 with GCC 3.4 fails with the following error:

libtool: compile:  ccache g++-3.4 -DHAVE_CONFIG_H -I. -I../../ginac -I../config -I/home/pc7135/varg/target/x86_64-linux-gnu/include -O2 -g -Wall -pipe -MT builtin_fcns.lo -MD -MP -MF .deps/builtin_fcns.Tpo -c ../../ginac/parser/builtin_fcns.cpp  -fPIC -DPIC -o .libs/builtin_fcns.o
../../ginac/parser/builtin_fcns.cpp: In function `GiNaC::ex (* GiNaC::encode_serial_as_reader_func(unsigned int))(const GiNaC::exvector&)':
/home/pc7135/varg/tmp/build/GiNaC/build-linux-gcc-3.4/ginac/../../ginac/parser/builtin_fcns.cpp|67| error: ISO C++ forbids casting between pointer-to-function and pointer-to-object
make[2]: *** [builtin_fcns.lo] Error 1

The C++98 standard [expr.reinterpret.cast] does not allow

reinterpret_cast<function_pointer>(void*)
reinterpret_cast<void*>(function_pointer)

But the ability to do so is important for a lot of practical uses. So soon
after the C++98 standard was approved, a language defect report was filed
on this topic, see
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#195
The result is that compilers will be allowed to support reinterpret_cast
conversions of function pointers to other (pointers) types, and vice a versa.
Such conversions work with *current* compilers (GCC 4.x), but don't work
with older ones, hence this patch.

14 years agoInstall the ginac-excompiler script iff excompiler is supported and enabled.
Alexei Sheplyakov [Wed, 6 Jan 2010 17:56:04 +0000 (19:56 +0200)]
Install the ginac-excompiler script iff excompiler is supported and enabled.
(cherry picked from commit 25c7a8c09f7db73b48675777aa805e788f2308be)

14 years agoInstall the ginac-excompiler script iff excompiler is supported and enabled.
Alexei Sheplyakov [Wed, 6 Jan 2010 17:56:04 +0000 (19:56 +0200)]
Install the ginac-excompiler script iff excompiler is supported and enabled.

14 years agoPreparing for release.
Jens Vollinga [Wed, 4 Nov 2009 22:12:57 +0000 (23:12 +0100)]
Preparing for release.

14 years agoFix libtool versioning fiasco.
Richard Kreckel [Wed, 4 Nov 2009 20:58:26 +0000 (21:58 +0100)]
Fix libtool versioning fiasco.

Fix f2f67dde5c9caca, which caused the soname to be bumped too frequently.

14 years agoFix libtool versioning fiasco.
Richard Kreckel [Wed, 4 Nov 2009 20:58:26 +0000 (21:58 +0100)]
Fix libtool versioning fiasco.

Fix f2f67dde5c9caca, which caused the soname to be bumped too frequently.

14 years agoPreparing for release. release_1-5-4
Jens Vollinga [Mon, 2 Nov 2009 22:29:21 +0000 (23:29 +0100)]
Preparing for release.

14 years agoAdd mul::info() and add::info() support for numeric info_flags.
Richard Kreckel [Sun, 11 Oct 2009 21:19:21 +0000 (23:19 +0200)]
Add mul::info() and add::info() support for numeric info_flags.

This way, GiNaC knows that the sum or product of a number of positive
expressions is again a positive expression. [by Vladimir Kisil]

14 years agoAdd mul::info() and add::info() support for numeric info_flags.
Richard Kreckel [Sun, 11 Oct 2009 21:19:21 +0000 (23:19 +0200)]
Add mul::info() and add::info() support for numeric info_flags.

This way, GiNaC knows that the sum or product of a number of positive
expressions is again a positive expression. [by Vladimir Kisil]

14 years agoMerge branch 'ginac_1-5' of ssh://www.ginac.de/srv/git/ginac into ginac_1-5
Richard Kreckel [Sun, 4 Oct 2009 20:34:33 +0000 (22:34 +0200)]
Merge branch 'ginac_1-5' of ssh://www.ginac.de/srv/git/ginac into ginac_1-5

14 years agoOutput LaTeX-symbols using \mathrm, instead of \mbox.
Richard Kreckel [Sun, 4 Oct 2009 20:30:45 +0000 (22:30 +0200)]
Output LaTeX-symbols using \mathrm, instead of \mbox.

Using \mathrm improves printing in complex formulae.
One reason is that it scales in fractions. [by Vladimir Kisil]

14 years agoOutput LaTeX-symbols using \mathrm, instead of \mbox.
Richard Kreckel [Sun, 4 Oct 2009 20:30:45 +0000 (22:30 +0200)]
Output LaTeX-symbols using \mathrm, instead of \mbox.

Using \mathrm improves printing in complex formulae.
One reason is that it scales in fractions. [by Vladimir Kisil]

14 years agoMoved header includes to source files to avoid polluting the namespace
Jens Vollinga [Sun, 4 Oct 2009 20:15:13 +0000 (22:15 +0200)]
Moved header includes to source files to avoid polluting the namespace
for library users.

14 years agoRemove debian/ directory.
Richard Kreckel [Tue, 29 Sep 2009 20:28:47 +0000 (22:28 +0200)]
Remove debian/ directory.

The lifecycle of the Debian packaging files is better maintained in
the Debian pool's diff file. Removing these files makes the life of
the GiNaC releaser easier.

14 years agoRemove debian/ directory.
Richard Kreckel [Tue, 29 Sep 2009 20:25:16 +0000 (22:25 +0200)]
Remove debian/ directory.

The lifecycle of the Debian packaging files is better maintained in
the Debian pool's diff file. Removing these files makes the life of
the GiNaC releaser easier.

14 years agoProperly document how to deal with libtool versioning.
Richard Kreckel [Tue, 29 Sep 2009 20:08:11 +0000 (22:08 +0200)]
Properly document how to deal with libtool versioning.

The old description was referring to ginac_lt_age which should always
stay 0, because we promised to mark incompatible binary interfaces by
bumping ginac_minor_version (or even ginac_major_version). Let's get
rid of ginac_lt_age.

14 years agoProperly document how to deal with libtool versioning.
Richard Kreckel [Tue, 29 Sep 2009 20:08:11 +0000 (22:08 +0200)]
Properly document how to deal with libtool versioning.

The old description was referring to ginac_lt_age which should always
stay 0, because we promised to mark incompatible binary interfaces by
bumping ginac_minor_version (or even ginac_major_version). Let's get
rid of ginac_lt_age.

14 years agoncmul::eval(): don't write beyond the end of the vector.
Alexei Sheplyakov [Sat, 8 Aug 2009 10:03:38 +0000 (13:03 +0300)]
ncmul::eval(): don't write beyond the end of the vector.

14 years agomodular_matrix: don't use STL iterators in {mul, sub}_col and friends.
Alexei Sheplyakov [Sat, 8 Aug 2009 10:03:15 +0000 (13:03 +0300)]
modular_matrix: don't use STL iterators in {mul, sub}_col and friends.

Not using STL iterators makes the code simpler and cleaner. Also we don't
have to argue whether the standard ([lib.random.access.iterators]) imposes
any pre/post-condictions on operator+=.
(cherry picked from commit 59ec13895c97ffd74979a0b811a7571f6de56386)

14 years agomodular_matrix: don't use STL iterators in {mul, sub}_col and friends.
Alexei Sheplyakov [Sat, 8 Aug 2009 10:03:15 +0000 (13:03 +0300)]
modular_matrix: don't use STL iterators in {mul, sub}_col and friends.

Not using STL iterators makes the code simpler and cleaner. Also we don't
have to argue whether the standard ([lib.random.access.iterators]) imposes
any pre/post-condictions on operator+=.

14 years agoAdded get_builtin_reader() that parses only the builtin GiNaC functions
Jens Vollinga [Sun, 9 Aug 2009 21:38:48 +0000 (23:38 +0200)]
Added get_builtin_reader() that parses only the builtin GiNaC functions
and pow, sqrt, and power.

14 years agoFixed include of stdint.h (parser.cpp needs the header as well).
Jens Vollinga [Sun, 9 Aug 2009 21:27:10 +0000 (23:27 +0200)]
Fixed include of stdint.h (parser.cpp needs the header as well).

14 years agoshaker_sort, permutation_sign: fix invalid use of STL iterators.
Alexei Sheplyakov [Sat, 8 Aug 2009 10:03:48 +0000 (13:03 +0300)]
shaker_sort, permutation_sign: fix invalid use of STL iterators.

According to the standard incrementing end(), and decrementing begin()
are ill-defined operations (see [lib.forward.iterators],
[lib.bidirectional.iterators]).
(cherry picked from commit 694f839947982f5b12b6c629d5bab522c801630d)

14 years agosymmetry::calchash(): be careful to not dereference past-the-end iterator.
Alexei Sheplyakov [Sat, 8 Aug 2009 10:07:14 +0000 (13:07 +0300)]
symmetry::calchash(): be careful to not dereference past-the-end iterator.
(cherry picked from commit 526825bcee294cb20e37d8db6d5040ba0f8c428f)

14 years agocheck_parameter_G: fix pontential increment of end().
Alexei Sheplyakov [Sat, 8 Aug 2009 10:06:36 +0000 (13:06 +0300)]
check_parameter_G: fix pontential increment of end().

Incrementing past-the-end iterator is not permitted by the standard, see
[lib.input.iterators].
(cherry picked from commit 49a44f7d55ec0d6686d3c32c7081a07d10c93274)

14 years agoG_eval: fix incorrect use of STL iterator.
Alexei Sheplyakov [Sat, 8 Aug 2009 10:02:47 +0000 (13:02 +0300)]
G_eval: fix incorrect use of STL iterator.

According to [lib.bidirectional.iterators] it's not OK to decrement
an iterator pointing to the beginning of the sequence. Fortunately random
access iterators provided by (current versions of) gcc/libstdc++ don't have
this silly limitation, so the code which works with pointers works with
iterators without any changes at all. However,
 - there's no guarantee that the current behavior won't change in the future
 - some non-GNU compilers are not that smart (i.e. the program segfaults
   upon when decrementing beginning-of-the-sequence iterator).
(cherry picked from commit dda45abd8a2c408f8b3eb7959a10dfb2468ecc3a)

14 years agoFix the compliation error *for real* ... and restore performance
Alexei Sheplyakov [Sat, 8 Aug 2009 08:43:12 +0000 (11:43 +0300)]
Fix the compliation error *for real* ... and restore performance

Commit 8bf0597dde55e4c94a2ff39f1d8130902e3d7a9b (titled as 'Fixed the parser
such that it can read in user defined classes again.') made the parser a bit
slower, especially if the input contains many terms of user-defined type.
The reason for that is quite simple: we throw and catch an exception every
time we construct an object of user-defined type:

       // dirty hack to distinguish between serial numbers of functions and real
       // pointers.
       GiNaC::function* f = NULL;
       try {
               unsigned serial = (unsigned)(unsigned long)(void *)(reader->second);
               f = new GiNaC::function(serial, args);
       }
       catch ( std::runtime_error ) {
               if ( f ) delete f;
               ex ret = reader->second(args);
               return ret;
       }

Fortunately functions are aligned and we can use much more efficient
technique to distinguish between serial and pointers to functions.

14 years agoFix the compliation error *for real*
Alexei Sheplyakov [Fri, 7 Aug 2009 20:22:18 +0000 (23:22 +0300)]
Fix the compliation error *for real*

14 years agoshaker_sort, permutation_sign: fix invalid use of STL iterators.
Alexei Sheplyakov [Sat, 8 Aug 2009 10:03:48 +0000 (13:03 +0300)]
shaker_sort, permutation_sign: fix invalid use of STL iterators.

According to the standard incrementing end(), and decrementing begin()
are ill-defined operations (see [lib.forward.iterators],
[lib.bidirectional.iterators]).

14 years agosymmetry::calchash(): be careful to not dereference past-the-end iterator.
Alexei Sheplyakov [Sat, 8 Aug 2009 10:07:14 +0000 (13:07 +0300)]
symmetry::calchash(): be careful to not dereference past-the-end iterator.

14 years agocheck_parameter_G: fix pontential increment of end().
Alexei Sheplyakov [Sat, 8 Aug 2009 10:06:36 +0000 (13:06 +0300)]
check_parameter_G: fix pontential increment of end().

Incrementing past-the-end iterator is not permitted by the standard, see
[lib.input.iterators].

14 years agoG_eval: fix incorrect use of STL iterator.
Alexei Sheplyakov [Sat, 8 Aug 2009 10:02:47 +0000 (13:02 +0300)]
G_eval: fix incorrect use of STL iterator.

According to [lib.bidirectional.iterators] it's not OK to decrement
an iterator pointing to the beginning of the sequence. Fortunately random
access iterators provided by (current versions of) gcc/libstdc++ don't have
this silly limitation, so the code which works with pointers works with
iterators without any changes at all. However,
 - there's no guarantee that the current behavior won't change in the future
 - some non-GNU compilers are not that smart (i.e. the program segfaults
   upon when decrementing beginning-of-the-sequence iterator).

14 years agoFixed memory leak.
Jens Vollinga [Fri, 31 Jul 2009 15:54:16 +0000 (17:54 +0200)]
Fixed memory leak.

14 years agoFixed the fix in commit f059ebe117d15292e0d262e6e8e232e835c7e33c.
Jens Vollinga [Fri, 31 Jul 2009 13:29:17 +0000 (15:29 +0200)]
Fixed the fix in commit f059ebe117d15292e0d262e6e8e232e835c7e33c.

14 years agoFixed dirty hack in parser to distinguish between serial numbers and pointers.
Jens Vollinga [Fri, 31 Jul 2009 12:41:08 +0000 (14:41 +0200)]
Fixed dirty hack in parser to distinguish between serial numbers and pointers.

14 years agoFixed the parser such that it can read in user defined classes again.
Jens Vollinga [Fri, 31 Jul 2009 10:48:58 +0000 (12:48 +0200)]
Fixed the parser such that it can read in user defined classes again.
Fixed default reader to parse also pow, sqrt and power.