Search in sources :

Example 86 with DoubleMatrix2D

use of cern.colt.matrix.DoubleMatrix2D in project tdq-studio-se by Talend.

the class TestMatrix2D method doubleTest12.

/**
 */
public static void doubleTest12() {
    DoubleMatrix2D A, B, C, D, E, F, G, H, I, J;
    A = Factory2D.make(2, 3, 9);
    B = Factory2D.make(4, 3, 8);
    C = Factory2D.appendRows(A, B);
    System.out.println("\nA=" + A);
    System.out.println("\nB=" + B);
    System.out.println("\nC=" + C);
    D = Factory2D.make(3, 2, 7);
    E = Factory2D.make(3, 4, 6);
    F = Factory2D.appendColumns(D, E);
    System.out.println("\nD=" + D);
    System.out.println("\nE=" + E);
    System.out.println("\nF=" + F);
    G = Factory2D.appendRows(C, F);
    System.out.println("\nG=" + G);
    H = Factory2D.ascending(2, 3);
    System.out.println("\nH=" + H);
    I = Factory2D.repeat(H, 2, 3);
    System.out.println("\nI=" + I);
}
Also used : DoubleMatrix2D(cern.colt.matrix.DoubleMatrix2D)

Example 87 with DoubleMatrix2D

use of cern.colt.matrix.DoubleMatrix2D in project tdq-studio-se by Talend.

the class TestMatrix2D method doubleTest15.

/**
 */
public static void doubleTest15(int size, int runs) {
    System.out.println("\n\n");
    double[][] values = { { 0, 5, 9 }, { 2, 6, 10 }, { 3, 7, 11 } };
    // DoubleMatrix2D A = Factory2D.make(values);
    DoubleMatrix2D A = Factory2D.make(size, size);
    double value = 5;
    for (int i = size; --i >= 0; ) {
        A.setQuick(i, i, value);
    }
    A.viewRow(0).assign(value);
    // DoubleMatrix2D A = Factory2D.makeIdentity(size,size);
    // DoubleMatrix2D A = Factory2D.makeAscending(size,size).assign(new cern.jet.random.engine.MersenneTwister());
    cern.colt.Timer timer = new cern.colt.Timer().start();
    DoubleMatrix2D inv = null;
    for (int run = 0; run < runs; run++) {
        inv = LinearAlgebra.inverse(A);
    }
    timer.stop().display();
/*
timer.reset().start();
for (int run=0; run<runs; run++) {
	new Jama.Matrix(A.toArray()).inverse();
}
timer.stop().display();
*/
// System.out.println("A="+A);
// System.out.println("inverse(A)="+inv);
// System.out.println("formatted inverse(A)="+ new Jama.Matrix(inv.toArray()));
/*
-1.0000000000000018, 2.000000000000007, -1.0000000000000047
2.000000000000007, -6.750000000000024, 4.500000000000016
-1.000000000000004, 3.7500000000000133, -2.500000000000009
*/
}
Also used : DoubleMatrix2D(cern.colt.matrix.DoubleMatrix2D)

Example 88 with DoubleMatrix2D

use of cern.colt.matrix.DoubleMatrix2D in project tdq-studio-se by Talend.

the class TestMatrix2D method doubleTest26.

/**
 */
public static void doubleTest26(int size) {
    System.out.println("\n\n");
    System.out.println("initializing...");
    boolean dense = true;
    DoubleMatrix2D A;
    DoubleFactory2D factory;
    if (dense)
        factory = Factory2D.dense;
    else
        factory = Factory2D.sparse;
    double value = 0.5;
    A = factory.make(size, size, value);
    Property.generateNonSingular(A);
    cern.colt.Timer timer = new cern.colt.Timer().start();
    DoubleMatrix2DComparator fun = new DoubleMatrix2DComparator() {

        public int compare(DoubleMatrix2D a, DoubleMatrix2D b) {
            return a.zSum() == b.zSum() ? 1 : 0;
        }
    };
    System.out.println(A);
    System.out.println(Algebra.ZERO.inverse(A));
    timer.stop().display();
    System.out.println("done.");
}
Also used : DoubleMatrix2D(cern.colt.matrix.DoubleMatrix2D) DoubleMatrix2DComparator(cern.colt.matrix.doublealgo.DoubleMatrix2DComparator) DoubleFactory2D(cern.colt.matrix.DoubleFactory2D)

