Package org.encog.mathutil.matrices

Examples of org.encog.mathutil.matrices.Matrix


  }
 
  public void testColumnMatrix() throws Throwable
  {
    double matrixData[] = {1.0,2.0,3.0,4.0};
    Matrix matrix = Matrix.createColumnMatrix(matrixData);
    TestCase.assertEquals(matrix.get(0,0), 1.0);
    TestCase.assertEquals(matrix.get(1,0), 2.0);
    TestCase.assertEquals(matrix.get(2,0), 3.0);
    TestCase.assertEquals(matrix.get(3,0), 4.0);
  }
View Full Code Here


  }
 
  public void testAdd() throws Throwable
  {
    double matrixData[] = {1.0,2.0,3.0,4.0};
    Matrix matrix = Matrix.createColumnMatrix(matrixData);
    matrix.add(0, 0, 1);
    TestCase.assertEquals(matrix.get(0, 0), 2.0);
  }
View Full Code Here

  }
 
  public void testClear() throws Throwable
  {
    double matrixData[] = {1.0,2.0,3.0,4.0};
    Matrix matrix = Matrix.createColumnMatrix(matrixData);
    matrix.clear();
    TestCase.assertEquals(matrix.get(0, 0), 0.0);
    TestCase.assertEquals(matrix.get(1, 0), 0.0);
    TestCase.assertEquals(matrix.get(2, 0), 0.0);
    TestCase.assertEquals(matrix.get(3, 0), 0.0);
  }
View Full Code Here

  }
 
  public void testIsVector() throws Throwable
  {
    double matrixData[] = {1.0,2.0,3.0,4.0};
    Matrix matrixCol = Matrix.createColumnMatrix(matrixData);
    Matrix matrixRow = Matrix.createRowMatrix(matrixData);
    TestCase.assertTrue(matrixCol.isVector());
    TestCase.assertTrue(matrixRow.isVector());
    double matrixData2[][] = {{1.0,2.0},{3.0,4.0}};
    Matrix matrix = new Matrix(matrixData2);
    TestCase.assertFalse(matrix.isVector());
  }
View Full Code Here

  }
 
  public void testIsZero() throws Throwable
  {
    double matrixData[] = {1.0,2.0,3.0,4.0};
    Matrix matrix = Matrix.createColumnMatrix(matrixData);
    TestCase.assertFalse(matrix.isZero());
    double matrixData2[] = {0.0,0.0,0.0,0.0};
    Matrix matrix2 = Matrix.createColumnMatrix(matrixData2);
    TestCase.assertTrue(matrix2.isZero());

  }
View Full Code Here

  }
 
  public void testPackedArray() throws Throwable
  {
    double matrixData[][] = {{1.0,2.0},{3.0,4.0}};
    Matrix matrix = new Matrix(matrixData);
    Double matrixData2[] = matrix.toPackedArray();
    TestCase.assertEquals(4, matrixData2.length);
    TestCase.assertEquals(1.0,matrix.get(0, 0));
    TestCase.assertEquals(2.0,matrix.get(0, 1));
    TestCase.assertEquals(3.0,matrix.get(1, 0));
    TestCase.assertEquals(4.0,matrix.get(1, 1));
   
    Matrix matrix2 = new Matrix(2,2);
    matrix2.fromPackedArray(matrixData2, 0);
    TestCase.assertTrue(matrix.equals(matrix2));
  }
View Full Code Here

  }
 
  public void testPackedArray2() throws Throwable
  {
    Double data[] = {1.0,2.0,3.0,4.0};
    Matrix matrix = new Matrix(1,4);
    matrix.fromPackedArray(data, 0);
    TestCase.assertEquals(1.0, matrix.get(0, 0));
    TestCase.assertEquals(2.0, matrix.get(0, 1));
    TestCase.assertEquals(3.0, matrix.get(0, 2));
  }
View Full Code Here

  }
 
  public void testSize() throws Throwable
  {
    double data[][] = {{1.0,2.0},{3.0,4.0}};
    Matrix matrix = new Matrix(data);
    TestCase.assertEquals(4, matrix.size());
  }
View Full Code Here

  }
 
  public void testVectorLength() throws Throwable
  {
    double vectorData[] = {1.0,2.0,3.0,4.0};
    Matrix vector = Matrix.createRowMatrix(vectorData);
    TestCase.assertEquals(5, (int)MatrixMath.vectorLength(vector));
   
    Matrix nonVector = new Matrix(2,2);
    try
    {
      MatrixMath.vectorLength(nonVector);
      TestCase.assertTrue(false);
    }
View Full Code Here

    setTraining(training);
    this.indexableTraining = getTraining();
    this.network = network;
    this.trainingLength = (int) this.indexableTraining.getRecordCount();
    this.parametersLength = this.network.getStructure().calculateSize();
    this.hessianMatrix = new Matrix(this.parametersLength,
        this.parametersLength);
    this.hessian = this.hessianMatrix.getData();
    this.beta = 1.0;
    this.lambda = 0.1;
    this.deltas = new double[this.parametersLength];
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.