CoCoALib is a C++ library of functions for computations in commutative algebra. To use the library you will need some basic knowledge of the C++ programming language; however, most of the computational features of the library can also be accessed from the interactive system CoCoA 5 which offers a more convenient way of doing computations.
CoCoALib comes with a collection of hand-written descriptions of its capabilities as well as a collection of example programs showing how to use many of the features of the library. The hope is that the example programs (plus perhaps a little intelligent guesswork) will suffice to answer most questions about CoCoALib. The hand-written documentation is intended to be more thorough: so less guesswork is needed, but you may have to plough through lots of tedious text to find the detail you're looking for.
The hand-written documentation is split into many files: generally there is one file of documentation for each implementation file in the source code. Furthermore, each file comprises three sections:
We have tried to give CoCoALib a "natural" interface, but this has not always been possible. Here are the main problem areas:
The use of the hat symbol (^) to denote exponentiation is very widespread.
CoCoALib does not allow this you must use the function power
instead.
Why not? Because it would be too easy to write misleading code, i.e.
valid code which does not compute what you would expect. Here is a simple
example: 3*x^2
is interpreted by the compiler as (3*x)^2
. Unfortunately
there is no way to make the C++ compiler use the expected interpretation.
The C++ language is not designed to compute directly with unlimited
integers or with exact rational numbers; special types (namely ZZ
and
QQ
) to handle these sorts of values have been added as part of CoCoALib
(with the real work being done by the GMP library). Nevertheless the user
has to be wary of several pitfalls where code which looks correct at first
glance does not produce the right answer.
2/3
is
valid C++ but is interpreted as an integer division giving result 0
; instead
the rational must be constructed like this QQ(2,3)
n = 99...99;
(with 99 nines) will probably not even compile because of an
error about "integer constant too big"; instead such a large value must be
handled directly by CoCoALib in a call like convert(n, "99...99");
where the
variable n
has already been declared to be of type ZZ
or QQ
.
ZZ
but the computations will be much slower than
with machine integers. If you are quite sure that large values can never occur
then it is fine to use machine integers; otherwise use unlimited integers.