Package org.encog.mathutil.matrices

Examples of org.encog.mathutil.matrices.Matrix


    double m[][] = {
        {1,2,3,4},
        {5,6,7,8},
        {9,10,11,12},
        {13,14,15,16} };
    Matrix matrix = new Matrix(m);
    TestCase.assertEquals(matrix.getRows(), 4);
    TestCase.assertEquals(matrix.getCols(), 4);
  }
View Full Code Here


   
    double m2[][] = {
        {0,2},
        {3,4} }
 
    Matrix matrix1 = new Matrix(m1);
    Matrix matrix2 = new Matrix(m1);
   
    TestCase.assertTrue(matrix1.equals(matrix2));
   
    matrix2 = new Matrix(m2);
   
    TestCase.assertFalse(matrix1.equals(matrix2));
  }
View Full Code Here

   
    double m2[][] = {
        {1.123,2.123},
        {3.123,4.123} };
   
    Matrix matrix1 = new Matrix(m1);
    Matrix matrix2 = new Matrix(m2);
   
    TestCase.assertTrue(matrix1.equals(matrix2,3));
    TestCase.assertFalse(matrix1.equals(matrix2,4));
   
    double m3[][] = {
        {1.1,2.1},
        {3.1,4.1} };
   
    double m4[][] = {
        {1.2,2.1},
        {3.1,4.1} };
   
    Matrix matrix3 = new Matrix(m3);
    Matrix matrix4 = new Matrix(m4);
    TestCase.assertTrue(matrix3.equals(matrix4,0));
    TestCase.assertFalse(matrix3.equals(matrix4,1));
   
    try
    {
View Full Code Here

    double c[][] = {
        {5,1},
        {4,2}
    };
   
    Matrix matrixA = new Matrix(a);
    Matrix matrixB = new Matrix(b);
    Matrix matrixC = new Matrix(c);
   
    Matrix result = matrixA.clone();
    result = MatrixMath.multiply(matrixA,matrixB);

    TestCase.assertTrue(result.equals(matrixC));
   
    double a2[][] = {
        {1,2,3,4},
        {5,6,7,8}
    };
   
    double b2[][] = {
        {1,2,3},
        {4,5,6},
        {7,8,9},
        {10,11,12}
    };
   
    double c2[][] = {
        {70,80,90},
        {158,184,210}
    };
   
    matrixA = new Matrix(a2);
    matrixB = new Matrix(b2);
    matrixC = new Matrix(c2);
   
    result = MatrixMath.multiply(matrixA, matrixB);
    TestCase.assertTrue(result.equals(matrixC));
   
    result = matrixB.clone();
    try
    {
      MatrixMath.multiply(matrixB,matrixA);
View Full Code Here

    double matrixDataDouble[][] = {
        {1.0,-1.0},
        {-1.0,1.0},
    };
   
    Matrix matrixBoolean = new Matrix(matrixDataBoolean);
    Matrix matrixDouble = new Matrix(matrixDataDouble);
   
    TestCase.assertTrue(matrixBoolean.equals(matrixDouble));
  }
View Full Code Here

    };
    double matrixData2[][] = {
        {3.0,4.0}
    };
   
    Matrix matrix1 = new Matrix(matrixData1);
    Matrix matrix2 = new Matrix(matrixData2);
   
    Matrix matrixRow = matrix1.getRow(1);
    TestCase.assertTrue(matrixRow.equals(matrix2));
   
    try
    {
      matrix1.getRow(3);
      TestCase.assertTrue(false);
View Full Code Here

    double matrixData2[][] = {
        {2.0},
        {4.0}
    };
   
    Matrix matrix1 = new Matrix(matrixData1);
    Matrix matrix2 = new Matrix(matrixData2);
   
    Matrix matrixCol = matrix1.getCol(1);
    TestCase.assertTrue(matrixCol.equals(matrix2));
   
    try
    {
      matrix1.getCol(3);
      TestCase.assertTrue(false);
View Full Code Here

  }
 
  public void testZero() throws Throwable
  {
    double doubleData[][] = { {0,0}, {0,0} };
    Matrix matrix = new Matrix(doubleData);
    TestCase.assertTrue(matrix.isZero());
  }
View Full Code Here

  }
 
  public void testSum() throws Throwable
  {
    double doubleData[][] = { {1,2}, {3,4} };
    Matrix matrix = new Matrix(doubleData);
    TestCase.assertEquals((int)matrix.sum(), 1+2+3+4);
  }
View Full Code Here

  }
 
  public void testRowMatrix() throws Throwable
  {
    double matrixData[] = {1.0,2.0,3.0,4.0};
    Matrix matrix = Matrix.createRowMatrix(matrixData);
    TestCase.assertEquals(matrix.get(0,0), 1.0);
    TestCase.assertEquals(matrix.get(0,1), 2.0);
    TestCase.assertEquals(matrix.get(0,2), 3.0);
    TestCase.assertEquals(matrix.get(0,3), 4.0);
  }
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.