Documentation API of the 'cern.colt.matrix.tfloat.impl.SparseCCFloatMatrix2D' Java class
SparseCCFloatMatrix2D
cern.colt.matrix.tfloat.impl

Class SparseCCFloatMatrix2D

  • All Implemented Interfaces:
    Serializable, Cloneable


    public class SparseCCFloatMatrix2Dextends WrapperFloatMatrix2D
    Sparse column-compressed 2-d matrix holding float elements. First see the package summary and javadoc tree view to get the broad picture.

    Implementation:

    Internally uses the standard sparse column-compressed format.
    Note that this implementation is not synchronized.

    Cells that

    • are never set to non-zero values do not use any memory.
    • switch from zero to non-zero state do use memory.
    • switch back from non-zero to zero state also do use memory. Their memory is not automatically reclaimed. Reclamation can be triggered via trimToSize().

    Time complexity:

    Getting a cell value takes time O(log nzr) where nzr is the number of non-zeros of the touched row. This is usually quick, because typically there are only few nonzeros per row. So, in practice, get has expected constant time. Setting a cell value takes worst-case time O(nz) where nzr is the total number of non-zeros in the matrix. This can be extremely slow, but if you traverse coordinates properly (i.e. upwards), each write is done much quicker:

     // rather quick matrix.assign(0); for (int column = 0; column < columns; column++) {     for (int row = 0; row < rows; row++) {         if (someCondition)             matrix.setQuick(row, column, someValue);     } }  // poor matrix.assign(0); for (int column = columns; --column >= 0;) {     for (int row = rows; --row >= 0;) {         if (someCondition)             matrix.setQuick(row, column, someValue);     } } 
    If for whatever reasons you can't iterate properly, consider to create an empty dense matrix, store your non-zeros in it, then call sparse.assign(dense). Under the circumstances, this is still rather quick.

    Fast iteration over non-zeros can be done via forEachNonZero(cern.colt.function.tfloat.IntIntFloatFunction), which supplies your function with row, column and value of each nonzero. Although the internally implemented version is a bit more sophisticated, here is how a quite efficient user-level matrix-vector multiplication could look like:

     // Linear algebraic y = A * x A.forEachNonZero(new cern.colt.function.IntIntFloatFunction() {     public float apply(int row, int column, float value) {         y.setQuick(row, y.getQuick(row) + value * x.getQuick(column));         return value;     } }); 

    Here is how a a quite efficient user-level combined scaling operation could look like:

     // Elementwise A = A + alpha*B B.forEachNonZero(new cern.colt.function.IntIntFloatFunction() {     public float apply(int row, int column, float value) {         A.setQuick(row, column, A.getQuick(row, column) + alpha * value);         return value;     } }); 
    Method assign(FloatMatrix2D,cern.colt.function.tfloat.FloatFloatFunction) does just that if you supply FloatFunctions.plusMultSecond(float) as argument.
    See Also:
    Serialized Form

Warning: You cannot see the full API documentation of this class since the access to the DatMelt documentation for third-party Java classes is denied. Guests can only view jhplot Java API. To view the complete description of this class and its methods, please request the full DataMelt membership.

If you are already a full member, please login to the DataMelt member area before visiting this documentation.