Package org.encog.mathutil.matrices

Examples of org.encog.mathutil.matrices.Matrix


  public void testBipolar2double() throws Throwable
  {
    // test a 1x4
    boolean[] booleanData1 = { true, false, true, false };
    double[] checkData1 = {1,-1,1,-1};
    Matrix matrix1 = Matrix.createRowMatrix(BiPolarUtil.bipolar2double(booleanData1));
    Matrix checkMatrix1 = Matrix.createRowMatrix(checkData1);
    TestCase.assertTrue( matrix1.equals(checkMatrix1));
   
    // test a 2x2
    boolean booleanData2[][] = {{true,false},{false,true}};
    double checkData2[][] = { {1,-1}, {-1,1} };
    Matrix matrix2 = new Matrix(BiPolarUtil.bipolar2double(booleanData2));
    Matrix checkMatrix2 = new Matrix(checkData2);
    TestCase.assertTrue(matrix2.equals(checkMatrix2));
  }
View Full Code Here


      {2},
      {3},
      {4}
    };
   
    Matrix matrix1 = new Matrix(matrixData1);
    Matrix checkMatrix = new Matrix(matrixData2);
   
    Matrix matrix2 = MatrixMath.transpose(matrix1);
   
    TestCase.assertTrue(matrix2.equals(checkMatrix));
  }
View Full Code Here

      {6},
      {7},
      {8}
    };
   
    Matrix matrix1 = new Matrix(matrixData1);
    Matrix matrix2 = new Matrix(matrixData2);
   
    double dotProduct = MatrixMath.dotProduct(matrix1,matrix2);
   
    TestCase.assertEquals(dotProduct, 70.0);
   
    // test dot product errors
    double nonVectorData[][] = {{1.0,2.0},{3.0,4.0}};
    double differentLengthData[][] = {{1.0}};
    Matrix nonVector = new Matrix(nonVectorData);
    Matrix differentLength = new Matrix(differentLengthData);
   
    try
    {
      MatrixMath.dotProduct(matrix1, nonVector);
      TestCase.assertTrue(false);
View Full Code Here

   *
   * @return Lower trapezoidal matrix whose columns define the reflections
   */

  public Matrix getH() {
    Matrix X = new Matrix(m, n);
    double[][] H = X.getData();
    for (int i = 0; i < m; i++) {
      for (int j = 0; j < n; j++) {
        if (i >= j) {
          H[i][j] = QR[i][j];
        } else {
View Full Code Here

   *
   * @return R
   */

  public Matrix getR() {
    Matrix X = new Matrix(n, n);
    double[][] R = X.getData();
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (i < j) {
          R[i][j] = QR[i][j];
        } else if (i == j) {
View Full Code Here

   *
   * @return Q
   */

  public Matrix getQ() {
    Matrix X = new Matrix(m, n);
    double[][] Q = X.getData();
    for (int k = n - 1; k >= 0; k--) {
      for (int i = 0; i < m; i++) {
        Q[i][k] = 0.0;
      }
      Q[k][k] = 1.0;
View Full Code Here

        for (int j = 0; j < nx; j++) {
          X[i][j] -= X[k][j] * QR[i][k];
        }
      }
    }
    return (new Matrix(X).getMatrix(0, n - 1, 0, nx - 1));
  }
View Full Code Here

   *
   * @return L
   */

  public final Matrix getL() {
    return new Matrix(l);
  }
View Full Code Here

        }
        x[k][j] /= l[k][k];
      }
    }

    return new Matrix(x);
  }
View Full Code Here

import org.encog.mathutil.matrices.MatrixMath;

public class MatrixBenchmark {

  public static Matrix generateRandomMatrix(final int size) {
    final Matrix result = new Matrix(size, size);
    for (int row = 0; row < size; row++) {
      for (int col = 0; col < size; col++) {
        result.set(row, col, Math.random() * 100);
      }
    }
    return result;
  }
View Full Code Here

TOP

Related Classes of org.encog.mathutil.matrices.Matrix

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.