Difference between revisions of "CoCoALib:Examples"

This is created by "make examples" in "CoCoALib/".

DO NOT EDIT UNDER THIS LINE (automatically generated). Send edits and comments to Anna Bigatti.

[ ex-empty.C ]

This is a template file for example programs. The program itself does nothing whatsoever.

long description

Make a copy "foo.C" of this file and put your code in "program" Compile it in the examples directory like this:

 "make foo"


[ ex-BuildInfo.C ]

This is a very short example showing what you can do with BuildInfo.

long description

BuildInfo::PrintAll gives important information in the (enormously unlikely :-) event that you need to report a bug in CoCoALib.

[ ex-ZZ1.C ]

Program to calculate the modular inverse of a number. You must give as input the modulus and the residue; the residue need not be reduced.

long description

This program illustrates that ZZ values can be used much like normal C++ ints except that there is a almost no limit on the magnitude of the values. NB If you need extreme efficiency then use the GMP library directly. Contrast this example with ex-RingZ1.

[ ex-ZZ-prime1.C ]

Program to find a 'big' prime number, suitable for use in cryptographic applications (with some more primality testing).

long description

This program illustrates that ZZ values can be used much like normal C++ ints except that there is a almost no limit on the magnitude of the values. It shows use of some more advanced functions for ZZ values. NB If you need extreme efficiency then use the GMP library directly.

[ ex-ring1.C ]

This example program shows how to create various types of ring, and several operations one can perform on rings (e.g. querying their properties).

long description

It creates several different sorts of ring, and then calls PrintRingInfo on each one. Note the considerable overhead needed to create a (non-standard) PolyRing: first you must make a PPOrdering, then you must make a PPMonoid from that ordering, and finally you can make a PolyRing. The tedious part is specifying the names of the indeterminates. We hope to make this less cumbersome soon.

[ ex-RingZ1.C ]

This is a basic example about the creation and use of the ring of integers. It illustrates the CoCoALib "philosophy" of first creating a ring, and then computing with values in that ring. The C++ commands for performing arithmetic on RingElems have a natural syntax (except we cannot use ^ for powers). It warns about "mixed ring arithmetic", which is forbidden in CoCoALib.

long description

To calculate with elements of a ring we must first create the the ring, then we can create C++ objects of type RingElem which belong to the ring -- a RingElem can change its value but not the ring to which it belongs.

[ ex-RingQ1.C ]

Some simple computations with rational numbers. This example illustrates how to create the field of rational numbers. It shows that we can compute 7/2 in Q but not in Z. It shows how to map an integer into a rational number.

long description

Familiarize yourself with the example ex-RingZ1.C before proceeding. As C++ does not natively have any rings, we must construct them from scratch.

[ ex-RingFloat1.C ]

Example showing some features of RingFloat. Program to explore the precision offered by RingFloat

[ ex-RingFloat2.C ]

Program exhibiting a way of using ever higher precisions...

long description

Example showing iterative increase of precision using RingFloat until the answer is found (or an arbitrary limit on precision is reached). This program will always fail to find the limit: J-M Muller's sequence actually converges to 6 (rather slowly), however it is pathological because it converges to 100 using any finite precision arithmetic. RingFloat detects the onset of pathological convergence to 100, and throws an InsufficientPrecision exception.

[ ex-RingFloat3.C ]

Program showing how some RingFloat values can have more precision than that requested.

long description

Example showing that certain RingFloat values may have a precision higher than that requested. In this case we request 64 bits (i.e. about 19 decimal digits), but are able to remove the nine most significant digits and still have a result with the requested precision. So the original value of the variable third did in fact have at least 93 bits correct (i.e. about 28 decimal digits).

[ ex-RingFp1.C ]

Inefficient program to compute sqrt(2) modulo a given number. Simple example using finite fields or integers modulo N.

long description

The program asks the user for the value of N, it creates the ring of integers mod N, and finally uses "brute force" to find all square-roots of 2 modulo N.

[ ex-RingFp2.C ]

Example program showing how to create small prime finite fields implemented in a specific manner -- normally it is best to let the function NewZmod choose automatically the best implementation.

long description

The program asks the user for the characteristic N, and then tries different ways of making Z mod N.

[ ex-PPMonoidElem1.C ]

Example of use of power products and PPMonoids. Program exhibiting most functions on power products.

[ ex-RingElem1.C ]

Example showing operations on RingElem for a ring or a PolyRing.

long description

This is a long list of function calls from different rings.

