Package org.encog.mathutil.matrices

Examples of org.encog.mathutil.matrices.Matrix


  public static void testVerifySame()
  {
    double dataBase[][] = {{1.0,2.0},{3.0,4.0}};
    double dataTooManyRows[][] = {{1.0,2.0},{3.0,4.0},{5.0,6.0}};
    double dataTooManyCols[][] = {{1.0,2.0,3.0},{4.0,5.0,6.0}};
    Matrix base = new Matrix(dataBase);
    Matrix tooManyRows = new Matrix(dataTooManyRows);
    Matrix tooManyCols = new Matrix(dataTooManyCols);
    MatrixMath.add(base, base);
    try
    {
      MatrixMath.add(base, tooManyRows);
      TestCase.assertFalse(true);
View Full Code Here


  }
 
  public void testDivide() throws Throwable
  {
    double data[][] = {{2.0,4.0},{6.0,8.0}};
    Matrix matrix = new Matrix(data);
    Matrix result = MatrixMath.divide(matrix, 2.0);
    TestCase.assertEquals(1.0, result.get(0,0));
  }
View Full Code Here

    {
     
    }
   
    double checkData[][] = {{1,0},{0,1}};
    Matrix check = new Matrix(checkData);
    Matrix matrix = MatrixMath.identity(2);
    TestCase.assertTrue(check.equals(matrix));
  }
View Full Code Here

  }
 
  public void testMultiplyScalar() throws Throwable
  {
    double data[][] = {{2.0,4.0},{6.0,8.0}};
    Matrix matrix = new Matrix(data);
    Matrix result = MatrixMath.multiply(matrix, 2.0);
    TestCase.assertEquals(4.0, result.get(0,0));
  }
View Full Code Here

 
  public void testDeleteRow() throws Throwable
  {
    double origData[][] = {{1.0,2.0},{3.0,4.0}};
    double checkData[][] = {{3.0,4.0}};
    Matrix orig = new Matrix(origData);
    Matrix matrix = MatrixMath.deleteRow(orig, 0);
    Matrix check = new Matrix(checkData);
    TestCase.assertTrue(check.equals(matrix));
   
    try
    {
      MatrixMath.deleteRow(orig, 10);
      TestCase.assertTrue(false);
View Full Code Here

 
  public void testDeleteCol() throws Throwable
  {   
    double origData[][] = {{1.0,2.0},{3.0,4.0}};
    double checkData[][] = {{2.0},{4.0}};
    Matrix orig = new Matrix(origData);
    Matrix matrix = MatrixMath.deleteCol(orig, 0);
    Matrix check = new Matrix(checkData);
    TestCase.assertTrue(check.equals(matrix));
   
    try
    {
      MatrixMath.deleteCol(orig, 10);
      TestCase.assertTrue(false);
View Full Code Here

  }
 
  public void testCopy()
  {
    double data[][] = {{1.0,2.0},{3.0,4.0}};
    Matrix source = new Matrix(data);
    Matrix target = new Matrix(2,2);
    MatrixMath.copy(source, target);
    TestCase.assertTrue(source.equals(target));
  }
View Full Code Here

public class TestMatrix extends TestCase {
 
  public void testRowsAndCols() throws Throwable
  {
    Matrix matrix = new Matrix(6,3);
    TestCase.assertEquals(matrix.getRows(), 6);
    TestCase.assertEquals(matrix.getCols(), 3);
   
    matrix.set(1,2, 1.5);
    TestCase.assertEquals(matrix.get(1,2), 1.5 );
  }
View Full Code Here

    TestCase.assertEquals(matrix.get(1,2), 1.5 );
  }
 
  public void testRowAndColRangeUnder() throws Throwable
  {
    Matrix matrix = new Matrix(6,3);
   
    // make sure set registers error on under-bound row
    try {
      matrix.set(-1, 0, 1);
      TestCase.assertTrue(false); // should have thrown an exception
    }
    catch(MatrixError e)
    {
    }
   
    // make sure set registers error on under-bound col
    try {
      matrix.set(0, -1, 1);
      TestCase.assertTrue(false); // should have thrown an exception
    }
    catch(MatrixError e)
    {
    }
   
    // make sure get registers error on under-bound row
    try {
      matrix.get(-1, 0 );
      TestCase.assertTrue(false); // should have thrown an exception
    }
    catch(MatrixError e)
    {
    }
   
    // make sure set registers error on under-bound col
    try {
      matrix.get(0, -1 );
      TestCase.assertTrue(false); // should have thrown an exception
    }
    catch(MatrixError e)
    {
    }
View Full Code Here

    }
  }
 
  public void testRowAndColRangeOver() throws Throwable
  {
    Matrix matrix = new Matrix(6,3);
   
    // make sure set registers error on under-bound row
    try {
      matrix.set(6, 0, 1);
      TestCase.assertTrue(false); // should have thrown an exception
    }
    catch(MatrixError e)
    {
    }
   
    // make sure set registers error on under-bound col
    try {
      matrix.set(0, 3, 1);
      TestCase.assertTrue(false); // should have thrown an exception
    }
    catch(MatrixError e)
    {
    }
   
    // make sure get registers error on under-bound row
    try {
      matrix.get(6, 0 );
      TestCase.assertTrue(false); // should have thrown an exception
    }
    catch(MatrixError e)
    {
    }
   
    // make sure set registers error on under-bound col
    try {
      matrix.get(0, 3 );
      TestCase.assertTrue(false); // should have thrown an exception
    }
    catch(MatrixError e)
    {
    }
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.