Package no.uib.cipr.matrix

Examples of no.uib.cipr.matrix.Matrix


        super.setUp();
    }

    public void testTriDiagonal() {
        int n = Utilities.getInt(1, 10);
        Matrix A = new DenseMatrix(n, n);
        Vector x = new DenseVector(n);

        for (int i = 0; i < n; ++i) {
            A.set(i, i, 2);
            x.set(i, 1);
        }
        for (int i = 0; i < n - 1; ++i) {
            A.set(i, i + 1, -1);
            A.set(i + 1, i, -1);
        }

        testFactorization(A, x);
    }
View Full Code Here


        testFactorization(A, x);
    }

    public void testPentaDiagonal() {
        int n = Utilities.getInt(1, 10);
        Matrix A = new DenseMatrix(n, n);
        Vector x = new DenseVector(n);

        for (int i = 0; i < n; ++i) {
            A.set(i, i, 4);
            x.set(i, 1);
        }
        for (int i = 0; i < n - 1; ++i) {
            A.set(i, i + 1, -1);
            A.set(i + 1, i, -1);
        }
        for (int i = 0; i < n - 2; ++i) {
            A.set(i, i + 2, -1);
            A.set(i + 2, i, -1);
        }

        testFactorization(A, x);
    }
View Full Code Here

    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

    /**
     * We can't zero, so we do without
     */
    @Override
    public void testCopy() {
        Matrix Ac = A.copy();
        assertEquals(Ad, Ac);
    }
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
                    assertEquals(J.get(i, j), 1, 1e-10);
    }
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
                    assertEquals(J.get(i, j), 1, 1e-10);
    }
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
                    assertEquals(J.get(i, j), 1, 1e-10);
    }
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
                    assertEquals(J.get(i, j), 1, 1e-10);
    }
View Full Code Here

    Stopwatch watch = Stopwatch.createUnstarted();
    DenseMatrix dense = new DenseMatrix(1000, 1000);
    int[][] nz = Utilities.getRowPattern(dense.numRows(), dense.numColumns(), 100);
    Utilities.rowPopulate(dense, nz);
    log.info("created matrices");
    Matrix sparse = new LinkedSparseMatrix(dense.numRows(), dense.numColumns());
    sparse.set(dense);

    for (Matrix m : Lists.newArrayList(dense, sparse)) {
      log.info("starting " + m.getClass());
      Matrix t = new DenseMatrix(m);
      t.transpose();
      Matrix o = new DenseMatrix(dense.numRows(), dense.numColumns());
      log.info("warming up " + m.getClass() + " " + o.getClass());
      for (int i = 0; i < 10; i++)
        m.mult(t, o);
      log.info("starting " + m.getClass() + " " + o.getClass());
      watch.start();
      for (int i = 0; i < 100; i++)
        m.mult(t, o);
      watch.stop();
      log.info(m.getClass() + " " + o.getClass() + " " + watch);
    }
  }
View Full Code Here

    Stopwatch watch = Stopwatch.createUnstarted();
    DenseMatrix dense = new DenseMatrix(1000, 1000);
    int[][] nz = Utilities.getRowPattern(dense.numRows(), dense.numColumns(), 100);
    Utilities.rowPopulate(dense, nz);
    log.info("created matrices");
    Matrix sparse = new LinkedSparseMatrix(dense.numRows(), dense.numColumns());
    sparse.set(dense);

    for (Matrix m : Lists.newArrayList(dense, sparse)) {
      log.info("starting " + m.getClass());
      Matrix t = new DenseMatrix(m);
      Matrix o = new DenseMatrix(dense.numRows(), dense.numColumns());
      log.info("warming up " + m.getClass() + " " + o.getClass());
      for (int i = 0; i < 10; i++)
        m.transAmult(t, o);
      log.info("starting " + m.getClass() + " " + o.getClass());
      watch.start();
      for (int i = 0; i < 100; i++)
        m.transAmult(t, o);
      watch.stop();
      log.info(m.getClass() + " " + o.getClass() + " " + watch);
    }
  }
View Full Code Here

TOP

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

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.