8.8.2. MDOMatrix¶
- MDOMatrix¶
- Represents a matrix class with a double value. Typically used to interact with matrix attributes. - Properties - The number of columns contained in this matrix - The number of non-zero elements in a matrix - The number of rows contained in this matrix - Cols¶
- The number of columns contained in this matrix 
 - Nzs¶
- The number of non-zero elements in a matrix 
 - Rows¶
- The number of rows contained in this matrix 
 - Static Methods - Construct a sparse matrix with indexes and values - Construct a sparse matrix containing row indexes, column indexes, and values - Construct a matrix in the format of compressed sparse columns (CSC) - Construct a compressed sparse row (CSR) formatting matrix - Construct a dense matrix - Construct a matrix whose internal elements are all value - Construct a square matrix where the main diagonal elements are all 1 - Construct a matrix containing only zeros - Methods - Retrieve the ith value in this matrix - Retrieve the index of the ith non-zero element in this matrix - Convert the current matrix into string format - MDOMatrix Coo(int rows, int cols, int[] indices, double[] data)¶
- Construct a sparse matrix with indexes and values - Parameters
- int rows – The number of rows 
- int cols – The number of columns 
- int[] indices – Indexes of all non-zero elements 
- double[] data – Values of all non-zero elements 
 
- Returns
- Newly created matrix 
 
 - MDOMatrix Coo(int rows, int cols, int[] rowIndices, int[] colIndices, double[] data)¶
- Construct a sparse matrix containing row indexes, column indexes, and values - Parameters
- int rows – The Number of rows 
- int cols – The Number of columns 
- int[] rowIndices – Row indexes of all non-zero elements 
- int[] colIndices – Column indexes of all non-zero elements 
- double[] data – Values of all non-zero elements 
 
- Returns
- Newly created matrix 
 
 - MDOMatrix Csc(int rows, int cols, int[] ptr, int[] ind, double[] data)¶
- Construct a matrix in the format of compressed sparse columns (CSC) - Parameters
- int rows – The number of rows 
- int cols – The number of columns 
- int[] ptr – The begin indices in ind of columns contained in matrix. 
- int[] ind – Row indices of all non-zero elements 
- double[] data – Values of all non-zero elements 
 
- Returns
- Newly created matrix 
 
 - MDOMatrix Csr(int rows, int cols, int[] ptr, int[] ind, double[] data)¶
- Construct a compressed sparse row (CSR) formatting matrix - Parameters
- int rows – The number of rows 
- int cols – The number of columns 
- int[] ptr – The begin indices in ind of rows contained in matrix 
- int[] ind – Column indices of all non-zero elements 
- double[] data – Values of all non-zero elements 
 
- Returns
- Newly created matrix 
 
 - MDOMatrix Dense(int rows, int cols, double[] data)¶
- Construct a dense matrix - Parameters
- int rows – The number of rows 
- int cols – The number of columns 
- double[] data – Values for all elements. It should have at least rows * cols elements. 
 
- Returns
- The newly created matrix 
 
 - MDOMatrix Full(int rows, int cols, double value)¶
- Construct a matrix whose internal elements are all value . - Parameters
- int rows – The number of rows 
- int cols – The number of columns 
- double value – The value of all matrix elements. 
 
- Returns
- The newly created matrix. 
 
 - MDOMatrix Identity(int n)¶
- Construct a square matrix where the main diagonal elements are all 1 - Parameters
- int n – The dimension of the new matrix, that is, the number of rows and columns of the square matrix. 
- Returns
- The newly created matrix 
 
 - MDOMatrix Zero(int rows, int cols)¶
- Construct a matrix containing only zeros. - Parameters
- int rows – Number of rows 
- int cols – Number of columns 
 
- Returns
- The newly created matrix 
 
 - double Data(int i)¶
- Retrieve the ith value in this matrix - Parameters
- int i – Index i to query 
- Returns
- The ith value in this matrix 
 
 - int Index(int i)¶
- Retrieve the index of the ith non-zero element in this matrix - Parameters
- int i – The number of orders of this non-zero element in the matrix 
- Returns
- The index position of the ith non-zero element in this matrix 
 
 - string ToString()¶
- Convert the current matrix into string format. - Returns
- The string format of the matrix.