All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----jnt.linear_algebra.CoordinateSparseMatrixDouble
The nonzero value, together with its offset are stored. Thus, the 5-element matrix
0 1 0 4 2 0 0 0 7could be represented by the following contstructor:
double val[] = new double[3]; int row[] = new int[3]; int col[] = new int[3];or, equivalently
val[0] = 1.0; col[0] = 0; row[0] = 1; val[1] = 4.0; col[1] = 1; row[1] = 0; val[2] = 2.0; col[2] = 1; row[2] = 1; val[3] = 7.0; col[3] = 2; row[3] = 2;
CoordinateSparseMatrixDouble S = new CoordinateSparseMatrixDouble(3, 3, 4, val, row, col);
CoordinateSparseMatrixDouble S = new CoordinateSparseMatrixDouble(3, 3, 4);
for (int i=0; i<3; i++) S.set_ith_element(i, row[i], col[i], val[i]);
General set/get functions which treat the matrix as dense, are available but are not very efficient (i.e. they have an O(nz) cost).
S.set(i,j, val); // equivalent to A[i][j] = val; v = S.get(i,j); // equivalent to v = A[i][j];
The elements are unoreded, and offsets begin at 0. Note, also, that coordinate matrix representations are not unique -- the elements are unordered, and explicit zeros could be stored.
val[] and integer positions
in ind[].
public CoordinateSparseMatrixDouble(int M,
int N)
public CoordinateSparseMatrixDouble(int M,
int N,
int nz)
public CoordinateSparseMatrixDouble(int M,
int N,
int nz,
int row[],
int col[],
double val[])
val[] and integer positions
in ind[].
public CoordinateSparseMatrixDouble copy()
public final double[] val()
NOTE: this access method is here for efficiency. It should be used by 'trusted' apps only, because it essentially bypasses the 'private' status of these variables.
public final double val(int i)
public final int[] row()
NOTE: this access method is here for efficiency. It should be used by 'trusted' apps only, because it essentially bypasses the 'private' status of these variables.
public final int row(int i)
public final int col(int i)
public final int[] col()
NOTE: this access method is here for efficiency. It should be used by 'trusted' apps only, because it essentially bypasses the 'private' status of these variables.
public final double[] mult(double x[])
public final void mult(double y[],
double x[])
public void print()
public static void write(CoordinateSparseMatrixDouble S)
public void write()
public static CoordinateSparseMatrixDouble readfile(String s) throws IOException
5 7 3 1 1 2.0 3 4 9.9 6 3 7.5denotes the 5x7 sparse matrix with 3 nonzeros:
The base offsets are assumed to be zero (ie. A[0][0] is the first element), but can be overridden by an optional base-offset. (see readfile(String, int).)
public static CoordinateSparseMatrixDouble readfile(String s,
int base_offset) throws IOException
This option is here mainly for compatibility with Matrix-Market files and other data formats that use 1-based offsets.
public int M()
public int N()
public int num_nonzeros()
All Packages Class Hierarchy This Package Previous Next Index