Example usage for org.apache.commons.math3.linear SparseRealMatrix getColumnDimension

List of usage examples for org.apache.commons.math3.linear SparseRealMatrix getColumnDimension

Introduction

In this page you can find the example usage for org.apache.commons.math3.linear SparseRealMatrix getColumnDimension.

Prototype

int getColumnDimension();

Source Link

Document

Returns the number of columns in the matrix.

Usage

From source file:edu.byu.nlp.util.asserts.MoreAsserts.java

public static void assertSparseMatricesEqual(final SparseRealMatrix actual, final SparseRealMatrix expected) {
    Preconditions.checkNotNull(actual);//from www .j ava 2  s.c om
    Preconditions.checkNotNull(expected);
    Preconditions.checkArgument(actual.getRowDimension() == expected.getRowDimension());

    // check densely--this doesn't need to be fast
    for (int r = 0; r < actual.getRowDimension(); r++) {
        for (int c = 0; c < actual.getColumnDimension(); c++) {
            double act = actual.getEntry(r, c);
            double exp = expected.getEntry(r, c);
            if (act != exp) {
                System.err.println("actual[" + r + "][" + c + "]=" + act + " does not match expected[" + r
                        + "][" + c + "]=" + exp);
            }
            Assertions.assertThat(act).isEqualTo(exp);
        }
    }
}