Encog.MathUtil.Matrices.Matrix.IsZero C# (CSharp) Method

IsZero() public method

Determine if all of the values in the matrix are zero.
public IsZero ( ) : bool
return bool
        public bool IsZero()
        {
            for (int row = 0; row < Rows; row++)
            {
                for (int col = 0; col < Cols; col++)
                {
                    if (matrix[row][col] != 0)
                    {
                        return false;
                    }
                }
            }
            return true;
        }

Usage Example

Example #1
0
        public void IsZero()
        {
            double[] matrixData = { 1.0, 2.0, 3.0, 4.0 };
            Matrix   matrix     = Matrix.CreateColumnMatrix(matrixData);

            Assert.IsFalse(matrix.IsZero());
            double[] matrixData2 = { 0.0, 0.0, 0.0, 0.0 };
            Matrix   matrix2     = Matrix.CreateColumnMatrix(matrixData2);

            Assert.IsTrue(matrix2.IsZero());
        }
All Usage Examples Of Encog.MathUtil.Matrices.Matrix::IsZero