]> www.ginac.de Git - ginac.git/log
ginac.git
7 years agoReplace mktemp with mkstemp.
Till Hofmann [Sat, 8 Oct 2016 18:34:40 +0000 (20:34 +0200)]
Replace mktemp with mkstemp.

As the manpage says, mktemp is deprecated ("Never use mktemp") and gcc
warns about the usage of mktemp. Replace mktemp with its safe variant
mkstemp.

7 years agoFinalize 1.7.1 release. release_1-7-1
Richard Kreckel [Sat, 1 Oct 2016 22:46:08 +0000 (00:46 +0200)]
Finalize 1.7.1 release.

7 years agoSuppress compiler warnings about inconsistent override.
Richard Kreckel [Sat, 1 Oct 2016 22:45:11 +0000 (00:45 +0200)]
Suppress compiler warnings about inconsistent override.

The introduction of the 'override' keyword in GiNaC in d5b86dd10 was
deliberately incomplete: Duplication of code in macros was avoided.
It turns out that some compilers (e.g. g++ -Wsuggest-override or clang++
-Wall) complain if the 'override' keyword is used inconsistently. Let's
make this consistent now, even if it leads to the introduction of two
more macros.

7 years agoFix compilation of programs using __attribute__((deprecated)).
Richard Kreckel [Wed, 14 Sep 2016 20:00:29 +0000 (22:00 +0200)]
Fix compilation of programs using __attribute__((deprecated)).

Ouu, we mustn't redefine 'deprecated' in order for this to work...

Thanks to Alexander Proskurin for reporting this.

7 years agoUpdate ax_cxx_compile_stdcxx.m4.
Richard Kreckel [Wed, 17 Aug 2016 20:08:57 +0000 (22:08 +0200)]
Update ax_cxx_compile_stdcxx.m4.

Serial 3 fixes make CXXFLAGS=..., c.f. the macro's upstream revision history.

7 years agoImprove performance of clifford_to_lst().
Vladimir Kisil [Wed, 17 Aug 2016 20:05:13 +0000 (22:05 +0200)]
Improve performance of clifford_to_lst().

Rewrite get_clifford_comp() so it is less obscure and more efficient.

7 years agoFix convergence of Li_projection at ±I.
Stefan Weinzierl [Thu, 11 Aug 2016 21:55:59 +0000 (23:55 +0200)]
Fix convergence of Li_projection at ±I.

For arguments near ±I, direct summation does not practically converge.
Use the Bernoulli transformation instead.

Thanks to Peter Banks for reporting this:
<http://www.cebix.net/pipermail/ginac-list/2016-August/002085.html>

7 years agoAdd proper functions to make clifford_bar() and clifford_star().
Vladimir Kisil [Thu, 11 Aug 2016 18:47:08 +0000 (20:47 +0200)]
Add proper functions to make clifford_bar() and clifford_star().

Previously operations clifford_bar() and clifford_star() called
conjugate() method. This results in reversion of all non-commutative
entries (not only Clifford units) and produced complex conjugation
of all non-real items. The new routine operates on Clifford units only.

7 years ago[bugfix] Fix crash in basic::subs().
Richard Kreckel [Thu, 21 Jul 2016 06:55:44 +0000 (08:55 +0200)]
[bugfix] Fix crash in basic::subs().

A regression in 1.7.0 was introduced with 1b8bcb06 in function
basic::subs_one_level(): implicitly casting *this to an ex first for
finding *this in m and later in the function's return statement caused
a crash in the second cast because *this was deleted in the first one.
After all, *this was dynamically allocated in basic::subs().

This bug was reported and hunted down by Mario Prausa.

7 years agoFinalize 1.7.0 release. release_1-7-0
Richard Kreckel [Sat, 30 Apr 2016 20:39:42 +0000 (22:39 +0200)]
Finalize 1.7.0 release.

7 years agoMore shortcuts for trivial cases in mul::combine_*_to_pair().
Richard Kreckel [Fri, 29 Apr 2016 05:31:20 +0000 (07:31 +0200)]
More shortcuts for trivial cases in mul::combine_*_to_pair().

7 years agoUpdate reference to Robert C. Martin's "Acyclic Visitor" paper.
Richard Kreckel [Mon, 18 Apr 2016 20:18:20 +0000 (22:18 +0200)]
Update reference to Robert C. Martin's "Acyclic Visitor" paper.

