Skip to content

Latest commit

 

History

History
111 lines (83 loc) · 2.94 KB

README.md

File metadata and controls

111 lines (83 loc) · 2.94 KB

A Custom linear algebra library


Motivation

The reason for building this project was to implement the common linear algebra algorithms that were introduced during the introductory linear algebra course during my freshman year


Demo


$$2x+5y+z=20$$

$$4x+5y+z=10$$

$$6x+5y=0$$

$$A = \begin{pmatrix} 2 & 5 & 1 \\ 4 & 5 & 1 \\ 6 & 5 & 0 \\ \end{pmatrix} $$

$$B = \begin{pmatrix} 20 \\ 10 \\ 0\\ \end{pmatrix}$$

$$Solution => x=-5,y=6,z=0$$



./images/gif.gif

What can it do?


API:

  • Create a new matrix:
    • mat* mat_new(unsigned int num_rows,unsigned int num_cols)
    • Assigning values: mat->data[row][col] = desired_value
  • Free a created matrix:
    • void mat_free(mat* matrix)
  • Create a matrix with random numbers
    • mat *mat_rnd(unsigned int num_rows, unsigned int num_cols, int min, int max)
  • Generate a square matrix
    • mat *mat_sqr(unsigned int rowCol)
    • Assigning values: mat->data[row][col] = desired_value
  • Generate a square random matrix
    • mat *mat_sqr_rnd(unsigned int rowCol, int min, int max
  • Matrix addition
    • mat* mat_add(mat* a,mat* b)
  • Matrix subtraction
    • mat* mat_subtract(mat* a,mat* b)
  • Matrix multiplication
    • mat* mat_mul_naive(mat* a,mat* b)
  • Finding Row Echelon Form of a Matrix
    • mat* mat_ref(mat* a)
  • Finding Reduced Row Echelon Form of a Matrix
    • mat* mat_rref(mat* a)
  • LU decomposition
    • mat_lup* mat_LU(mat* a)
  • Solving linear equations
    • mat* solve_linear_LU(mat* a,mat* b)
  • Finding the inverse
    • Using LU method
      • mat* mat_inverse(mat* a)
  • Finding the determinant
    • double mat_determinant(mat* a)

Background and References


Can this be used in production?


Definitely not. This project was build for educational purposes only and this is definitely not a library that one should use for their projects.

Future of this project


  • This project is far from complete.
  • Some new features to be implemented:
    • A CLI interface for users
    • Replacing current makefile with CMake
    • Computing eigenvalues and eignevectors
    • Adding faster algorithms and better data structures
      • Addition of strassen's algorithm for matrix multiplicaton
      • Dense and sparse matrices
      • More...