README.md 1.57 KB
Newer Older
Lucas Serrano's avatar
Lucas Serrano committed
1
# FastMatrix
Lucas Serrano's avatar
Lucas Serrano committed
2 3
FastMatrix: A very efficient linear algebra library for extremely small matrices.

Lucas Serrano's avatar
Lucas Serrano committed
4 5
## Dependencies
 * libboost (>= 1.61)
Lucas Serrano's avatar
Lucas Serrano committed
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
 * bsimd

## Environment
Please make sure that your `$CPATH` (alternatively `$BOOST_SIMD_ROOT`) environment variable is correctly referencing Boost.SIMD include directory.

## Testing
You can test your configuration with `make test`. This must compile and run without error.

## Using the library
FastMatrix is a template-based header-only library. That means you don't need to compile anything before using it.

### Importing
There is only one header to import in order to use the library:
```c++
#include "../path/to/Fast-Matrix/fast_matrix.hpp"
```

### Creating a matrix
In order to create a squared matrix you need to create a object from the `BaseMatrix<Type, MatSize, MaxVecSize>` class
where `MatSize` is the matrix dimension and `MaxVecSize` the maximum vector size of type `Type` your hardware can support.

```c++
BaseMatrix<float, 5, 8> my_matrix;
```

By default your matrix will be initialized to zero.
If you want to initialize it to existing values you can pass an array to the constructor.
Values in the array are considered to be row-major.
```c++
double data[16] {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,160};
BaseMatrix<double, 4, 4> my_matrix(data);
```

### Getting the data back
You can dump the matrix data with the `dump_array()` method. The array is in row-major order.
```c++
double *data = my_matrix.dump_array();
```

### Printing values
`BaseMatrix` objects are printable with the `<<` operator:

```c++
std::cout << my_matrix << std::endl;
```