## Examples of javax.vecmath.GMatrix

 `363738394041424344454647` ```        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

 `798081828384858687888990919293949596979899100101102103104` ```     * 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

 `112113114115116117118119120121122123124` ```     * 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

 `127128129130131132133134135136137138139` ```     * 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

 `1617181920212223242526272829303132333435363738` ```  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

 `276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311` ```/* 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

 `460461462463464465466467468469470` ```     /**      * {@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