The source at objectmentor.com has been unavailble for a long while.

8 years agoAdd fderivative::derivatives() method.
Richard Kreckel [Thu, 14 Apr 2016 19:29:37 +0000 (21:29 +0200)]
Add fderivative::derivatives() method.

8 years agoFix typos in comments.
Richard Kreckel [Wed, 13 Apr 2016 06:50:41 +0000 (08:50 +0200)]
Fix typos in comments.

8 years agoUpdate compiler list and compile times.
Richard Kreckel [Wed, 13 Apr 2016 06:15:44 +0000 (08:15 +0200)]
Update compiler list and compile times.

8 years agoPrefer C library wrappers over C headers, where possible.
Richard Kreckel [Wed, 13 Apr 2016 06:10:22 +0000 (08:10 +0200)]
Prefer C library wrappers over C headers, where possible.

8 years agoMerge branch 'c++11' in preparation for version 1.7.0.
Richard Kreckel [Tue, 5 Apr 2016 20:51:12 +0000 (22:51 +0200)]
Merge branch 'c++11' in preparation for version 1.7.0.

8 years ago[build] Install compiler.h header file. c++11
Richard Kreckel [Mon, 4 Apr 2016 18:42:12 +0000 (20:42 +0200)]
[build] Install compiler.h header file.

Some header files need the deprecated macro. (Looking forward to C++14.)

8 years agoInstall ginac-excompiler in $LIBEXECDIR, not in $BINDIR.
Richard Kreckel [Mon, 4 Apr 2016 07:05:50 +0000 (09:05 +0200)]
Install ginac-excompiler in $LIBEXECDIR, not in $BINDIR.

...and make the GiNaC library aware of where it is installed.

The ginac-excompiler script is only invoked by GiNaC::compile_ex(...)
and serves no purpose on its own. In compliance with the FHS, it should
be installed in $LIBEXECDIR, not in $BINDIR. This also disburdens
distribution packagers from having to provide a manpage (which may be
required for all programs in $BINDIR).

The location for $LIBEXECDIR defaults to ${prefix}/libexec/. It may be
overwritten at configuration time. (Many distributions want to set it to
${prefix}/lib/ginac/.)

8 years ago[build] Ship FindLibDL.cmake, it's needed by CMakeLists.txt.
Richard Kreckel [Sun, 3 Apr 2016 15:46:47 +0000 (17:46 +0200)]
[build] Ship FindLibDL.cmake, it's needed by CMakeLists.txt.

8 years agoRemove ex::to_rational(lst) and ex::to_polynomial(lst).
Richard Kreckel [Sat, 12 Mar 2016 23:02:57 +0000 (00:02 +0100)]
Remove ex::to_rational(lst) and ex::to_polynomial(lst).

Those were GiNaC 1.1 compatibility functions. Use the corresponding
functions with exmap arguments instead.

8 years agoFinalize 1.6.7 release. release_1-6-7
Richard Kreckel [Sat, 6 Feb 2016 11:51:39 +0000 (12:51 +0100)]
Finalize 1.6.7 release.

8 years agoUse C++11 'auto' and range-based for loops where possible.
Richard Kreckel [Thu, 25 Feb 2016 21:12:28 +0000 (22:12 +0100)]
Use C++11 'auto' and range-based for loops where possible.

8 years agoUse C++11 'nullptr' where applicable.
Richard Kreckel [Mon, 22 Feb 2016 21:51:40 +0000 (22:51 +0100)]
Use C++11 'nullptr' where applicable.

8 years ago[build] Force C++11 compilation when using CMake.
Richard Kreckel [Thu, 11 Feb 2016 22:10:55 +0000 (23:10 +0100)]
[build] Force C++11 compilation when using CMake.

8 years ago[build] Fix CMake build.
Richard Kreckel [Thu, 11 Feb 2016 22:08:12 +0000 (23:08 +0100)]
[build] Fix CMake build.

8 years agominor optimization in power::expand_add
Richard Kreckel [Sat, 6 Feb 2016 22:19:35 +0000 (23:19 +0100)]
minor optimization in power::expand_add

