Using C++ as an implementation language provides
operator+ (const cl_MI&, const cl_MI&)
requires that both
arguments belong to the same modular ring cannot be expressed as a compile-time
information.
+
, -
, *
,
=
, ==
, ... can be used in infix notation, which is more
convenient than Lisp notation `(+ x y)' or C notation `add(x,y,&z)'.
With these language features, there is no need for two separate languages, one for the implementation of the library and one in which the library's users can program. This means that a prototype implementation of an algorithm can be integrated into the library immediately after it has been tested and debugged. No need to rewrite it in a low-level language after having prototyped in a high-level language.
In order to save memory allocations, CLN implements:
x+0
returns x
without copying
it.
> -2^29
,
< 2^29
don't consume heap memory, unless they were explicitly allocated
on the heap.
Speed efficiency is obtained by the combination of the following tricks and algorithms:
i386
, m68k
, sparc
, mips
, arm
).
O(N^2)
algorithm, the Karatsuba multiplication, which is an
O(N^1.6)
algorithm.
All the number classes are reference count classes: They only contain a pointer to an object in the heap. Upon construction, assignment and destruction of number objects, only the objects' reference count are manipulated.
Memory occupied by number objects are automatically reclaimed as soon as their reference count drops to zero.
For number rings, another strategy is implemented: There is a cache of, for example, the modular integer rings. A modular integer ring is destroyed only if its reference count dropped to zero and the cache is about to be resized. The effect of this strategy is that recently used rings remain cached, whereas undue memory consumption through cached rings is avoided.
Go to the first, previous, next, last section, table of contents.