Example 89 with DoubleMatrix2D

use of cern.colt.matrix.DoubleMatrix2D in project tdq-studio-se by Talend.

the class TestMatrix2D method doubleTest29.

/**
 */
public static void doubleTest29(DoubleFactory2D f) {
    double[][] data = { { 6, 5, 4 }, { 7, 6, 3 }, { 6, 5, 4 }, { 7, 6, 3 }, { 6, 5, 4 }, { 7, 6, 3 } };
    double[][] arrMatrix = { { 1, 2, 3, 4, 5, 6 }, { 2, 3, 4, 5, 6, 7 } };
    DoubleMatrix2D x = new DenseDoubleMatrix2D(data);
    DoubleMatrix2D matrix = f.make(arrMatrix);
    DoubleMatrix2D res = matrix.zMult(x, null);
    System.out.println(res);
}
Also used : DoubleMatrix2D(cern.colt.matrix.DoubleMatrix2D)

Example 90 with DoubleMatrix2D

use of cern.colt.matrix.DoubleMatrix2D in project tdq-studio-se by Talend.

the class TestMatrix2D method doubleTest.

/**
 */
public static void doubleTest() {
    int rows = 4;
    // make a 4*5 matrix
    int columns = 5;
    DoubleMatrix2D master = new DenseDoubleMatrix2D(rows, columns);
    System.out.println(master);
    // set all cells to 1
    master.assign(1);
    System.out.println("\n" + master);
    // set [2,1] .. [3,3] to 2
    master.viewPart(2, 1, 2, 3).assign(2);
    System.out.println("\n" + master);
    DoubleMatrix2D copyPart = master.viewPart(2, 1, 2, 3).copy();
    // modify an independent copy
    copyPart.assign(3);
    copyPart.set(0, 0, 4);
    // has changed
    System.out.println("\n" + copyPart);
    // master has not changed
    System.out.println("\n" + master);
    // [0,3] .. [3,4]
    DoubleMatrix2D view1 = master.viewPart(0, 3, 4, 2);
    // a view from a view
    DoubleMatrix2D view2 = view1.viewPart(0, 0, 4, 1);
    System.out.println("\n" + view1);
    System.out.println("\n" + view2);
}
Also used : DoubleMatrix2D(cern.colt.matrix.DoubleMatrix2D)

Aggregations

DoubleMatrix2D (cern.colt.matrix.DoubleMatrix2D)136 DenseDoubleMatrix2D (cern.colt.matrix.impl.DenseDoubleMatrix2D)38 DoubleMatrix1D (cern.colt.matrix.DoubleMatrix1D)36 Algebra (cern.colt.matrix.linalg.Algebra)16 DoubleFactory2D (cern.colt.matrix.DoubleFactory2D)13 DenseDoubleMatrix1D (cern.colt.matrix.impl.DenseDoubleMatrix1D)13 Node (edu.cmu.tetrad.graph.Node)11 Graph (edu.cmu.tetrad.graph.Graph)8 Test (org.junit.Test)6 DoubleMatrixReader (ubic.basecode.io.reader.DoubleMatrixReader)6 StringMatrixReader (ubic.basecode.io.reader.StringMatrixReader)6 DataSet (edu.cmu.tetrad.data.DataSet)5 DoubleArrayList (cern.colt.list.DoubleArrayList)4 TetradMatrix (edu.cmu.tetrad.util.TetradMatrix)4 DenseDoubleMatrix (ubic.basecode.dataStructure.matrix.DenseDoubleMatrix)4 AbstractFormatter (cern.colt.matrix.impl.AbstractFormatter)3 Endpoint (edu.cmu.tetrad.graph.Endpoint)3 ExpressionDataDoubleMatrix (ubic.gemma.core.datastructure.matrix.ExpressionDataDoubleMatrix)3 BioMaterial (ubic.gemma.model.expression.biomaterial.BioMaterial)3 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)3