8 years agoFix a comment.
Richard Kreckel [Sat, 6 Feb 2016 11:53:14 +0000 (12:53 +0100)]
Fix a comment.

8 years agospeed up multiply_lcm(e, lcm) a bit
Richard Kreckel [Sat, 6 Feb 2016 00:35:07 +0000 (01:35 +0100)]
speed up multiply_lcm(e, lcm) a bit

and comment it a little

8 years ago[bugfix] fix elusive bug in quo, rem,...
Richard Kreckel [Fri, 5 Feb 2016 23:47:08 +0000 (00:47 +0100)]
[bugfix] fix elusive bug in quo, rem,...

The power of two rational numeric objects needs not be rational. As a
result, some care is required when transforming (b^e)*l -> (b*l^(1/e))^e
for some rational e and l. This is a common transformation in order to
convert a polynomial over Q into a polynomial over Z when computing
their quotient, remainder, etc. Failure to be careful can potentially
introduce spurious non-rational numbers into rational polynomials and
make those operations fail. This patch avoids this transformation when
l^(1/e) is not a rational number.

8 years ago[bugfix] fix elusive bug in quo, rem,...
Richard Kreckel [Fri, 5 Feb 2016 23:47:08 +0000 (00:47 +0100)]
[bugfix] fix elusive bug in quo, rem,...

The power of two rational numeric objects needs not be rational. As a
result, some care is required when transforming (b^e)*l -> (b*l^(1/e))^e
for some rational e and l. This is a common transformation in order to
convert a polynomial over Q into a polynomial over Z when computing
their quotient, remainder, etc. Failure to be careful can potentially
introduce spurious non-rational numbers into rational polynomials and
make those operations fail. This patch avoids this transformation when
l^(1/e) is not a rational number.

8 years ago[bugfix] fix sqrfree(poly) for zero polynomials in disguise.
Richard Kreckel [Wed, 3 Feb 2016 07:13:58 +0000 (08:13 +0100)]
[bugfix] fix sqrfree(poly) for zero polynomials in disguise.

Yun's algorithm now handles polynomials which would become zero after
expanding.

8 years ago[bugfix] fix sqrfree(poly) for zero polynomials in disguise.
Richard Kreckel [Wed, 3 Feb 2016 07:13:58 +0000 (08:13 +0100)]
[bugfix] fix sqrfree(poly) for zero polynomials in disguise.

Yun's algorithm now handles polynomials which would become zero after
expanding.

8 years agoRemove extra cases for missing <stdint.h>.
Richard Kreckel [Sun, 31 Jan 2016 09:15:50 +0000 (10:15 +0100)]
Remove extra cases for missing <stdint.h>.

Use <cstdint> unconditionally -- it's been standardized in C++11.

8 years ago[C++17] Remove inheritance from std::binary_function, std::unary_function.
Richard Kreckel [Fri, 29 Jan 2016 22:45:21 +0000 (23:45 +0100)]
[C++17] Remove inheritance from std::binary_function, std::unary_function.

This inheritance is unneeded since C++11 and the two classes may be
removed in C++-17.

8 years ago[C++17] Replace std::bind2nd with a lambda.
Richard Kreckel [Fri, 29 Jan 2016 21:57:52 +0000 (22:57 +0100)]
[C++17] Replace std::bind2nd with a lambda.

8 years agoRemove global variable max_recursion_level.
Richard Kreckel [Thu, 28 Jan 2016 23:11:14 +0000 (00:11 +0100)]
Remove global variable max_recursion_level.

With the removal of the last 'level' parameter, this variable has
become obsolete.

8 years agoRemove 'level' argument of normal().
Richard Kreckel [Thu, 28 Jan 2016 21:45:56 +0000 (22:45 +0100)]
Remove 'level' argument of normal().

The 'level' argument was modeled after that of the eval() methods
(removed in 6c946d4c). It has never been very useful except for
confusing developers and it hasn't been documented in the tutorial.
Moreover, I have no indication that it has ever been used.

8 years agoRemove 'level' argument of evalf().
Richard Kreckel [Thu, 28 Jan 2016 21:11:46 +0000 (22:11 +0100)]
Remove 'level' argument of evalf().

The 'level' argument was modeled after that of the eval() methods
(removed in 6c946d4c). It has never been very useful except for
confusing developers. Moreover, I have no indication that it has
ever been used.

