I have posted this in the syntax section but I m not sure if it the good section so I also post here.
I'm trying at present to construct classes presented by jeff heaton in his book introduction to neural network for java : http://www.heatonresearch.com/online/introduction-neural-networks-java-edition-2...
Those classes are useful for every example of neural network jeff heaton give in his book so I need them anyway.
Here is what I tried to do(probably an aberration):
Code:
Code:class Matrix
{
private int r;
private int c;
private double[][] M;
public Matrix(final double[][]input)
{
M = input;
}
public void add(int row, int col, double value)
{
r = row;
c = col;
for(int i = 0; i<r; i++){
for(int j = 0; j<c; j++){
M[i][j] = value;
}
}
}
}
public static class MatrixMath{
public static Matrix add(final Matrix m1,final Matrix m2)
{
final double result[][] = new double[m1.getRows()][m1.getCols()];
for (int resultRow = 0; resultRow < m1.getRows(); resultRow++) {
for (int resultCol = 0; resultCol < m1.getCols(); resultCol++) {
result[resultRow][resultCol] = m1.get(resultRow, resultCol)+ m2.get(resultRow, resultCol);
}
}
return new Matrix(result);
}
}
Does someone have an idea how I could define my classes?
Especially MatrixMath class, I don't know how to deal with.
Jeff Heaton don't talk about constructor and use only static methods in this class. What I made is probably stupid but I don't know where.
thanks,
théo