https://github.com/madrury/linalg
A linear algebra library in C. For fun.
https://github.com/madrury/linalg
linear-algebra matrix-factorization
Last synced: 10 months ago
JSON representation
A linear algebra library in C. For fun.
- Host: GitHub
- URL: https://github.com/madrury/linalg
- Owner: madrury
- Created: 2015-09-20T22:28:56.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-04-13T23:09:34.000Z (almost 9 years ago)
- Last Synced: 2025-04-02T22:51:16.577Z (11 months ago)
- Topics: linear-algebra, matrix-factorization
- Language: C
- Size: 84 KB
- Stars: 58
- Watchers: 1
- Forks: 12
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
linalg: Linear Algebra and Regression in C
===========================================
`linalg` is a library for linear algebra and regression implemented in C. The code is optimized for readability and clarity instead of raw efficiency (though it tries not to ignore issues of efficiency completely).
Linear Algebra
--------------
`linalg` contains two datatypes in its core linear algebra engine, `vector` and `matrix`:
- `vector` is a (one dimensional) vector of real numbers (C `double`s). The underlying data is stored as a C array, and so occupies contiguous memory locations in the computer's memory.
- `matrix` is a (two dimensional) matrix of real numbers (C `double`s). The underlying data is stored in row-major order, so each row occupies contiguous memory locations in the computer's memory.
To complement these data types, `linalg` contains many functions for performing linear algebraic operations. For example
- `matrix_vector_multiply` computes the product vector of a matrix and vector.
- `matrix_multiply` computes the product matrix of two matrices.
- `matrix_multiply_MtN` computes the product of the transpose of one matrix with another.
Linear equations can be solved using `linsolve_qr`, which adopts a strategy of computing the QR matrix factorization of the left hand side. To access the underlying matrix factorization, use `qr_decomp`.
Regression
----------
`linalg` also includes functions for regression. Use `linreg_fit` to fit a linear regression given a design matrix `X` and a response vector `y`.
Tests
-----
The routines in `linalg` are extensively unit tested, which also serve as simple examples of use.