//------------------------------------------------------------ //Apply a function to every element of matrix public void map(mapFunc delegateFunction) { for (int i = 0; i < rows; ++i) { for (int j = 0; j < cols; ++j) { data[i, j] = delegateFunction(data[i, j]); } } }
//Apply a function to every element of matrix public static Matrix map(Matrix m, mapFunc delegateFunction) { Matrix result = new Matrix(m.rows, m.cols); for (int i = 0; i < m.rows; ++i) { for (int j = 0; j < m.cols; ++j) { result.data[i, j] = delegateFunction(m.data[i, j]); } } return(result); }