Exemplo n.º 1
0
        public Matrix invoke(MatrixPerElementProduct oper, Matrix m2)
        {
            if ((cols != m2.cols) || (rows != m2.rows))
            {
                throw new InvalidOperationException("Trying to invoke element-wise operation on matrices" +
                                                    "with non-matching dimensions");
            }

            Matrix result = new Matrix(rows, cols);

            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < cols; j++)
                {
                    result[i, j] = oper.Invoke(_mat[i, j], m2[i, j]);
                }
            }

            return(result);
        }
Exemplo n.º 2
0
 public static Matrix invoke(MatrixPerElementProduct oper, Matrix m1, Matrix m2)
 {
     return(m1.invoke(oper, m2));
 }