Package no.uib.cipr.matrix

Examples of no.uib.cipr.matrix.DenseMatrix


import java.io.FileWriter;

public class MatrixVectorIoTest extends TestCase {

  public void testWriteRead() throws Exception {
    DenseMatrix mat = new DenseMatrix(new double[][] {{1.1,1.2},{1.3,1.4}});
    File matrixFile = new File("TestMatrixFile");
    BufferedWriter out = new BufferedWriter(new FileWriter(matrixFile));
    MatrixVectorWriter writer = new MatrixVectorWriter(out);
    MatrixInfo mi = new MatrixInfo(false, MatrixInfo.MatrixField.Real, MatrixInfo.MatrixSymmetry.General);
    writer.printMatrixInfo(mi);
    writer.printMatrixSize(new MatrixSize(mat.numRows(), mat.numColumns(), mat.numColumns() * mat.numRows()), mi);
    writer.printArray(mat.getData());
    writer.close();
    Matrix newMat = new DenseMatrix(new MatrixVectorReader(new FileReader(matrixFile)));

    MatrixTestAbstract.assertEquals(mat, newMat);
  }
View Full Code Here


        c.factor(L.copy());

    assert I != null;
        c.solve(I);

        Matrix J = I.mult(L, new DenseMatrix(n, n));
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < n; ++j)
                if (i != j)
                    assertEquals(J.get(i, j), 0, 1e-10);
                else
View Full Code Here

        DenseCholesky c = new DenseCholesky(n, true);
        c.factor(U.copy());

        c.solve(I);

        Matrix J = I.mult(U, new DenseMatrix(n, n));
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < n; ++j)
                if (i != j)
                    assertEquals(J.get(i, j), 0, 1e-10);
                else
View Full Code Here

    @Override
    protected void createPrimary() throws Exception {
        int n = Utilities.getInt(1, max);
        int m = Utilities.getInt(1, max);
        A = new DenseMatrix(n, m);
        Ad = Utilities.populate(A);
    }
View Full Code Here

        // The issue here is that we should not allow matrices with more than
        // Integer.MAX_VALUE entries.
        boolean exceptionThrown = false;
        try
        {
            Matrix m = new DenseMatrix(Integer.MAX_VALUE, 2);
        }
        catch (IllegalArgumentException e)
        {
            exceptionThrown = true;
        }
        finally
        {
            assertTrue(exceptionThrown);
        }

        exceptionThrown = false;
        try
        {
            Matrix m = new DenseMatrix(Integer.MAX_VALUE, 3);
        }
        catch (IllegalArgumentException e)
        {
            exceptionThrown = true;
        }
        finally
        {
            assertTrue(exceptionThrown);
        }

        exceptionThrown = false;
        try
        {
            Matrix m = new DenseMatrix(Integer.MAX_VALUE - 10, 3);
        }
        catch (IllegalArgumentException e)
        {
            exceptionThrown = true;
        }
View Full Code Here

        PackCholesky c = new PackCholesky(n, false);
        c.factor(L.copy());

        c.solve(I);

        Matrix J = I.mult(L, new DenseMatrix(n, n));
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < n; ++j)
                if (i != j)
                    assertEquals(J.get(i, j), 0, 1e-10);
                else
View Full Code Here

        PackCholesky c = new PackCholesky(n, true);
        c.factor(U.copy());

        c.solve(I);

        Matrix J = I.mult(U, new DenseMatrix(n, n));
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < n; ++j)
                if (i != j)
                    assertEquals(J.get(i, j), 0, 1e-10);
                else
View Full Code Here

        assertEquals(A, QL.factorize(A));
    }

    public void testFactor() {
        QL ql = new QL(A.numRows(), A.numColumns());
        assertEquals(A, ql.factor(new DenseMatrix(A)));
    }
View Full Code Here

        assertEquals(A, ql.factor(new DenseMatrix(A)));
    }

    public void testRepeatFactor() {
        QL ql = new QL(A.numRows(), A.numColumns());
        ql.factor(new DenseMatrix(A));
        assertEquals(A, ql);
        ql.factor(new DenseMatrix(A));
        assertEquals(A, ql);
    }
View Full Code Here

        assertEquals(Ar, QL.factorize(Ar));
    }

    public void testFactorNonSquare() {
        QL ql = new QL(Ar.numRows(), Ar.numColumns());
        assertEquals(Ar, ql.factor(new DenseMatrix(Ar)));
    }
View Full Code Here

TOP

Related Classes of no.uib.cipr.matrix.DenseMatrix

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.