Skip to content
/ lincpp Public

simple linear algebra c++ header only library

License

Notifications You must be signed in to change notification settings

jpvolt/lincpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lincpp

simple linear algebra c++ header only library - educational purpose

Features

  • Matrix multiplication
  • Matrix transpose
  • Matrix Inversion

Usage

#include "mat.hpp"

using namespace lin;

int main(int argc, char* argv[]){
  
  //definition Mat<type> name(rows, cols);
  Mat<double> n(2,2);
  
  // fill matrix with value
  n = 0;
  // | 0.0 0.0 |
  // | 0.0 0.0 |
  
  n = {0.0, 1.0, 2.0, 3.0};
  // | 0.0 1.0 |
  // | 2.0 3.0 |
  
  n = n.T(); // matrix transpose
  // | 0.0 2.0 |
  // | 1.0 3.0 |
  
  n = n.I() // matrix identity
  // | 1.0 0.0 |
  // | 0.0 1.0 |
  
  // multiplication by scalar
  n = n*2.5;
  // | 2.5 0.0 |
  // | 0.0 2.5 |
  
  // division by scalar
  n = n/5;
  // | 0.5 0.0 |
  // | 0.0 0.5 |
  
  // matrix multiplication
  n = n*n.I();
  // | 0.5 0.0 |
  // | 0.0 0.5 |
  
  // Matrix sum and subtraction
  n = n - n*0.1;
  // | 0.4 0.0 |
  // | 0.0 0.4 |
  
  bool success;
  n = n.inverse(success); // matrix inverse
  
  // element access n(row, col)
  n(1,0) = 20;
  // | 0.4 0.0 |
  // | 20.0 0.4 |
  
  
}

About

simple linear algebra c++ header only library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages