public function testInverse()
 {
     $matrixData1 = [[1, 2, 3, 4]];
     $matrixData2 = [[1], [2], [3], [4]];
     $matrix1 = Matrix::matrixFromDoubles($matrixData1);
     $checkMatrix = Matrix::matrixFromDoubles($matrixData2);
     $matrix2 = MatrixMath\transpose($matrix1);
     $this->assertTrue($matrix2->equals($checkMatrix));
 }
 /**
  * Train the neural network for the specified pattern.
  * The neural network
  * can be trained for more than one pattern. To do this simply call the
  * train method more than once.
  *
  * @param
  *        	MLData pattern
  *        	The pattern to train for.
  */
 public function addPattern(MLData $pattern)
 {
     if ($pattern->size() != $this->getNeuronCount()) {
         throw new NeuralNetworkError("Network with " + $this->getNeuronCount() + " neurons, cannot learn a pattern of size " + $pattern->size());
     }
     // Create a row matrix from the input, convert boolean to bipolar
     $m2 = Matrix::createRowMatrix($pattern->getData());
     // Transpose the matrix and multiply by the original input matrix
     $m1 = MatrixMath\transpose($m2);
     $m3 = MatrixMath\multiply($m1, $m2);
     // matrix 3 should be square by now, so create an identity
     // matrix of the same size.
     $identity = MatrixMath\identity($m3->getRows());
     // subtract the identity matrix
     $m4 = MatrixMath\subtract($m3, $identity);
     // now add the calculated matrix, for this pattern, to the
     // existing weight matrix.
     $this->convertHopfieldMatrix($m4);
 }