Package se.hb.jcp.bindings.jlibsvm
Class SparseDoubleMatrix2D
- java.lang.Object
-
- cern.colt.PersistentObject
-
- cern.colt.matrix.impl.AbstractMatrix
-
- cern.colt.matrix.impl.AbstractMatrix2D
-
- cern.colt.matrix.DoubleMatrix2D
-
- se.hb.jcp.bindings.jlibsvm.SparseDoubleMatrix2D
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable
public class SparseDoubleMatrix2D extends cern.colt.matrix.DoubleMatrix2DClass for sparse 2-d matrices holding double elements in the sparse format expected by the Java version of libsvm. See the documentation for libsvm for more details.- Author:
- anders.gidenstam(at)hb.se
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected SparseDoubleMatrix1D[]_rowViewsSparseDoubleMatrix1D views of rows in this matrix.
-
Constructor Summary
Constructors Constructor Description SparseDoubleMatrix2D(int rows, int columns)Constructs a matrix with a given number of rows and columns.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doublegetQuick(int row, int column)Returns the matrix cell value at coordinate [row,column].cern.colt.matrix.DoubleMatrix2Dlike(int rows, int columns)Construct and returns a new empty matrix of the same dynamic type as the receiver, having the specified number of rows and columns.cern.colt.matrix.DoubleMatrix1Dlike1D(int size)Construct and returns a new 1-d matrix of the corresponding dynamic type, entirelly independent of the receiver.protected cern.colt.matrix.DoubleMatrix1Dlike1D(int size, int zero, int stride)Construct and returns a new 1-d matrix of the corresponding dynamic type, sharing the same cells.voidsetQuick(int row, int column, double value)Sets the matrix cell at coordinate [row,column] to the specified value.voidsetRow(int row, int[] indices, double[] values)Replaces one row of the matrix.protected voidsetUp(int rows, int columns)Sets up a matrix with a given number of rows and columns.cern.colt.matrix.DoubleMatrix1DviewRow(int row)Constructs and returns a new slice view representing the columns of the given row.protected cern.colt.matrix.DoubleMatrix2DviewSelectionLike(int[] rowOffsets, int[] columnOffsets)Construct and returns a new selection view.-
Methods inherited from class cern.colt.matrix.DoubleMatrix2D
aggregate, aggregate, assign, assign, assign, assign, assign, cardinality, copy, equals, equals, forEachNonZero, get, getContent, getNonZeros, haveSharedCells, haveSharedCellsRaw, like, set, toArray, toString, view, viewColumn, viewColumnFlip, viewDice, viewPart, viewRowFlip, viewSelection, viewSelection, viewSorted, viewStrides, zAssign8Neighbors, zMult, zMult, zMult, zMult, zSum
-
Methods inherited from class cern.colt.matrix.impl.AbstractMatrix2D
_columnOffset, _columnRank, _rowOffset, _rowRank, checkBox, checkColumn, checkColumnIndexes, checkRow, checkRowIndexes, checkShape, checkShape, columns, index, rows, setUp, size, toStringShort, vColumnFlip, vDice, vPart, vRowFlip, vStrides
-
-
-
-
Field Detail
-
_rowViews
protected SparseDoubleMatrix1D[] _rowViews
SparseDoubleMatrix1D views of rows in this matrix. These are created and stored on demand.
-
-
Constructor Detail
-
SparseDoubleMatrix2D
public SparseDoubleMatrix2D(int rows, int columns)Constructs a matrix with a given number of rows and columns. All entries are initially 0.- Parameters:
rows- the number of rows the matrix shall have.columns- the number of columns the matrix shall have.- Throws:
java.lang.IllegalArgumentException- if rows<0 || columns<0 || (double)columns*rows > Integer.MAX_VALUE.
-
-
Method Detail
-
like
public cern.colt.matrix.DoubleMatrix2D like(int rows, int columns)Construct and returns a new empty matrix of the same dynamic type as the receiver, having the specified number of rows and columns. For example, if the receiver is an instance of type SparseDoubleMatrix2D the new matrix must also be of type DenseDoubleMatrix2D, if the receiver is an instance of type SparseDoubleMatrix2D the new matrix must also be of type SparseDoubleMatrix2D, etc. In general, the new matrix should have internal parametrization as similar as possible.- Specified by:
likein classcern.colt.matrix.DoubleMatrix2D- Parameters:
rows- the number of rows the matrix shall have.columns- the number of columns the matrix shall have.- Returns:
- a new empty matrix of the same dynamic type.
-
like1D
public cern.colt.matrix.DoubleMatrix1D like1D(int size)
Construct and returns a new 1-d matrix of the corresponding dynamic type, entirelly independent of the receiver. For example, if the receiver is an instance of type DenseDoubleMatrix2D the new matrix must be of type DenseDoubleMatrix1D, if the receiver is an instance of type SparseDoubleMatrix2D the new matrix must be of type SparseDoubleMatrix1D, etc.- Specified by:
like1Din classcern.colt.matrix.DoubleMatrix2D- Parameters:
size- the number of cells the matrix shall have.- Returns:
- a new matrix of the corresponding dynamic type.
-
like1D
protected cern.colt.matrix.DoubleMatrix1D like1D(int size, int zero, int stride)Construct and returns a new 1-d matrix of the corresponding dynamic type, sharing the same cells. For example, if the receiver is an instance of type DenseDoubleMatrix2D the new matrix must be of type DenseDoubleMatrix1D, if the receiver is an instance of type SparseDoubleMatrix2D the new matrix must be of type SparseDoubleMatrix1D, etc.- Specified by:
like1Din classcern.colt.matrix.DoubleMatrix2D- Parameters:
size- the number of cells the matrix shall have.zero- the index of the first element.stride- the number of indexes between any two elements, i.e. index(i+1)-index(i).- Returns:
- a new matrix of the corresponding dynamic type.
-
getQuick
public double getQuick(int row, int column)Returns the matrix cell value at coordinate [row,column].Provided with invalid parameters this method may return invalid objects without throwing any exception. You should only use this method when you are absolutely sure that the coordinate is within bounds. Precondition (unchecked): 0 <= column < columns() && 0 <= row < rows().
- Specified by:
getQuickin classcern.colt.matrix.DoubleMatrix2D- Parameters:
row- the index of the row-coordinate.column- the index of the column-coordinate.- Returns:
- the value at the specified coordinate.
-
setQuick
public void setQuick(int row, int column, double value)Sets the matrix cell at coordinate [row,column] to the specified value.Provided with invalid parameters this method may access illegal indexes without throwing any exception. You should only use this method when you are absolutely sure that the coordinate is within bounds. Precondition (unchecked): 0 <= column < columns() && 0 <= row < rows().
- Specified by:
setQuickin classcern.colt.matrix.DoubleMatrix2D- Parameters:
row- the index of the row-coordinate.column- the index of the column-coordinate.value- the value to be filled into the specified cell.
-
viewRow
public cern.colt.matrix.DoubleMatrix1D viewRow(int row)
Constructs and returns a new slice view representing the columns of the given row. The returned view is backed by this matrix, so changes in the returned view are reflected in this matrix, and vice-versa. To obtain a slice view on subranges, construct a sub-ranging view (viewPart( ...)), then apply this method to the sub-range view.Example:
2 x 3 matrix:
1, 2, 3
4, 5, 6viewRow(0) ==> Matrix1D of size 3:
1, 2, 3- Overrides:
viewRowin classcern.colt.matrix.DoubleMatrix2D- Parameters:
row- the row to fix.- Returns:
- a new slice view.
- Throws:
java.lang.IndexOutOfBoundsException- if row < 0 || row >= rows().- See Also:
DoubleMatrix2D.viewColumn(int)
-
setRow
public void setRow(int row, int[] indices, double[] values)Replaces one row of the matrix.- Parameters:
row- the row to replace.indices- the indices to be filled in the new row.values- the values to be filled into the new row.
-
viewSelectionLike
protected cern.colt.matrix.DoubleMatrix2D viewSelectionLike(int[] rowOffsets, int[] columnOffsets)Construct and returns a new selection view.- Specified by:
viewSelectionLikein classcern.colt.matrix.DoubleMatrix2D- Parameters:
rowOffsets- the offsets of the visible elements.columnOffsets- the offsets of the visible elements.- Returns:
- a new view.
-
setUp
protected void setUp(int rows, int columns)Sets up a matrix with a given number of rows and columns.- Overrides:
setUpin classcern.colt.matrix.impl.AbstractMatrix2D- Parameters:
rows- the number of rows the matrix shall have.columns- the number of columns the matrix shall have.- Throws:
java.lang.IllegalArgumentException- if rows<0 || columns<0 || (double)columns*rows > Integer.MAX_VALUE.
-
-