8 years agoAvoid x^0 and Order(x^0) terms together in series expansion.
Richard Kreckel [Wed, 6 Jan 2016 21:34:23 +0000 (22:34 +0100)]
Avoid x^0 and Order(x^0) terms together in series expansion.

At the branch cut, the series expansions of log(), atan(), and atanh()
assembled pseries objects which contained both x^0 and Order(x^0) terms.
This patch removes the extra x^0 term if the order is 0. It also adds
a GINAC_ASSERT for these kinds of invariants to the pseries ctor and
simplifies the loops in pseries' degree(), ldegree(), eval() and evalf()
member functions.

8 years agoHappy New Year!
Richard Kreckel [Fri, 1 Jan 2016 10:49:48 +0000 (11:49 +0100)]
Happy New Year!

8 years agoHappy New Year!
Richard Kreckel [Fri, 1 Jan 2016 01:05:06 +0000 (02:05 +0100)]
Happy New Year!

8 years agoDe-document eval() in ginsh help and manpage.
Richard Kreckel [Fri, 1 Jan 2016 01:02:49 +0000 (02:02 +0100)]
De-document eval() in ginsh help and manpage.

This was forgotten in 6c946d4c.

8 years agoMake relational::rhs() and lhs() nonvirtual.
Richard Kreckel [Thu, 31 Dec 2015 18:34:54 +0000 (19:34 +0100)]
Make relational::rhs() and lhs() nonvirtual.

I am unable to see a point in ever overriding these two member functions.

8 years agoClarification on symmetries of metric of clifford object.
Vladimir V. Kisil [Thu, 31 Dec 2015 15:44:16 +0000 (16:44 +0100)]
Clarification on symmetries of metric of clifford object.

The metric of a clifford object may be non-symmetric. Even if
a metric is defined by a symmetric tensor, clifford object may
not be aware of the symmetry and it needs to be explicitly declared.

Signed-off-by: Vladimir V. Kisil <kisilv@maths.leeds.ac.uk>
8 years agoAdd specific dbgprinttree() method to clifford.
Vladimir V. Kisil [Thu, 31 Dec 2015 15:41:48 +0000 (16:41 +0100)]
Add specific dbgprinttree() method to clifford.

Metric is an important element of a clifford object, thus it is useful
to have the metric to be printed in the detailed debug printing.

Signed-off-by: Vladimir V. Kisil <kisilv@maths.leeds.ac.uk>
8 years agocache pseries coeff accesses in pseries::mul_series.
Ralf Stephan [Thu, 31 Dec 2015 15:36:46 +0000 (16:36 +0100)]
cache pseries coeff accesses in pseries::mul_series.

Coeff is too general as long as we have only ints as exponents.
This patch fixes a potentially cubic slowdown.

8 years agoFinalize 1.6.6 release. ginac_1-6-6
Richard Kreckel [Sun, 20 Dec 2015 20:29:55 +0000 (21:29 +0100)]
Finalize 1.6.6 release.

8 years agoRemove reference to ftpthep.physik.uni-mainz.de.
Richard Kreckel [Sun, 20 Dec 2015 16:56:09 +0000 (17:56 +0100)]
Remove reference to ftpthep.physik.uni-mainz.de.

Higgs is down, alas...

8 years agoRemove reference to ftpthep.physik.uni-mainz.de.
Richard Kreckel [Sun, 20 Dec 2015 16:56:09 +0000 (17:56 +0100)]
Remove reference to ftpthep.physik.uni-mainz.de.

Higgs is down, alas...

8 years agoHoist typeid(*this) from loops.
Richard Kreckel [Sun, 20 Dec 2015 16:50:07 +0000 (17:50 +0100)]
Hoist typeid(*this) from loops.

The compilers don't seem to reliably recognize the invariance of this.

8 years agoRemove iter_swap specializations.
Richard Kreckel [Sun, 20 Dec 2015 16:30:34 +0000 (17:30 +0100)]
Remove iter_swap specializations.

It's a myth that iter_swap helps the compiler produce better code.
Let's just use specialized swap instead.

8 years agoAdd support for power::info(info_flags::real).
Richard Kreckel [Sun, 20 Dec 2015 03:44:01 +0000 (04:44 +0100)]
Add support for power::info(info_flags::real).

