Class Library for Numbers (CLN) is a
free library
A library is a collection of Book, books, and possibly other Document, materials and Media (communication), media, that is accessible for use by its members and members of allied institutions. Libraries provide physical (hard copies) or electron ...
for
arbitrary precision arithmetic. It operates on signed
integer
An integer is the number zero (0), a positive natural number (1, 2, 3, ...), or the negation of a positive natural number (−1, −2, −3, ...). The negations or additive inverses of the positive natural numbers are referred to as negative in ...
s,
rational numbers
In mathematics, a rational number is a number that can be expressed as the quotient or fraction (mathematics), fraction of two integers, a numerator and a non-zero denominator . For example, is a rational number, as is every integer (for examp ...
,
floating point
In computing, floating-point arithmetic (FP) is arithmetic on subsets of real numbers formed by a ''significand'' (a signed sequence of a fixed number of digits in some base) multiplied by an integer power of that base.
Numbers of this form ...
numbers,
complex numbers
In mathematics, a complex number is an element of a number system that extends the real numbers with a specific element denoted , called the imaginary unit and satisfying the equation i^= -1; every complex number can be expressed in the form a ...
,
modular numbers, and univariate
polynomial
In mathematics, a polynomial is a Expression (mathematics), mathematical expression consisting of indeterminate (variable), indeterminates (also called variable (mathematics), variables) and coefficients, that involves only the operations of addit ...
s. Its implementation
programming language
A programming language is a system of notation for writing computer programs.
Programming languages are described in terms of their Syntax (programming languages), syntax (form) and semantics (computer science), semantics (meaning), usually def ...
is
C++.
Details
CLN uses
object oriented
Object-oriented programming (OOP) is a programming paradigm based on the concept of '' objects''. Objects can contain data (called fields, attributes or properties) and have actions they can perform (called procedures or methods and impleme ...
techniques and
operator overloading
In computer programming, operator overloading, sometimes termed ''operator ad hoc polymorphism'', is a specific case of polymorphism, where different operators have different implementations depending on their arguments. Operator overloading ...
to achieve a natural
algebra
Algebra is a branch of mathematics that deals with abstract systems, known as algebraic structures, and the manipulation of expressions within those systems. It is a generalization of arithmetic that introduces variables and algebraic ope ...
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
In mathematics, a Set (mathematics), set ''A'' is a subset of a set ''B'' if all Element (mathematics), elements of ''A'' are also elements of ''B''; ''B'' is then a superset of ''A''. It is possible for ''A'' and ''B'' to be equal; if they a ...
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 (CL) is a dialect of the Lisp programming language, published in American National Standards Institute (ANSI) standard document ''ANSI INCITS 226-1994 (S2018)'' (formerly ''X3.226-1994 (R1999)''). The Common Lisp HyperSpec, a hyperli ...
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
A computer algebra system (CAS) or symbolic algebra system (SAS) is any mathematical software with the ability to manipulate mathematical expressions in a way similar to the traditional manual computations of mathematicians and scientists. The de ...
s.
The implementation is efficient. It can be configured to use the
GNU Multi-Precision Library as kernel for speed-critical
inner loop
In computer programs, an important form of control flow is the Loop (computing), loop which causes a block of code to be executed more than once. A common idiom is to have a loop Nested loop, nested inside another loop, with the contained loop be ...
s and implements advanced algorithms like
Schönhage–Strassen multiplication,
binary splitting for computing certain
mathematical constants
A mathematical constant is a number whose value is fixed by an unambiguous definition, often referred to by a special symbol (e.g., an alphabet letter), or by mathematicians' names to facilitate using it across multiple mathematical problems. ...
and others. All CLN objects are either immediate or
reference counted, providing for non-interruptive
garbage collection with no burden on the main application.
See also
*
GiNaC
References
External links
CLN website
{{Computer algebra systems
Free software programmed in C++
C++ numerical libraries
Software using the GNU General Public License
Pi-related software