Package org.jblas

Examples of org.jblas.DoubleMatrix$ElementsAsListView


    assertEquals(DoubleMatrix.scalar(8.0), A.get(point(1), point(2)));
  }

  @Test
  public void indicesRange() {
    assertEquals(new DoubleMatrix(1, 5, 1.0, 7.0, 4.0, 10.0, 1.0), A.get(0, indices(new int[] {0, 2, 1, 3, 0})));
  }
View Full Code Here


    assertEquals(new DoubleMatrix(1, 5, 1.0, 7.0, 4.0, 10.0, 1.0), A.get(0, indices(new int[] {0, 2, 1, 3, 0})));
  }

  @Test
  public void mixedRanges() {
    assertEquals(new DoubleMatrix(3, 2, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0), A.get(all(), interval(1, 3)));
    assertEquals(new DoubleMatrix(2, 1, 11.0, 12.0), A.get(interval(1, 3), point(3)));
  }
View Full Code Here

            int j = ipiv[i] - 1;
            int t = indices[i];
            indices[i] = indices[j];
            indices[j] = t;
        }
        DoubleMatrix result = new DoubleMatrix(size, size);
        for (int i = 0; i < size; i++)
            result.put(indices[i], i, 1.0);
        return result;
    }
View Full Code Here

        }
    }

    /** Check whether vector addition works. This is pure Java code and should work. */
    public static void checkVectorAddition() {
        DoubleMatrix x = new DoubleMatrix(3, 1, 1.0, 2.0, 3.0);
        DoubleMatrix y = new DoubleMatrix(3, 1, 4.0, 5.0, 6.0);
        DoubleMatrix z = new DoubleMatrix(3, 1, 5.0, 7.0, 9.0);

        check("checking vector addition", x.add(y).equals(z));
    }
View Full Code Here

    }

    /** Check matrix multiplication. This is already ATLAS/BLAS code. */
    public static void checkMatrixMultiplication() {

        DoubleMatrix A = new DoubleMatrix(new double[][]{
                    {1.0, 2.0, 3.0},
                    {4.0, 5.0, 6.0},
                    {7.0, 8.0, 9.0}
                });
        DoubleMatrix E = new DoubleMatrix(new double[][]{
                    {0.0, 0.0, 1.0},
                    {0.0, 1.0, 0.0},
                    {1.0, 0.0, 0.0}
                });
        DoubleMatrix B = new DoubleMatrix(new double[][]{
                    {3.0, 2.0, 1.0},
                    {6.0, 5.0, 4.0},
                    {9.0, 8.0, 7.0}
                });

View Full Code Here

    /**
     * Compute eigenvalues. This is a routine not in ATLAS, but in the original
     * LAPACK.
     */
    public static void checkEigenvalues() {
        DoubleMatrix A = new DoubleMatrix(new double[][]{
                    {3.0, 2.0, 0.0},
                    {2.0, 3.0, 2.0},
                    {0.0, 2.0, 3.0}
                });

        DoubleMatrix E = new DoubleMatrix(3, 1);

        NativeBlas.dsyev('N', 'U', 3, A.data, 0, 3, E.data, 0);
        check("checking existence of dsyev...", true);
    }
View Full Code Here

            {4.0, 5.0, 6.0},
            {7.0, 8.0, 9.0},
            {-1.0, -2.0, -3.0}
        };

        DoubleMatrix A = new DoubleMatrix(data);

        DoubleMatrix[] USV = org.jblas.Singular.sparseSVD(A);
        System.out.println(USV[0].toString());
        System.out.println(USV[1].toString());
        System.out.println(USV[2].toString());
View Full Code Here

        System.out.println(AZB[2].toString());*/
        check("checking existence of dgesvd...", true);
    }

    public static void checkGeneralizedEigenvalues() {
        DoubleMatrix A = new DoubleMatrix(3, 3, 2.0, 1.0, 0.0, 1.0, 2.0, 1.0, 0.0, 1.0, 2.0);
        DoubleMatrix B = new DoubleMatrix(3, 3, 4.0, 2.0, 1.0, 2.0, 4.0, 2.0, 1.0, 2.0, 4.0);

        DoubleMatrix[] LA = org.jblas.Eigen.symmetricGeneralizedEigenvectors(A, B);

        check("checkign existence of gsyevd (generalized eigenvalues)...", true);
    }
View Full Code Here

    public BenchmarkResult run(int size, double seconds) {
        int counter = 0;
        long ops = 0;

        DoubleMatrix A = randn(size, size);
        DoubleMatrix B = randn(size, size);
        DoubleMatrix C = randn(size, size);

        Timer t = new Timer();
        t.start();
        while (!t.ranFor(seconds)) {
            A.mmuli(B, C);
View Full Code Here

    public BenchmarkResult run(int size, double seconds) {
        int counter = 0;
        long ops = 0;

        DoubleMatrix A = randn(size, size);
        DoubleMatrix B = randn(size, size);
        DoubleMatrix C = randn(size, size);

        Timer t = new Timer();
        t.start();
        while (!t.ranFor(seconds)) {
            A.mmuli(B, C);
View Full Code Here

TOP

Related Classes of org.jblas.DoubleMatrix$ElementsAsListView

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.