These are the constructors offered by the different formats.
The default constructor has no use other than to create an empty matrix. Since it is not possible to insert values into an IVSparse Matrix after construction this is only useful for creating a matrix to be overwritten later. It's also worth mentioning that IVCSC also has a construtor that allows for the specification of rows and columns for an empty matrix. This is essentially the same as the default constructor but allows for the specification of rows and columns.
This is how to load data into IVSparse from outside sources using COO, CSC, or Eigen.
First is loading data in using COO which is a very common format for sparse data such as Matrix Market. IVSparse takes in a vector of tuples where each tuple is (row, column, value). The vector doesn't need to be sorted but does need to contian no duplicates.
It's also easy for IVSparse to use raw CSC data to construct matrices and is often used as well for sparse applications. IVSparse takes in pointers to the three arrays for CSC/CSR and the metadata needed about the matrix. The arrays do need to follow CSC format conventions and given the correct storage order. For example if using CSC data make a column major matrix, if using CSR data make a row major matrix. An example for using raw CSC pointers is shown below:
The easiest way to make an IVSparse Matrix is to construct one from an already existing Eigen sparse matrix. Eigen sparse matrices are just CSC matrices so the process is the same as the CSC example above but with far less parameters for the programmer to manage. IVSparse can also take either column or row major Eigen sparse matrices. An example of this is shown below:
There are many ways to move data around in IVSparse once in one of the three formats supported. The main ways are by using the copy constructor, the conversion constructor, the assignment operator, the file constructor, or the vector constructors.
Constructing from a file is one of the easiest ways to move data around. Simply save a matrix on disk using the .write()
method and simply load it in with the same template parameters as the matrix saved. An example of this is shown below:
It's simple to copy or move between compression levels in IVSparse. To deep copy a matrix just use one matrix as the parameter to the constructor of another matrix of the same template parameters. To convert between compression levels do the same thing except the compression level parameter can be different and the constructor will do the conversion itself. An example of this is shown below:
The last primary way to move data in IVSparse is through the use of vectors. There are two vector constructors to make an IVSparse Matrix, the single vector constructor and the array of vectors constructor. The single vector constructor simply turns a vector into a matrix with a single row or column. The array of vectors constructor takes in an array of vectors and turns it into a matrix. An example of this is shown below: