Package no.uib.cipr.matrix

Examples of no.uib.cipr.matrix.Vector


        if (!(y instanceof DistVector))
            throw new IllegalArgumentException("Vector must be DistVector");

        checkSize(y);

        Vector yb = ((DistVector) y).getLocal();

        x.set(alpha, yb);

        return this;
    }
View Full Code Here


        if (!(y instanceof DistVector))
            throw new IllegalArgumentException("Vector must be DistVector");

        checkSize(y);

        Vector yb = ((DistVector) y).getLocal();

        x.add(alpha, yb);

        return this;
    }
View Full Code Here

            throw new IllegalArgumentException("Vector must be a DistVector");

        checkSize(y);

        // Compute local part
        Vector yb = ((DistVector) y).getLocal();
        double ldot = x.dot(yb);

        // Sum all local parts
        double[] recv = new double[1];
        comm.allReduce(new double[] { ldot }, recv, Reductions.sum());
View Full Code Here

    entries[0] = 0.0;
    entries[1] = 0.0;
    entries[2] = 1.0;
    entries[3] = 0.0;
    entries[4] = 2.0;
    Vector dense = new DenseVector(entries, false);
    vector = new SparseVector(dense);

    // NOTE: must compact before calling getIndex()!!!
    // vector.compact();
    index = vector.getIndex();
View Full Code Here

     * Test of direct vector solver
     */
    public void testVectorSolve() {
        while (true) {
            try {
                Vector b = Matrices.random(A.numRows());
                Vector x = Matrices.random(A.numRows());
                x = A.solve(b, x);

                Vector y = A.multAdd(-1, x, x.copy().set(b));
                assertEquals(0, y.norm(Vector.Norm.Two), tol);
                assertEquals(Ad, A);
                return;
            } catch (MatrixSingularException e) {
                Utilities.addDiagonal(A, Ad, 1);
            } catch (MatrixNotSPDException e) {
View Full Code Here

     * Test of direct transpose vector solver
     */
    public void testTransVectorSolve() {
        while (true) {
            try {
                Vector b = Matrices.random(A.numRows());
                Vector x = Matrices.random(A.numRows());
                x = A.transSolve(b, x);

                Vector y = A.transMultAdd(-1, x, x.copy().set(b));
                assertEquals(0, y.norm(Vector.Norm.Two), tol);
                assertEquals(Ad, A);
                return;
            } catch (MatrixSingularException e) {
                Utilities.addDiagonal(A, Ad, 1);
            } catch (MatrixNotSPDException e) {
View Full Code Here

  {
    Variable v1 = new Variable (Variable.CONTINUOUS);
    Variable v2 = new Variable (Variable.CONTINUOUS);
    Randoms r = new Randoms (2343);

    Vector mu = new DenseVector (new double[] { 1.0, 2.0 });
    Matrix var = new DenseMatrix (new double[][] {{ 0.5, 2.0 }, { 0, 1 }});
//    Matrix var = new DenseMatrix (new double[][] {{ 0.5, 2.0 }, { 2.0, 0.75 }});

    VarSet vars = new HashVarSet (new Variable[] { v1, v2 });
    Factor f = new NormalFactor (vars, mu, var);
View Full Code Here

    entries[0] = 0.0;
    entries[1] = 0.0;
    entries[2] = 1.0;
    entries[3] = 0.0;
    entries[4] = 2.0;
    Vector dense = new DenseVector(entries, false);
    vector = new SparseVector(dense);

    // NOTE: must compact before calling getIndex()!!!
    // vector.compact();
    index = vector.getIndex();
View Full Code Here

*/
public class ILUTTest extends IncompleteFactorizationTestAbstract {

    @Override
    void testFactorization(Matrix A, Vector x) {
        Vector b = A.mult(x, x.copy());

        ILU ilut = new ILU(new CompRowMatrix(A));
        ilut.setMatrix(A);
        ilut.apply(b, x);

        Vector r = A.multAdd(-1, x, b.copy());

        assertEquals(0, r.norm(Vector.Norm.TwoRobust), 1e-5);
    }
View Full Code Here

    }

    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);
        }
View Full Code Here

TOP

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

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.