Class Library for Numbers
Encyclopedia
CLN is a free
library for arbitrary precision arithmetic. It operates on signed integer
s, rational numbers, floating point
numbers, complex numbers, modular
numbers, and univariate polynomial
s. Its implementation programming language
is C++
.
CLN uses object oriented techniques and operator overloading
to achieve a natural algebra
ic syntax: The sum x of two variables a and b is written as x = a + b, as opposed to the function sum(&x, a, b).
CLN uses class inheritance
to model the natural subset
s of the available number types: E.g. the integer class is a subtype of the rational class, just as the integer numbers are a subset of the rational numbers. The complex numbers and all its subtypes behave exactly like the types of numbers known to the Common Lisp
language, giving CLN another meaning: it becomes an abbreviation of Common Lisp Numbers. Due to this, CLN can be and is used for implementations of Common Lisp, other interpreted languages, or computer algebra system
s.
The implementation is efficient. It can be configured to use the GNU Multi-Precision Library
as kernel for speed-critical inner loop
s and implements advanced algorithms like Schönhage–Strassen multiplication, binary splitting
and others. All CLN objects are either immediate or reference counted
, providing for non-interruptive garbage collection
with no burden on the main application.
Free software
Free software, software libre or libre software is software that can be used, studied, and modified without restriction, and which can be copied and redistributed in modified or unmodified form either without restriction, or with restrictions that only ensure that further recipients can also do...
library for arbitrary precision arithmetic. It operates on signed integer
Integer
The integers are formed by the natural numbers together with the negatives of the non-zero natural numbers .They are known as Positive and Negative Integers respectively...
s, rational numbers, floating point
Floating point
In computing, floating point describes a method of representing real numbers in a way that can support a wide range of values. Numbers are, in general, represented approximately to a fixed number of significant digits and scaled using an exponent. The base for the scaling is normally 2, 10 or 16...
numbers, complex numbers, modular
Modular arithmetic
In mathematics, modular arithmetic is a system of arithmetic for integers, where numbers "wrap around" after they reach a certain value—the modulus....
numbers, and univariate polynomial
Polynomial
In mathematics, a polynomial is an expression of finite length constructed from variables and constants, using only the operations of addition, subtraction, multiplication, and non-negative integer exponents...
s. Its implementation programming language
Programming language
A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....
is C++
C++
C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...
.
CLN uses object oriented techniques and operator overloading
Operator overloading
In object oriented computer programming, operator overloading—less commonly known as operator ad-hoc polymorphism—is a specific case of polymorphism, where different operators have different implementations depending on their arguments...
to achieve a natural algebra
Algebra
Algebra is the branch of mathematics concerning the study of the rules of operations and relations, and the constructions and concepts arising from them, including terms, polynomials, equations and algebraic structures...
ic syntax: The sum x of two variables a and b is written as x = a + b, as opposed to the function sum(&x, a, b).
CLN uses class inheritance
Inheritance (computer science)
In object-oriented programming , inheritance is a way to reuse code of existing objects, establish a subtype from an existing object, or both, depending upon programming language support...
to model the natural subset
Subset
In mathematics, especially in set theory, a set A is a subset of a set B if A is "contained" inside B. A and B may coincide. The relationship of one set being a subset of another is called inclusion or sometimes containment...
s of the available number types: E.g. the integer class is a subtype of the rational class, just as the integer numbers are a subset of the rational numbers. The complex numbers and all its subtypes behave exactly like the types of numbers known to the Common Lisp
Common Lisp
Common Lisp, commonly abbreviated CL, is a dialect of the Lisp programming language, published in ANSI standard document ANSI INCITS 226-1994 , . From the ANSI Common Lisp standard the Common Lisp HyperSpec has been derived for use with web browsers...
language, giving CLN another meaning: it becomes an abbreviation of Common Lisp Numbers. Due to this, CLN can be and is used for implementations of Common Lisp, other interpreted languages, or computer algebra system
Computer algebra system
A computer algebra system is a software program that facilitates symbolic mathematics. The core functionality of a CAS is manipulation of mathematical expressions in symbolic form.-Symbolic manipulations:...
s.
The implementation is efficient. It can be configured to use the GNU Multi-Precision Library
GNU Multi-Precision Library
The GNU Multiple Precision Arithmetic Library, also known as GMP, is a free library for arbitrary-precision arithmetic, operating on signed integers, rational numbers, and floating point numbers...
as kernel for speed-critical inner loop
Inner loop
In computer programs, an important form of control flow is the loop. For example, this small pseudo-code program uses two nested loops to iterate over all the entries of an n×n matrix, changing their values so that the matrix becomes an identity matrix: for a in 1..n for b in 1..n ...
s and implements advanced algorithms like Schönhage–Strassen multiplication, binary splitting
Binary splitting
In mathematics, binary splitting is a technique for speeding up numerical evaluation of many types of series with rational terms. In particular, it can be used to evaluate hypergeometric series at rational points...
and others. All CLN objects are either immediate or reference counted
Reference counting
In computer science, reference counting is a technique of storing the number of references, pointers, or handles to a resource such as an object, block of memory, disk space or other resource...
, providing for non-interruptive garbage collection
Garbage collection (computer science)
In computer science, garbage collection is a form of automatic memory management. The garbage collector, or just collector, attempts to reclaim garbage, or memory occupied by objects that are no longer in use by the program...
with no burden on the main application.