Click or drag to resize

DoubleMatrixNegate Method

Determines the negation of a matrix.

Namespace:  Novacta.Analytics
Assembly:  Novacta.Analytics (in Novacta.Analytics.dll) Version: 2.0.0
Syntax
public static DoubleMatrix Negate(
	DoubleMatrix matrix
)

Parameters

matrix
Type: Novacta.AnalyticsDoubleMatrix
The operand.

Return Value

Type: DoubleMatrix
The result of negating matrix.
Exceptions
ExceptionCondition
ArgumentNullExceptionmatrix is null.
Remarks

Let LaTeX equation and LaTeX equation be the matrix number of rows and columns, respectively, and consider its generic entry

LaTeX equation

The method returns a matrix having the same dimensions of matrix, whose generic entry is:

LaTeX equation

Examples

In the following example, some matrices are negated.

C#
using System;

namespace Novacta.Analytics.CodeExamples
{
    public class NegationExample0  
    {
        public void Main()
        {
            // Create the operand.
            var data = new double[6] {
                0,  2,  4,
                1,  3,  5,
            };
            var operand = DoubleMatrix.Dense(2, 3, data, StorageOrder.RowMajor);
            Console.WriteLine("operand =");
            Console.WriteLine(operand);

            // Compute the negation of operand.
            var result = - operand;

            Console.WriteLine();
            Console.WriteLine("- operand =");
            Console.WriteLine(result);

            // In .NET languages that do not support overloaded operators,
            // you can use the alternative methods named Negate.
            result = DoubleMatrix.Negate(operand);

            Console.WriteLine();
            Console.WriteLine("DoubleMatrix.Negate(operand) returns");
            Console.WriteLine();
            Console.WriteLine(result);

            // Both operators and alternative methods are overloaded to 
            // support read-only matrix arguments.
            // Compute the negation using a read-only wrapper of operand.
            ReadOnlyDoubleMatrix readOnlyOperand = operand.AsReadOnly();
            result = - readOnlyOperand;

            Console.WriteLine();
            Console.WriteLine("- readOnlyOperand =");
            Console.WriteLine(result);
        }
    }
}

// Executing method Main() produces the following output:
// 
// operand =
// 0                2                4                
// 1                3                5                
// 
// 
// 
// - operand =
// -0               -2               -4               
// -1               -3               -5               
// 
// 
// 
// DoubleMatrix.Negate(operand) returns
// 
// -0               -2               -4               
// -1               -3               -5               
// 
// 
// 
// - readOnlyOperand =
// -0               -2               -4               
// -1               -3               -5               
// 

See Also