CLN, a Class Library for Numbers - 1 Introduction

Go to the first, previous, next, last section, table of contents.

# 1 Introduction

CLN is a library for computations with all kinds of numbers. It has a rich set of number classes:

- Integers (with unlimited precision),
- Rational numbers,
- Floating-point numbers:
  - Short float,
  - Single float,
  - Double float,
  - Long float (with unlimited precision),
- Complex numbers,
- Modular integers (integers modulo a fixed integer),
- Univariate polynomials.

The subtypes of the complex numbers among these are exactly the types of numbers known to the Common Lisp language. Therefore `CLN` can be used for Common Lisp implementations, giving ``CLN'` another meaning: it becomes an abbreviation of "Common Lisp Numbers".

The CLN package implements

- Elementary functions (`+`, `-`, `*`, `/`, `sqrt`, comparisons, ...),
- Logical functions (logical `and`, `or`, `not`, ...),
- Transcendental functions (exponential, logarithmic, trigonometric, hyperbolic functions and their inverse functions).

CLN is a C++ library. Using C++ as an implementation language provides

- efficiency: it compiles to machine code,
- type safety: the C++ compiler knows about the number types and complains if, for example, you try to assign a float to an integer variable.
- algebraic syntax: You can use the `+`, `-`, `*`, `=`, `==`, ... operators as in C or C++.

CLN is memory efficient:

- Small integers and short floats are immediate, not heap allocated.
- Heap-allocated memory is reclaimed through an automatic, non-interruptive garbage collection.

CLN is speed efficient:

- The kernel of CLN has been written in assembly language for some CPUs (`i386`, `m68k`, `sparc`, `mips`, `arm`).
- On all CPUs, CLN uses the superefficient low-level routines from GNU GMP version 2.
- It uses Karatsuba multiplication, which is significantly faster for large numbers than the standard multiplication algorithm.
- For very large numbers (more than 12000 decimal digits), it uses Schönhage-Strassen multiplication, which is an asymptotically optimal multiplication algorithm, for multiplication, division and radix conversion.

CLN aims at being easily integrated into larger software packages:

- The garbage collection imposes no burden on the main application.
- The library provides hooks for memory allocation and exceptions.

Go to the first, previous, next, last section, table of contents.