(And, while at it, clean up the surrounding code a bit.)

8 years agoRemove info_flags::algebraic.
Richard Kreckel [Sun, 20 Dec 2015 03:36:42 +0000 (04:36 +0100)]
Remove info_flags::algebraic.

It doesn't work, never has, and it is quire unclear how to fix it.

8 years agoRemove expairseq::construct_from_2_ex_via_exvector() member function.
Richard Kreckel [Thu, 17 Dec 2015 23:06:31 +0000 (00:06 +0100)]
Remove expairseq::construct_from_2_ex_via_exvector() member function.

This function is much slower than the optimized construct_from_2_ex()
member function, which explains why it wasn't used.

8 years agoinclude <algorithm> for use of std::min().
Richard Kreckel [Thu, 17 Dec 2015 21:57:04 +0000 (22:57 +0100)]
include <algorithm> for use of std::min().

Thanks to Jan Rheinländer for reporting this.

Cherry-picked from a56196f3.

8 years agoinclude <algorithm> for use of std::min().
Richard Kreckel [Thu, 17 Dec 2015 21:57:04 +0000 (22:57 +0100)]
include <algorithm> for use of std::min().

Thanks to Jan Rheinländer for reporting this.

8 years agoRemove useless code in add::eval().
Richard Kreckel [Thu, 17 Dec 2015 21:45:50 +0000 (22:45 +0100)]
Remove useless code in add::eval().

With commit ae6c004b, we have actually a more rigorous solution for the
bug fixed first (and wrongly) on September 23 2010 with commit 89d5356b.
This patch removes the now useless code and adds the new regression check
from master, just in case.

8 years ago[bugfix] Make sure add::eval() collects all numeric terms *correctly*.
Richard Kreckel [Thu, 17 Dec 2015 21:30:13 +0000 (22:30 +0100)]
[bugfix] Make sure add::eval() collects all numeric terms *correctly*.

This fixes a bug introduced with in 2010 with 89d5356b.

8 years agoAdd rvalue reference ctors from epvectors for add, mul.
Richard Kreckel [Thu, 17 Dec 2015 08:32:15 +0000 (09:32 +0100)]
Add rvalue reference ctors from epvectors for add, mul.

8 years agoMerge some cosmetic patches.
Richard Kreckel [Wed, 16 Dec 2015 21:02:25 +0000 (22:02 +0100)]
Merge some cosmetic patches.

This is a collection of some minor optimizations and indentation fixes.

8 years agoMake .eval() evaluate top-level only.
Richard Kreckel [Wed, 16 Dec 2015 20:22:36 +0000 (21:22 +0100)]
Make .eval() evaluate top-level only.

With the previous patch, some old workarounds have become unnecessary:
If all expressions are evaluated, any object which is an aggregate of
expressions will only ever have to evaluate the top level. As such, it
has become pointless to evaluate child objects of an expression prior
to doing its own term-rewriting. This patch removes the evaluation of
children from all GiNaC objects. It also removes the now superfluous
parameter 'level' of the eval methods.

8 years agoMake add::eval(), mul::eval() work without compromise.
Richard Kreckel [Wed, 16 Dec 2015 12:00:30 +0000 (13:00 +0100)]
Make add::eval(), mul::eval() work without compromise.

If a user asks to evaluate an object, the expectation is that the
library returns an evaluated, canonical expression. Everything else is
a bug. (It doesn't matter whether the user asks explicitly or by
assigning to an ex.) It turns out that it was possible to construct
objects which didn't fully evaluate. This patch fixes this by making
eval() a little bit more careful.

This obsoletes the need to go through combine_ex_with_coeff_to_pair()
when constructing an epvector that is then used to construct an add
or mul. (Alas, this was omitted frequently enough...)

8 years agoImprove method of setting status_flags::dynallocated.
Richard Kreckel [Mon, 30 Nov 2015 22:06:53 +0000 (23:06 +0100)]
Improve method of setting status_flags::dynallocated.

There seems to be no way to obsolete the need to mark an object derived
from basic and handled by ex as being 'on the heap', at least none that
doesn't have significant performance impact. Having said that, this
patch aims at making this process simpler and more intuitive.

