Common C/C++ Libraries
Data types
LinAsm libraries define their own data types. They are separated into two categories: scalar and vector data types. Scalar types are just aliases to internal C and C++ types and have the same length and operations set. Vector types are custom types, which use gcc aggregates to hold vectors. LinAsm also define union types which can hold both types simultaneously. They are useful when you apply vector operations to the data, but also need to extract some elements of target vectors.
Angle library
Angle library converts angle values between different popular units: degrees, radians and gradians. All functions in this library are implemented as inline functions, and can do angle conversion very fast. They are useful to change angle representation format in programs.
Approximation library
The need for function approximations arises in many branches of applied mathematics, and computer science in particular. In general, a function approximation problem asks us to select a function among a well-defined class that closely matches a target function in a task-specific way. In mathematics, the idea of least squares can be applied to approximating a given function by a weighted sum of other functions. The best approximation can be defined as that which minimises the difference between the original function and the approximation; for a least-squares approach the quality of the approximation is measured in terms of the squared differences between the two.
- Approximation by power function
- Approximation by elementary functions
- Linear approximation
- Square law approximation
- Cube law approximation
- Hyperbolic approximation
- Inverse square law approximation
- Inverse cube law approximation
- Square root approximation
- Exponential approximation
- Logarithmic approximation
- Hyperbolic sine approximation
- Hyperbolic cosine approximation
- Inverse hyperbolic sine approximation
- Inverse hyperbolic cosine approximation
- Approximation by polynomial functions
- Polynomial approximation
- Square root approximation
- Exponential approximation
- Logarithmic approximation
- Hyperbolic sine approximation
- Hyperbolic cosine approximation
- Inverse hyperbolic sine approximation
- Inverse hyperbolic cosine approximation
- Approximation by rational functions
- Rational function approximation
- Subrational function approximation
Array library
Array manipulations are core functions of many popular algorithms: linear and binary searching, sorting keys and mathematical operations to vectors. If these operations can be optimized in many times, then all programs that use them can process data much faster. And responsibility of whole system will grow up.
Array library provides very fast and optimized routines to work with integer and floating-point arrays. It uses SIMD extension of modern x86-64 processors to accelerate data manipulations. Cache prefetch and hint instructions speed up memory operations and improve total speed of algorithms, especially for very big arrays.
- Key compare function prototype
- Initialization
- Copying arrays
- Moving arrays
- Pattern cloning
- Data conversion
- Conversion between floating-point types
- Conversion from signed integer types to floating-point types
- Conversion from floating-point types to signed integer types
- Truncating from floating-point types to signed integer types
- Bit field operations
- Get bit value from bit field
- Set bit value in bit field
- Reset bit value in bit field
- Invert bit value in bit field
- Bitwise operations
- Byte swap
- Bit reversal permutation
- Population count
- Bitwise NOT
- Bitwise AND
- Scalar bitwise AND
- Vector bitwise AND
- Bitwise OR
- Scalar bitwise OR
- Vector bitwise OR
- Bitwise XOR
- Scalar bitwise XOR
- Vector bitwise XOR
- Arithmetic operations
- Unary operations
- Negative value
- Absolute value
- Negative absolute value
- Number sign
- Square
- Square root
- Binary operations
- Addition
- Scalar addition
- Vector addition
- Subtraction
- Scalar subtraction
- Vector subtraction
- Reverse subtraction
- Scalar reverse subtraction
- Vector reverse subtraction
- Multiplication
- Scalar multiplication
- Vector multiplication
- Division
- Scalar division
- Vector division
- Reverse division
- Scalar reverse division
- Vector reverse division
- Rounding
- Round down (floor)
- Round up (ceil)
- Round to nearest even integer
- Round to nearest integer, away from zero
- Round to nearest integer, toward zero (truncation)
- Fractional part
- Numerical integration
- Sum of elements
- Sum of squares
- Sum of absolute values
- Sum of multiplied values
- Sum of squared differences
- Sum of absolute differences
- Minimum and maximum absolute value
- Minimum absolute value
- Maximum absolute value
- Minimum and maximum value
- Regular array search
- Minimum value
- Maximum value
- Object array search
- Minimum value
- Maximum value
- Linear search
- Bit field search
- Forward direction search
- Searching for set bit
- Searching for reset bit
- Backward direction search
- Searching for set bit
- Searching for reset bit
- Regular array search
- Forward direction search
- Backward direction search
- Object array search
- Forward direction search
- Backward direction search
- Binary search
- Regular array search
- Ascending sort order
- Searching for first equal element
- Searching for last equal element
- Searching for greater element
- Searching for greater or equal element
- Searching for less element
- Searching for less or equal element
- Descending sort order
- Searching for first equal element
- Searching for last equal element
- Searching for less element
- Searching for less or equal element
- Searching for greater element
- Searching for greater or equal element
- Object array search
- Ascending sort order
- Searching for first equal element
- Searching for last equal element
- Searching for greater element
- Searching for greater or equal element
- Searching for less element
- Searching for less or equal element
- Descending sort order
- Searching for first equal element
- Searching for last equal element
- Searching for less element
- Searching for less or equal element
- Searching for greater element
- Searching for greater or equal element
- Linear counting
- Bit counting
- Element counting
- Object counting
- Binary counting
- Element counting
- Ascending sort order
- Descending sort order
- Object counting
- Ascending sort order
- Descending sort order
- Replacing
- Element replacing
- Object replacing
- Order reversing
- Regular array reversing
- Object array reversing
- Unique values
- Unique elements
- Unique objects
- Duplicate values
- Duplicate elements
- Duplicate objects
- Insertion sort
- Regular array sorting
- Ascending sort order
- Descending sort order
- Key array sorting
- Ascending sort order
- Descending sort order
- Object array sorting
- Ascending sort order
- Descending sort order
- Quick sort
- Regular array sorting
- Ascending sort order
- Descending sort order
- Key array sorting
- Ascending sort order
- Descending sort order
- Object array sorting
- Ascending sort order
- Descending sort order
- Merge sort
- Regular array sorting
- Ascending sort order
- Descending sort order
- Key array sorting
- Ascending sort order
- Descending sort order
- Object array sorting
- Ascending sort order
- Descending sort order
- Radix sort
- Regular array sorting
- Ascending sort order
- Descending sort order
- Key array sorting
- Ascending sort order
- Descending sort order
- Merging of sorted arrays
- Regular array merging
- Ascending sort order
- Descending sort order
- Key array merging
- Ascending sort order
- Descending sort order
- Object array merging
- Ascending sort order
- Descending sort order
- Comparison of arrays
- Regular array comparison
- Object array comparison
- Checks
- Check for differences
- Regular array check
- Object array check
- Check for duplicate values
- Regular array check
- Object array check
- Check for sort order
- Regular array check
- Check for ascending sort order
- Check for descending sort order
- Object array check
- Check for ascending sort order
- Check for descending sort order
- Check for infinite values
- Check for NaN values
- Check for overlap
- Array hashing
- 32-bit hash functions
- 64-bit hash functions
Complex library
Complex numbers extend the concept of the one-dimensional number line to the two-dimensional complex plane (also called Argand plane) by using the horizontal axis for the real part and the vertical axis for the imaginary part. The complex number re + im * i can be identified with the point (re, im) in the complex plane. A complex number whose real part is zero is said to be purely imaginary, whereas a complex number whose imaginary part is zero is a real number. In this way, the complex numbers contain the ordinary real numbers while extending them in order to solve problems that cannot be solved with real numbers alone.
- Complex number structure
- Arithmetic operations
- Unary operations
- Negative value
- Complex conjugate value
- Square root
- Square value
- Inverse value
- Binary operations
- Addition
- Subtraction
- Multiplication
- Division
- Complex number properties
- Magnitude value
- Argument value
- Checks
- Check for zero number
- Check for equality of the numbers
- Check for negativity of the numbers
FPU library
FPU library was designed to allow C/C++ programs to communicate with FPU directly via simple interface, to get its status, and change unit work mode. This is common routine for any mathematics and computation algorithms. But "C" and "C++" language just provide very abstract paradigm how programs should operate with hardware units. It is because of portability of both languages. But if we need high speed calculation, we also need to operate with hardware units as close as it is possible. That is why such programs require some kind of interface functions to manipulate with hardware units state and change working mode.
- FPU constants
- FPU rounding modes
- FPU precision modes
- FPU exception masks
- FPU exception flags
- FPU data types
- FPU control functions
- Init FPU
- Set FPU mode
- Get FPU mode
- FPU rounding mode
- Set round mode
- Get round mode
- FPU precision mode
- Set precision mode
- Get precision mode
- FPU exception masks
- Clear exception masks
- Set exception masks
- Get exception masks
- FPU status functions
- Clear FPU exceptions
- Get FPU status
- FPU exception flags
- FPU exceptions summary status flag
- FPU stack fault flag
- FPU stack top index
Math library
Math library declares a set of functions to compute common mathematical operations and transformations. They may replace and extend standard math functions from C library, and provide extra operations for specific mathematical algorithms. It is optimized for x86-64 Linux systems and much faster that standard GNU lib C functions.
- Mathematical constants
- Bitwise operations
- Byte swap
- Bit reversal permutation
- Bit scan
- Bit scan forward
- Bit scan backward
- Circular rotation
- Circular rotation to the left
- Circular rotation to the right
- Population count
- Arithmetic operations
- Absolute value
- Negative absolute value
- Number sign
- Square root
- Square value
- Cube value
- Inverse value
- Inverse square value
- Inverse cube value
- Three-state comparison
- Minimum and maximum absolute value
- Minimum absolute value
- Maximum absolute value
- Minimum and maximum value
- Minimum value
- Maximum value
- Greatest common divisor
- Least common multiple
- Cancellation
- Observational error
- Absolute error
- Relative error
- Scale functions
- Scale by power of 2
- Scale by power of 10
- Exponentiation functions
- Exponentiation by base 2
- Integer exponentiation by base 2
- Real exponentiation by base 2
- Exponentiation by base 10
- Integer exponentiation by base 10
- Real exponentiation by base 10
- Exponentiation by base E (natural logarithm)
- Exponentiation by custom base
- Integer exponentiation by custom base
- Real exponentiation by custom base
- Logarithmic functions
- Logarithm to base 2
- Integer logarithm to base 2
- Real logarithm to base 2
- Logarithm to base 10
- Integer logarithm to base 10
- Real logarithm to base 10
- Logarithm to base E (natural logarithm)
- Trigonometric functions
- Hypotenuse
- 2 dimensional hypotenuse
- 3 dimensional hypotenuse
- Cathetus
- Trigonometric sine
- Trigonometric cosine
- Trigonometric sine and cosine
- Trigonometric tangent
- Inverse trigonometric functions
- Inverse trigonometric sine
- Inverse trigonometric cosine
- Inverse trigonometric tangent
- Hyperbolic functions
- Hyperbolic sine
- Hyperbolic cosine
- Hyperbolic tangent
- Inverse hyperbolic functions
- Inverse hyperbolic sine
- Inverse hyperbolic cosine
- Inverse hyperbolic tangent
- Rounding
- Round down (floor)
- Round up (ceil)
- Round to nearest even integer
- Round to nearest integer, away from zero
- Round to nearest integer, toward zero (truncation)
- Fractional part
- Checks
- Check for normal value
- Check for subnormal value
- Check for finite value
- Check for infinite value
- Check for NaN value
Matrix library
In mathematics, a matrix is a rectangular array of numbers, symbols, or expressions, arranged in rows and columns, that is treated in certain prescribed ways. The individual items in a matrix are called its elements or entries. A major application of matrices is to represent linear transformations. For example, the rotation of vectors in three dimensional space is a linear transformation which can be represented by a rotation matrix. Another application of matrices is in the solution of systems of linear equations. If the matrix is square, it is possible to deduce some of its properties by computing its determinant. For example, a square matrix has an inverse if and only if its determinant is not zero. Insight into the geometry of a linear transformation is obtainable (along with other information) from the matrix's eigenvalues and eigenvectors.
- Initialization
- Initialization of rectangle matrix
- Initialization of diagonal matrix
- Copying
- Arithmetic operations
- Unary operations
- Negative matrix
- Binary operations
- Addition
- Subtraction
- Multiplication by scalar value
- Division by scalar value
- Multiplication by matrix
- Transposition
- Inverse matrix
- Inverse matrix through upper triangular matrix
- Inverse matrix through lower triangular matrix
- Determinant
- Determinant of diagonal matrix
- Determinant of triangular matrix
- Determinant of square matrix
- Determinant of square matrix through upper triangular matrix
- Determinant of square matrix through lower triangular matrix
- Solving of linear system
- Gauss elimination
- Gauss elimination to upper triangular matrix
- Gauss elimination to lower triangular matrix
- Cholesky decomposition
- Cholesky decomposition to upper triangular matrix
- Cholesky decomposition to lower triangular matrix
Numbers library
The Numbers library scans C style string for number values in different numeral systems, and converts them to internal computer format, depending of expected data types. The library checks integer overflow and underflow conditions and signals to caller if such situation has occurred. The functions don't use local decimal mark to separate integer and fractional parts. They use only point symbol ('.') as the default decimal mark.
These functions were made as replacement for standard C library string conversion functions, and may be useful in programs that do intensive numbers extraction from any strings representations: binary, octal, decimal and hexadecimal. They are extremely fast, especially for floating-point numbers.
Sequence library
Sequence library is developed to provide fast algorithms for subsequence searching. It implements only Boyer-Moore-Horspool searching algorithm now, but in future it may be extended with more specific algorithms for sequence matching.
SIMD library
SIMD library was designed to allow C/C++ programs to communicate with SIMD directly via simple interface, to get its status, and change unit work mode. This is common routine for any mathematics and computation algorithms. But "C" and "C++" language just provide very abstract paradigm how programs should operate with hardware units. It is because of portability of both languages. But if we need high speed calculation, we also need to operate with hardware units as close as it is possible. That is why such programs require some kind of interface functions to manipulate with hardware units state and change working mode.
- SIMD constants
- SIMD rounding modes
- SIMD exception masks
- SIMD exception flags
- SIMD data types
- SIMD control functions
- Init SIMD
- Set SIMD mode
- Get SIMD mode
- SIMD rounding mode
- Set round mode
- Get round mode
- SIMD exception masks
- Clear exception masks
- Set exception masks
- Get exception masks
- SIMD flush to zero mode
- Clear flush to zero flag
- Set flush to zero flag
- Get flush to zero flag
- SIMD denormals are zeros
- Clear denormals are zeros flag
- Set denormals are zeros flag
- Get denormals are zeros flag
- SIMD status functions
- Clear SIMD exceptions
- Get SIMD status
- SIMD exception flags
Statistics library
Statistics library implements most popular statistics functions for data analysis. It finds measures of location, variability, shape and others. The library provides functions which find different aspects of normally distributed values, and also has functions from robust statistics like median, quartiles and inter quartile range. The last ones usually need data sorting, but this implementation uses fast quantile location algorithm, which significantly improves these methods.
String library
The String library provides safe string functions which have almost the same functionality as string functions from the standard C library, but without their shortcomings. They work around buffer overflow problem, which is common problem for string library in libc. These safe functions signal by a return code to caller, that source string is too long to store it into selected buffer, and roll back all data which have been already partially copied from source string into the target buffer.
- String compare function prototypes
- String length
- Copying
- Copying of string to string
- Copying of characters sequence to string
- Concatenating
- Concatenating of string to string
- Concatenating of characters sequence to string
- String comparison
- Comparison of strings
- Comparison of characters sequences
- Symbol search
- Searching for single symbol
- Forward direction search
- Backward direction search
- Searching for symbols set
- Forward direction search
- Backward direction search
- Substring search
- Searching string for pattern
- Forward direction search
- Backward direction search
- Searching characters sequence for pattern
- Forward direction search
- Backward direction search
- String search
- Linear search
- Forward direction search
- Backward direction search
- Binary search
- Ascending sort order
- Searching for first equal string
- Searching for last equal string
- Searching for greater string
- Searching for greater or equal string
- Searching for less string
- Searching for less or equal string
- Descending sort order
- Searching for first equal string
- Searching for last equal string
- Searching for less string
- Searching for less or equal string
- Searching for greater string
- Searching for greater or equal string
- Counting
- Symbol counting
- Single symbol counting
- Symbols set counting
- String counting
- Linear counting
- Binary counting
- Ascending sort order
- Descending sort order
- Replacing
- Symbol replacing
- String replacing
- Order reversing
- Unique values
- Duplicate values
- Insertion sort
- String array sorting
- Ascending sort order
- Descending sort order
- Key array sorting
- Ascending sort order
- Descending sort order
- Quick sort
- String array sorting
- Ascending sort order
- Descending sort order
- Key array sorting
- Ascending sort order
- Descending sort order
- Merge sort
- String array sorting
- Ascending sort order
- Descending sort order
- Key array sorting
- Ascending sort order
- Descending sort order
- Merging of sorted strings
- String array merging
- Ascending sort order
- Descending sort order
- Key array merging
- Ascending sort order
- Descending sort order
- Checks
- Check for duplicate values
- Check for sort order
- Check for ascending sort order
- Check for descending sort order
- String hashing
- 32-bit hash functions
- 64-bit hash functions
Time library
Time library is implemented as Time class, which allow programs to convert time variables from human readable format to Unix time format and vice versa. It also understands time zone records which are covered by tzfiles from package "tzdata". You may load data from that files into Time objects and use them to get local time in different time zones.
2D vector library
2D vectors library provide primitives for math calculations with two dimensional vectors. It implements basic functions of linear algebra in vector space and can be used in analytic geometry, engineering, physics, natural sciences, computer science, and the social sciences (particularly in economics). The library provides structures/classes with public components which represent projections of vector onto common axes: X and Y. You may set these components directly or change them via the library functions.
- 2D vector structure
- Arithmetic operations
- Unary operations
- Normalization (direction cosines)
- Reflection of vector
- Reflection through the origin
- Reflection through the X axis
- Reflection through the Y axis
- Binary operations
- Addition of vectors
- Subtraction of vectors
- Multiplication by scalar value
- Division by scalar value
- Rotation of vector
- Shearing of vector
- Shearing parallel to the X axis
- Shearing parallel to the Y axis
- Scaling of vector
- Scalar product
- Absolute value
- Cosine value of angle between the vectors
- Projection of the vector to another vector
- Checks
- Check for zero vector
- Check for equality of the vectors
- Check for negativity of the vectors
- Check for collinearity of the vectors
- Check for orthogonality of the vectors
3D vector library
3D vectors library provide primitives for math calculations with three dimensional vectors. It implements basic functions of linear algebra in vector space and can be used in analytic geometry, engineering, physics, natural sciences, computer science, and the social sciences (particularly in economics). The library provides structures/classes with public components which represent projections of vector onto common axes: X, Y and Z. You may set these components directly or change them via the library functions.
- 3D vector structure
- Arithmetic operations
- Unary operations
- Normalization (direction cosines)
- Reflection of vector
- Reflection through the origin
- Reflection through the X axis
- Reflection through the Y axis
- Reflection through the Z axis
- Reflection through the YZ plane
- Reflection through the XZ plane
- Reflection through the XY plane
- Binary operations
- Addition of vectors
- Subtraction of vectors
- Multiplication by scalar value
- Division by scalar value
- Rotation of vector
- Rotation around the X axis
- Rotation around the Y axis
- Rotation around the Z axis
- Shearing of vector
- Shearing parallel to the YZ plane
- Shearing parallel to the XZ plane
- Shearing parallel to the XY plane
- Scaling of vector
- Products
- Vector product
- Scalar product
- Triple product
- Absolute value
- Cosine value of angle between the vectors
- Projection of the vector to another vector
- Checks
- Check for zero vector
- Check for equality of the vectors
- Check for negativity of the vectors
- Check for collinearity of the vectors
- Check for orthogonality of the vectors
- Check for coplanarity of the vectors