This describes the installation process using cmake. As pre-requisites, you'll need git and cmake installed.
On a unix system, the build directory should now look something like this:
Add these tools to PATH.
Note: Run the following commands in msysgit terminal.
To compile benchmarking binaries:
Linux:
g++ <file_name>.cpp -std=c++11 -I../include/ -isystem ../lib/benchmark/include -L../lib/benchmark/build/src -lbenchmark -lpthread -o ./linux_binaries/<file_name>
This guide contains detailed explaination of all the methods and functions available and how to use them.
More detailed information about how to use these methods and functions is available in /examples
.
Many initializer functions are provided that return Matrix
object.
Function | Parameters | Return value | Description |
---|---|---|---|
matrix.init() |
1 Parameter: | Matrix object | Creates a Matrix object of same dimensions and values as the 2D vector provided. |
matrix.eye() |
1 Parameter: | Matrix object | Creates an identity Matrix object of the size given as parameters. |
matrix.zeros() |
2 Parameters: | Matrix object | Creates a Matrix object of all elements 0 of the size given as parameters. |
matrix.ones() |
2 Parameters: | Matrix object | Creates a Matrix object of all elements 1 of the size given as parameters. |
read_csv() |
1 Parameter: | Matrix object | Creates a Matrix object with data elements of type std::string . |
Matrix
objects can be sliced like Numpy
arrays.
Note: First convert the Matrix
elements' data type to double using Matrix.to_double()
.
Function | Parameters | Return value | Description |
---|---|---|---|
Matrix.slice() |
4 Parameter: | Matrix object | Slices the Matrix object according to the indices provided. |
matrix.slice_select() |
4 Parameter: | Matrix object | Slices the Matrix object to get all rows which have value(3rd parameter) in second Matrix object and one column(4th parameter) |
A number of methods are provided to print/view a Matrix
object in different ways.
Function | Parameters | Return value | Description |
---|---|---|---|
matrix.print() |
0 Parameters | void | Prints the whole Matrix object onto the console. |
matrix.head() |
0 Parameters | void | Prints first 5 rows of the Matrix object onto the console. |
matrix.tail() |
0 Parameters | void | Prints first 5 rows of the Matrix object onto the console. |
matrix.view() |
2 Parameters: | void | Prints the value on the provided index. |
matrix.view() |
4 Parameters: | void | Prints the Matrix object according to the indices provided. |
Function | Parameters | Return value | Description |
---|---|---|---|
matrix.min() |
2 Parameters: | Matrix object | Method to get the minimum value along an axis |
matrix.max() |
2 Parameters: | Matrix object | Method to get the maximum value along an axis |
matrix.argmin() |
2 Parameters: | Matrix object | Method to get the index of minimum value along an axis |
matrix.argmax() |
2 Parameters: | Matrix object | Method to get the index of maximum value along an axis |
Broadcasting is in-built in the Basic Mathematical operations i.e., addition, subtraction, multiplication and division.
Following binary operations are possible:
where, @ is any operator from (+, -, *, /)
Note: Vector is a Matrix
object where row length or column length is equal to 1.
Following unary operations are possible:
where, @ is any operator from (-)
Indexing can be used to get or assign value to a particular element.
For example, let there is a Matrix
object named mat. If we want to get the value at index (5,3) we can do this as follows:
double val = mat(5,3);
Similarly, if we want to assign the value to index (5,3) we can do this by:
mat(5,3) = 10.54;
Function | Parameters | Return value | Description |
---|---|---|---|
matrix.sqrt() |
1 Parameter: | Matrix object | Method to get the sqrt of each element of aMatrix object |
matrix.power() |
2 Parameters: | Matrix object | Method to calculate power of each element of a Matrix object |
matrix.power() |
2 Parameters: | Matrix object | Method to calculate power of each element of a Matrix object |
matrix.exp() |
1 Parameter: | Matrix object | Method to calculate exponential of all elements in the Matrix object |
matrix.log() |
1 Parameter: | Matrix object | Method to calculate natural logarithm of all elements in the in the Matrix object |
matrix.abs() |
1 Parameter: | Matrix object | Method to get absolute value of all elements in the in the Matrix object |
Note: Broadcasting in power() methods works in the same way as in Basic Mathematical operations.
Function | Parameters | Return value | Description |
---|---|---|---|
matrix.sum() |
2 Parameters: | Matrix object | Method to calculate the sum over an axis of aMatrix object |
matrix.mean() |
2 Parameters: | Matrix object | Method to calculate the mean over an axis of a Matrix object |
matrix.std() |
2 Parameters: | Matrix object | Method to calculate the standard deviation over an axis of a Matrix object |
Function | Parameters | Return value | Description |
---|---|---|---|
Matrix.T() |
0 Parameters | Matrix object | Method to return the Tranpose of aMatrix object |
matrix.matmul() |
2 Parameters: | Matrix object | Method to calculate matrix multiplication |
matrix.determinant() |
2 Parameters: | double | Method to calculate the Determinant of a Matrix object |
matrix.inverse() |
1 Parameter: | Matrix object | Method to calculate the Inverse of a Matrix object |
Function | Parameters | Return value | Description |
---|---|---|---|
matrix.concatenate() |
3 Parameters: | Matrix object | Method to concatenate/join two Matrix objects |
Matrix.get() |
0 Parameters | std::vector<std::vector<double>> | Method to get the Matrix object as a 2D vector |
Matrix.get_row() |
1 Parameter: | std::vector<double> | Method to get a row of a Matrix object in the form of a vector |
Matrix.get_col() |
1 Parameter: | std::vector<double> | Method to get a column of a Matrix object in the form of a vector |
matrix.delete_() |
3 Parameters: | Matrix object | Method to delete a row or column of a Matrix object |
matrix.reciprocal() |
1 Parameter: | Matrix object | Method to calculate reciprocal of all elements in the Matrix object |
Matrix.row_length() |
0 Parameters | int | Method to get the number of rows in a Matrix object |
Matrix.col_length() |
0 Parameters | int | Method to get the number of columns in a Matrix object |
Matrix.to_double() |
0 Parameters | void | Method convert the elements of a Matrix object from std::string to double |
Matrix.to_string() |
0 Parameters | void | Method convert the elements of a Matrix object from double to std::string |