Where, before, one would return from a function returning an ex with
        return (new mul(a, b))->setflag(status_flags::dynallocated);
this patch lets us return with
        return dynallocate<mul>(a, b);
which should be much clearer. In any case, it involves less typing.

The two points where the status_flags::dynallocated are set are now
  * the dynallocate<B>(args...) template function and
  * the virtual duplicate() member functions.

This patch rolls out the new functionality throughout the library.

8 years agoRemove accidentally pushed binary.
Richard Kreckel [Sun, 29 Nov 2015 11:42:59 +0000 (12:42 +0100)]
Remove accidentally pushed binary.

In commit 79cad108, a compiled binary from the test suite was accidentally
added and pushed. Sorry.

8 years agoRename array of precomputed data in test suite.
Richard Kreckel [Sun, 29 Nov 2015 11:33:59 +0000 (12:33 +0100)]
Rename array of precomputed data in test suite.

Reason: C++17 may introduce a std::data<> template. Right now, the GCC 6.0
prerelease bails out at this code, when compiler with -std=c++17.
<http://en.cppreference.com/w/cpp/iterator/data>

8 years agoUse neseted initializer lists to construct matrix objects.
Richard Kreckel [Sat, 28 Nov 2015 14:43:46 +0000 (15:43 +0100)]
Use neseted initializer lists to construct matrix objects.

Add constructor of initializer_list<initializer_list<ex>> to matrix.
Use this syntax where, previously, ctor from comma-separated list of
elements was used. Deprecate the ctor from comma-separated list.

Note: The output format '[[a,b],[c,d]]' and ginsh syntax are
unchanged because lists are printed '{a,b,c}' and a matrix is not a
list of lists.

8 years ago[build] Update scripts for correct rpath for linking with CLN.
Richard Kreckel [Fri, 27 Nov 2015 10:49:16 +0000 (11:49 +0100)]
[build] Update scripts for correct rpath for linking with CLN.

Use up-to-date files from GNU gettext 0.19.6.

8 years agoUse initializer lists to construct container<>, lst.
Richard Kreckel [Thu, 26 Nov 2015 20:36:46 +0000 (21:36 +0100)]
Use initializer lists to construct container<>, lst.

Add constructor of initializer_list<ex> to container<C<ex>>. In
particular, this means that we can finally declare lst objects as
lst{a,2*b,2}. Convert GiNaC to this syntax throughout. Deprecate
the old constructors taking 1..16 ex parameters and the ones from
comma seaparated lists (without braces).

8 years agoInfrastructure: Update baseline language check M4 macros.
Richard Kreckel [Thu, 26 Nov 2015 14:04:52 +0000 (15:04 +0100)]
Infrastructure: Update baseline language check M4 macros.

Use the more general ax_cxx_compile_stdcxx.m4 macro from gnu.org
instead of the old ax_cxx_compile_stdcxx_11.m4.

8 years agoMake ample use of the contextual keyword 'override'.
Richard Kreckel [Thu, 26 Nov 2015 11:20:20 +0000 (12:20 +0100)]
Make ample use of the contextual keyword 'override'.

This patch adds the C++11 contextual keyword 'override' to every overridden
virtual function declaration except where that would incur macro duplications.
Along the way, it fixes some comments about member functions 'virtuality'.

8 years agoStandard header cleanup.
Richard Kreckel [Wed, 25 Nov 2015 14:17:20 +0000 (15:17 +0100)]
Standard header cleanup.

Sanitize some standard headers, remove include directives of unused
headers, complete configure check for used standard headers.

8 years agoReplace idx_is_not functor by a C++11 lambda.
Richard Kreckel [Wed, 25 Nov 2015 11:49:31 +0000 (12:49 +0100)]
Replace idx_is_not functor by a C++11 lambda.

8 years agoIn power::expand_add(), don't reserve excess monomial sizes.
Richard Kreckel [Wed, 25 Nov 2015 10:28:10 +0000 (11:28 +0100)]
In power::expand_add(), don't reserve excess monomial sizes.

There is no need to reserve n terms in each of the monomials of the
result of power(+(x,y,z...;0),n): We can compute it exactly as the
number of nonzero exponents in the multinomial expansion. The good
thing is that this counting is the same for each composition of a
partition, so it can be hoisted out of the loop over compositions.

