public double[] Evaluate(double[] Inputs, INeatNetwork network) { IMatrix <double> propogated = new Double.Matrix(Inputs.Length, 1, Inputs); for (int i = 0; i < network.Matrices.Length; i++) { propogated = Propogator.Forward(network.Matrices[i], propogated, Activator); } return(propogated.ToOneDimension()); }
public void Double() { IMatrix <double> left = new Double.Matrix(2, 2, new double[] { 1, 2, 3, 4 }); IMatrix <double> right = new Double.Matrix(2, 2, new double[] { 4, 3, 2, 1 }); IMatrix <double> leftStored = left.Duplicate(); IMatrix <double> rightStored = right.Duplicate(); // subtract IMatrix <double> result = 2.0d + left; result -= 1.0d; // make sure the originals match the stored versions Assert.Equal(leftStored, left); Assert.Equal(rightStored, right); // chaneg a value in the result and verify that the result is a value and not a reference to the roginal matrix result[0, 0] = -1; Assert.Equal(leftStored, left); Assert.Equal(rightStored, right); // change values in the original and make sure that the equality comparisons are properly working left[0, 0] = -1; right[0, 0] = 2; Assert.NotEqual(leftStored, left); Assert.NotEqual(rightStored, right); // make sure the + oppertaor throws with ivalid matrices left = new Double.Matrix(2, 3, 7); void ShouldThrow() { var x = left + right; } Assert.Throws <InvalidOperationException>(ShouldThrow); }