[ ex-RingHom1.C ]

The example in this file shows how to create and use some homomorphisms between rings.

long description

We compute these polynomials (with parameters) in some rings: f = (2*a/3-1)*x[0] + 1/a; g = x[0]-a;

[ ex-RingHom2.C ]

Operations between elements of different rings are not allowed but we can use homomorphisms to map the elements into the same ring.

long description

The example in this file shows how to create and use some homomorphisms between rings. In particular, it gives a simple example of mixed ring arithmetic: the user must map all values into a single ring before combining them arithmetically.

[ ex-RingHom3.C ]

This program shows how we can use ring homomorphism to perform a change of coordinates in a polynomial ring.

[ ex-RingHom4.C ]

This program shows how we can use ring homomorphism to evaluate polynomials.

[ ex-matrix1.C ]

Example program illustrating the creation of matrices, and some some operations on them.

long description

Please note that the matrix code is still rather young.

[ ex-module1.C ]

Example program illustrating the creation of free modules, and some some operations on them.

long description

Please note that the module code is still rather young.

[ ex-PolyInput1.C ]

This program shows a way to read a polynomial from the input.

Predefined and user-defined orderings and gradings on PPMonoid and PolyRing.

[ ex-GMPAllocator.C ]

Program to find lengths of 3n+1 sequences. (uses CoCoA::GMPAllocator)

long description

This example shows how a CoCoA::GMPAllocator can be used. If you do computations involving many small big-integers (up to about 40 decimal digits) then the custom allocator may give slightly better run-time performance -- you must compile with debugging turned off! The crucial command is the very first line of "program" just comment it out and recompile to use the default system allocator for GMP values.

[ ex-PolyIterator1.C ]

Program showing how to iterate through "sparse" polynomials.

[ ex-PolyIterator2.C ]

Program showing how to homogenize a sparse polynomial using iterators.

long description

This is just an example! If you want to homogenize polynomials you should use the library function "homog".

[ ex-NF.C ]

Example program illustrating an implementation of Normal Remainder wrt a list of polynomials. If the list is a Groebner Basis, NR returns the Normal Form.

long description

This is just an example! If you want to compute Normal Forms you should use the library function "NF".

[ ex-PolyRing1.C ]

Example of how to create some simple polynomial rings, and use of some of the operations specific to elements of PolyRings.

[ ex-ApproxPts1.C ]

A short example showing how to use the ApproxPt preprocessing algorithms. See the file ex-ApproxPt1.in for a sample input.

[ ex-AlexanderDual.C ]

Program showing how to compute the Alexander Dual of a mon'l sqfr ideal.

long description

It offers the function "PrimaryDecomposition" for a mon'l sqfr ideal which will be included in CoCoALib (sooner or later).

[ ex-QuotientBasis.C ]

Program showing how to compute a quotient basis of a 0-dimensional ideal.

long description

It offers the function "QuotientBasisRec" which will be included in CoCoALib (sooner or later).

[ ex-hilbert1.C ]

This example is just for testing the Hilbert code. It might disappear as soon as HilbertSeries is included in CoCoALib.

long description

This code also shows how to create the "chess examples".

[ ex-RingWeyl1.C ]

An example about RingWeyl, the interface is not quite settled yet.

long description

All these examples about RingWeyl will probably be merged into one.

[ ex-RingWeyl2.C ]

An example about RingWeyl, the interface is not quite settled yet.

long description

This shows a computation of a Groebner BasisAll these examples about RingWeyl will probably be merged into one.

[ ex-RingWeyl3.C ]

An example about RingWeyl, the interface is not quite settled yet.

long description

This shows a computation of a Groebner BasisAll these examples about RingWeyl will probably be merged into one.

[ ex-RingWeyl4.C ]

An example about RingWeyl, the interface is not quite settled yet.

long description

This shows a computation of a Groebner BasisAll these examples about RingWeyl will probably be merged into one.

[ ex-RingWeyl5.C ]

An example about RingWeyl, the interface is not quite settled yet.

long description

This shows a computation of a Groebner BasisAll these examples about RingWeyl will probably be merged into one.

[ ex-FGLM.C ]

Example of how to use the implementation of the FGLM algorithm to do Groebner Basis conversion.

[ ex-OrderIdeal.C ]

Example of how to use the [OrderIdeal] CoCoALib class.

[ ex-BorderBasis.C ]

Example of how to use the implementation of the Border Basis Algorithm to compute a O_\sigma{Id(gens)}-border basis.