Package org.encog.mathutil.matrices

Examples of org.encog.mathutil.matrices.Matrix


    this.outputNeuronCount = network.getOutputCount();
    this.forceWinner = false;
    setError(0);

    // setup the correction matrix
    this.correctionMatrix = new Matrix(this.outputNeuronCount,this.inputNeuronCount);

    // create the BMU class
    this.bmuUtil = new BestMatchingUnit(network);
  }
View Full Code Here


  private MLData compute(final SOM som, final MLData input) {

    final MLData result = new BasicMLData(som.getOutputCount());

    for (int i = 0; i < som.getOutputCount(); i++) {
      final Matrix optr = som.getWeights().getRow(i);
      final Matrix inputMatrix = Matrix.createRowMatrix(input.getData());
      result.setData(i, MatrixMath.dotProduct(inputMatrix, optr));
    }

    return result;
  }
View Full Code Here

    double m[][] = {
        {1,2,3,4},
        {5,6,7,8},
        {9,10,11,12},
        {13,14,15,16} };
    Matrix matrix = new Matrix(m);
    SingularValueDecomposition svd = new SingularValueDecomposition(matrix);
    Assert.assertEquals(2147483647, (int)(svd.cond()) );
    double[] d = svd.getSingularValues();
   
    Assert.assertEquals(4, d.length);
View Full Code Here

    double m1[][] = {
        {1,0,0,0},
        {0,1,0,0},
        {0,0,1,0},
        {0,0,0,1} };
    Matrix matrix1 = new Matrix(m1);
   
    double m2[][] = {
        {17,18,19,20},
        {21,22,23,24},
        {25,27,28,29},
        {37,33,31,30} };
    Matrix matrix2 = new Matrix(m2);
   
    CholeskyDecomposition c = new CholeskyDecomposition(matrix1);
    c.solve(matrix2);

    Matrix mx = c.getL();
   
    Assert.assertEquals(1.0, mx.get(0,0));
    Assert.assertEquals(1.0, mx.get(1,1));
    Assert.assertEquals(1.0, mx.get(2,2));
    Assert.assertEquals(4, mx.getRows());
    Assert.assertEquals(4, mx.getCols());
  }
View Full Code Here

    double m1[][] = {
        {1,0,0,0},
        {0,1,0,0},
        {0,0,1,0},
        {0,0,0,1} };
    Matrix matrix1 = new Matrix(m1);
     
    EigenvalueDecomposition e = new EigenvalueDecomposition(matrix1);
   
    double[] d1 = e.getImagEigenvalues();
    double[] d2 = e.getRealEigenvalues();
    Matrix mx = e.getV();
   
    Assert.assertEquals(1.0, mx.get(0,0));
    Assert.assertEquals(1.0, mx.get(1,1));
    Assert.assertEquals(1.0, mx.get(2,2));
    Assert.assertEquals(4, mx.getRows());
    Assert.assertEquals(4, mx.getCols());
  }
View Full Code Here

    double m1[][] = {
        {1,0,0,0},
        {0,1,0,0},
        {0,0,1,0},
        {1,0,0,1} };
    Matrix matrix1 = new Matrix(m1);
     
    EigenvalueDecomposition e = new EigenvalueDecomposition(matrix1);
   
    double[] d1 = e.getImagEigenvalues();
    double[] d2 = e.getRealEigenvalues();
    Matrix mx = e.getV();
   
    Assert.assertEquals(0.0, mx.get(0,0));
    Assert.assertEquals(0.0, mx.get(1,1));
    Assert.assertEquals(1.0, mx.get(2,2));
    Assert.assertEquals(4, mx.getRows());
    Assert.assertEquals(4, mx.getCols());
  }
View Full Code Here

    double m1[][] = {
        {1,0,0,0},
        {0,1,0,0},
        {0,0,1,0},
        {0,0,0,1} };
    Matrix matrix1 = new Matrix(m1);
   
    double m2[][] = {
        {17,18,19,20},
        {21,22,23,24},
        {25,27,28,29},
        {37,33,31,30} };
    Matrix matrix2 = new Matrix(m2);
   
    QRDecomposition c = new QRDecomposition(matrix1);
    Matrix mx = c.solve(matrix2);
   
    Assert.assertEquals(17.0, mx.get(0,0));
    Assert.assertEquals(22.0, mx.get(1,1));
    Assert.assertEquals(28.0, mx.get(2,2));
    Assert.assertEquals(4, mx.getRows());
    Assert.assertEquals(4, mx.getCols());
  }
View Full Code Here

  @Test
  public void testGetD_asymentric() {
    EigenvalueDecomposition decomposition =
        new EigenvalueDecomposition(matrix1);
    Matrix d = decomposition.getD();
    assertEquals(2, d.getCols());
    assertEquals(2, d.getRows());
    assertEquals(1.45, d.get(0, 0), 1e-10);
    assertEquals(1.4991664351, d.get(0, 1), 1e-10);
    assertEquals(-1.4991664351, d.get(1, 0), 1e-10);
    assertEquals(1.45, d.get(1, 1), 1e-10);
  }
View Full Code Here

  @Test
  public void testGetD_symentric() {
    EigenvalueDecomposition decomposition =
        new EigenvalueDecomposition(matrix2);
    Matrix d = decomposition.getD();
    assertEquals(2, d.getCols());
    assertEquals(2, d.getRows());
    assertEquals(-5.2008771255, d.get(0, 0), 1e-10);
    assertEquals(0.0, d.get(0, 1), 1e-10);
    assertEquals(0.0, d.get(1, 0), 1e-10);
    assertEquals(6.2008771255, d.get(1, 1), 1e-10);
  }
View Full Code Here

  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

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.