8 years agoIn power::expand_add(), don't reserve excess monomial sizes.
Richard Kreckel [Wed, 25 Nov 2015 10:28:10 +0000 (11:28 +0100)]
In power::expand_add(), don't reserve excess monomial sizes.

There is no need to reserve n terms in each of the monomials of the
result of power(+(x,y,z...;0),n): We can compute it exactly as the
number of nonzero exponents in the multinomial expansion. The good
thing is that this counting is the same for each composition of a
partition, so it can be hoisted out of the loop over compositions.

8 years agoMake specialized power::expand() helpers static member fuctions.
Richard Kreckel [Wed, 25 Nov 2015 10:22:34 +0000 (11:22 +0100)]
Make specialized power::expand() helpers static member fuctions.

The class power member functions expand_add(), expand_add_2(), and
expand_mul() do not access any member variable of class power. (In
fact, the only reason not to hide them entirely is that they invoke
protected members of classs expairseq, add, and mul which requires
them to be friends of these classes.)

8 years agoTutorial: how to create noncommutative symbols?
Richard Kreckel [Tue, 24 Nov 2015 12:09:47 +0000 (13:09 +0100)]
Tutorial: how to create noncommutative symbols?

This seems to be frequently asked:
<http://www.ginac.de/pipermail/ginac-devel/2015-November/002213.html>

Cherry-picked from dfaba64c.

8 years agoTutorial: how to create noncommutative symbols?
Richard Kreckel [Tue, 24 Nov 2015 12:02:46 +0000 (13:02 +0100)]
Tutorial: how to create noncommutative symbols?

This seems to be frequently asked:
<http://www.ginac.de/pipermail/ginac-devel/2015-November/002213.html>

8 years agomul::can_make_flat(): Finish ancient unfinished code.
Richard Kreckel [Tue, 24 Nov 2015 10:14:51 +0000 (11:14 +0100)]
mul::can_make_flat(): Finish ancient unfinished code.

This makes mul(expairseq({a*b,2},{b})) construct the canonical
mul(expairseq({a,3},{b,2})). Normally, such term rewriting is done
by the .eval() methods, but this is not done when a plain object of
a class derived from basic is constructed.

Cherry-picked from 26e2662e.

8 years agounit_matrix(r,c) can return an evaluated matrix object.
Richard Kreckel [Tue, 24 Nov 2015 11:00:25 +0000 (12:00 +0100)]
unit_matrix(r,c) can return an evaluated matrix object.

Cherry-picked from 052e9928.

8 years agoAvoid some explicit copying of STL containers.
Richard Kreckel [Tue, 24 Nov 2015 10:57:35 +0000 (11:57 +0100)]
Avoid some explicit copying of STL containers.

8 years agomul::can_make_flat(): Finish ancient unfinished code.
Richard Kreckel [Tue, 24 Nov 2015 10:14:51 +0000 (11:14 +0100)]
mul::can_make_flat(): Finish ancient unfinished code.

This makes mul(expairseq({a*b,2},{b})) construct the canonical
mul(expairseq({a,3},{b,2})). Normally, such term rewriting is done
by the .eval() methods, but this is not done when a plain object of
a class derived from basic is constructed.

8 years agounit_matrix(r,c) can return an evaluated matrix object.
Richard Kreckel [Mon, 23 Nov 2015 20:38:30 +0000 (21:38 +0100)]
unit_matrix(r,c) can return an evaluated matrix object.

8 years agoMake (a+b+c+...)^n work for huuuge terms.
Richard Kreckel [Mon, 23 Nov 2015 20:21:18 +0000 (21:21 +0100)]
Make (a+b+c+...)^n work for huuuge terms.

This fix is neccessary for results exceeding 2^31 terms. While at it,
also restructured power::expand_add_() a bit to look more like the
more general power::expand_add().

8 years agoConvert some more ctors from copying to moving STL containers.
Richard Kreckel [Mon, 23 Nov 2015 18:36:53 +0000 (19:36 +0100)]
Convert some more ctors from copying to moving STL containers.

8 years agoReplace static const variables with constexpr, where applicable.
Richard Kreckel [Sun, 8 Nov 2015 22:33:33 +0000 (23:33 +0100)]
Replace static const variables with constexpr, where applicable.

