Examples of GMatrix


Examples of javax.vecmath.GMatrix

        GVector p = new GVector( r );
        GVector xnew = new GVector( p );
        GVector rnew = new GVector( p );
        GVector pnew = new GVector( p );
        GVector matrixMultp = new GVector( p );
        GMatrix matrixInverse = new GMatrix( matrix );
        matrixInverse.invert();
        double error, norm;
        int iteration = 0;

        do {
            matrixMultp.mul( matrix, p );
View Full Code Here

Examples of javax.vecmath.GMatrix

     * The element (i, j) in the returned matrix is the kernel
     * evaluated for the data points in columns i and j in the data.
     */
    public static GMatrix kernelMatrix(GMatrix data, Kernel kernel) {
        int rows = data.getNumRow(), cols = data.getNumCol();
        GMatrix k = new GMatrix(cols, cols);
        GVector x1 = new GVector(rows);
        GVector x2 = new GVector(rows);
       
        // kernels are symmetric, so we only need calculate
        // every {i, j} combination, not permutation.
        for(int i = 0; i < cols; i++) {
            data.getColumn(i, x1);
            // set the diagonal
            k.setElement(i, i, kernel.eval(x1, x1));
           
            for(int j = i + 1; j < cols; j++) {
                data.getColumn(j, x2);
                double val = kernel.eval(x1, x2);
                k.setElement(i, j, val);
                k.setElement(j, i, val);
            }
        }
       
        return k;
    }
View Full Code Here

Examples of javax.vecmath.GMatrix

     * Returns a matrix with the specified number of rows and columns
     * where each element is randomly chosen from a uniform distribution
     * on the interval [0, 1].
     */
    public static GMatrix randomUniformMatrix(int rows, int cols) {
        GMatrix m = new GMatrix(rows, cols);
        for(int i = 0; i < rows; i++) {
            for(int j = 0; j < cols; j++) {
                m.setElement(i, j, RAND.nextDouble());
            }
        }
        return m;
    }
View Full Code Here

Examples of javax.vecmath.GMatrix

     * Returns a matrix with the specified number of rows and columns
     * where each element is randomly chosen from a Gaussian ("normal")
     * distribution with mean 0.0 and standard deviation 1.0.
     */
    public static GMatrix randomGaussianMatrix(int rows, int cols) {
        GMatrix m = new GMatrix(rows, cols);
        for(int i = 0; i < rows; i++) {
            for(int j = 0; j < cols; j++) {
                m.setElement(i, j, RAND.nextGaussian());
            }
        }
        return m;
    }
View Full Code Here

Examples of javax.vecmath.GMatrix

  public static void main(String[] args)
  {
    int n = 4;
    int m = 2;

    GMatrix data = new GMatrix(m, n);
    GVector values = new GVector(n);

    for (int i = 0; i < m; i++)
    {
      data.setRow(i, getRandomArray(n));
    }

    double[] v = new double[n];
    for (int i = 0; i < n; i++)
    {
      double[] col = new double[m];
      data.getColumn(i, col);
      v[i] = getValue(col);
    }

    values.set(v);
View Full Code Here

Examples of javax.vecmath.GMatrix

/* 582 */     int index = this.currentIndex;
/* 583 */     long time_basis = this.readings[index].time;
/*     */
/* 586 */     time -= time_basis;
/*     */
/* 588 */     GMatrix A = new GMatrix(num_readings, order + 1);
/*     */
/* 590 */     for (int i = 0; i < num_readings; i++) {
/* 591 */       A.setElement(i, 0, 1.0D);
/* 592 */       long tempTime = lastTimeRelative(num_readings - i - 1, index, time_basis);
/* 593 */       A.setElement(i, 1, tempTime);
/* 594 */       for (int j = 2; j <= order; j++)
/*     */       {
/* 596 */         A.setElement(i, j, powerAndDiv(tempTime, j));
/*     */       }
/*     */     }
/*     */
/* 600 */     GMatrix A_Transpose = new GMatrix(A);
/* 601 */     A_Transpose.transpose();
/* 602 */     GMatrix M = new GMatrix(order + 1, order + 1);
/* 603 */     M.mul(A_Transpose, A);
/*     */     try {
/* 605 */       M.invert();
/*     */     } catch (SingularMatrixException e) {
/* 607 */       System.out.println("SINGULAR MATRIX EXCEPTION in prediction");
/* 608 */       System.out.println(M);
/*     */     }
/*     */
/* 612 */     double[] transformArray = new double[16];
/* 613 */     GMatrix solMatrix = new GMatrix(order + 1, num_readings);
/* 614 */     solMatrix.mul(M, A_Transpose);
/*     */
/* 616 */     GVector P = new GVector(order + 1);
/*     */
/* 619 */     GVector predTimeVec = new GVector(order + 1);
/* 620 */     predTimeVec.setElement(0, 1.0D);
View Full Code Here

Examples of javax.vecmath.GMatrix

    /**
     * {@inheritDoc}
     */
    public final void multiply(final Matrix matrix) {
        final GMatrix m;
        if (matrix instanceof GMatrix) {
            m = (GMatrix) matrix;
        } else {
            m = new GeneralMatrix(matrix);
        }
View Full Code Here

Examples of toxi.geom.GMatrix

            for (int i = 0; i < n; i++) {
                int span = uKnots.findSpan(uk[i]);
                double[] tmp = uKnots.basisFunctions(span, uk[i]);
                System.arraycopy(tmp, 0, A, i * n + span - degree, tmp.length);
            }
            final GMatrix a = new GMatrix(n, n, A);
            final GVector perm = new GVector(n);
            final GMatrix lu = new GMatrix(n, n);
            a.computeLUD(lu, perm);

            final Vec4D[] cps = new Vec4D[n];
            for (int i = 0; i < cps.length; i++) {
                cps[i] = new Vec4D(0, 0, 0, 1);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.