8 years agoFix some pedantic compiler warnings.
Richard Kreckel [Sun, 8 Nov 2015 22:18:19 +0000 (23:18 +0100)]
Fix some pedantic compiler warnings.

Found with CLang++ -Wall. (There remain some more, but these are
more ugly to fix.)

8 years agoReplace GiNaC::ToString() with std::to_string().
Richard Kreckel [Sun, 8 Nov 2015 21:19:08 +0000 (22:19 +0100)]
Replace GiNaC::ToString() with std::to_string().

And, while at it, also make CMake exercise the new real_imag exam
introduced last week and document successful build with GCC-4.8.

8 years agoUse C++11 'nullptr' where applicable.
Richard Kreckel [Sat, 7 Nov 2015 21:24:29 +0000 (22:24 +0100)]
Use C++11 'nullptr' where applicable.

8 years agoRemove C++89 workaround for closing angle brackets in nested templates.
Richard Kreckel [Sat, 7 Nov 2015 12:23:26 +0000 (13:23 +0100)]
Remove C++89 workaround for closing angle brackets in nested templates.

8 years agoRemove 'discardable' option from ctors of container and derived classes.
Richard Kreckel [Sat, 7 Nov 2015 12:03:05 +0000 (13:03 +0100)]
Remove 'discardable' option from ctors of container and derived classes.

The whole idea of this was to allow the ctor to pilfer the data from the
constructed-from object, which is precisely the move semantics which
C++11 supports with rvalue references.

8 years agoAdd trivial shortcuts in expair plumbing of class add.
Richard Kreckel [Sat, 7 Nov 2015 00:50:00 +0000 (01:50 +0100)]
Add trivial shortcuts in expair plumbing of class add.

These little shortcuts in add::split_ex_to_pair(ex) and in
add::combine_ex_with_coeff_to_pair(ex, ex) avoid the creation of
new ex objects. These pieces of code are executed so often that this
patch speeds up GiNaC by 5-10%, depending on test.

8 years agoAdd trivial shortcuts in expair plumbing of class add.
Richard Kreckel [Sat, 7 Nov 2015 00:50:00 +0000 (01:50 +0100)]
Add trivial shortcuts in expair plumbing of class add.

These little shortcuts in add::split_ex_to_pair(ex) and in
add::combine_ex_with_coeff_to_pair(ex, ex) avoid the creation of
new ex objects. These pieces of code are executed so often that this
patch speeds up GiNaC by 5-10%, depending on test.

8 years agoFix little missed optimization.
Richard Kreckel [Fri, 6 Nov 2015 14:04:49 +0000 (15:04 +0100)]
Fix little missed optimization.

8 years agoFix little missed optimization.
Richard Kreckel [Fri, 6 Nov 2015 14:04:49 +0000 (15:04 +0100)]
Fix little missed optimization.

8 years agoReplace dynamic throw() with static noexcept operator.
Richard Kreckel [Fri, 6 Nov 2015 00:00:55 +0000 (01:00 +0100)]
Replace dynamic throw() with static noexcept operator.

8 years agoAdd some minor optimizations.
Richard Kreckel [Thu, 5 Nov 2015 12:41:18 +0000 (13:41 +0100)]
Add some minor optimizations.

8 years agoSpeed up power::real_part() and power::imag_part().
Richard Kreckel [Thu, 5 Nov 2015 12:30:48 +0000 (13:30 +0100)]
Speed up power::real_part() and power::imag_part().

Add special case for real base and exponent (not just integer exponent).
Improve special case for integer exponent by explicitly constructing
the result using the Binomial expansion.
Add a test case for real/imaginary part expansion.

8 years agoAdd some minor optimizations.
Richard Kreckel [Thu, 5 Nov 2015 12:41:18 +0000 (13:41 +0100)]
Add some minor optimizations.

8 years agoSpeed up power::real_part() and power::imag_part().
Richard Kreckel [Thu, 5 Nov 2015 12:30:48 +0000 (13:30 +0100)]
Speed up power::real_part() and power::imag_part().

Add special case for real base and exponent (not just integer exponent).
Improve special case for integer exponent by explicitly constructing
the result using the Binomial expansion.
Add a test case for real/imaginary part expansion.