Click or drag to resize

ComplexMatrixDivide Method (ComplexMatrix, ComplexMatrix)

Determines the division of a matrix by another.

Namespace:  Novacta.Analytics
Assembly:  Novacta.Analytics (in Novacta.Analytics.dll) Version: 2.0.0
Syntax
public static ComplexMatrix Divide(
	ComplexMatrix left,
	ComplexMatrix right
)

Parameters

left
Type: Novacta.AnalyticsComplexMatrix
The left operand.
right
Type: Novacta.AnalyticsComplexMatrix
The right operand.

Return Value

Type: ComplexMatrix
The result of dividing left by right.
Exceptions
ExceptionCondition
ArgumentNullExceptionleft is null.
-or-
right is null.
ArgumentException Both left and right are not scalar matrices, and any of the following conditions holds true:
  • left and right have not the same number of columns;
  • right is not square and has not full rank.
Remarks

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

LaTeX equation

Analogously, Let LaTeX equation and LaTeX equation be the right number of rows and columns, respectively, and let its generic entry given by

LaTeX equation

The method operates as follows.

  • If left is scalar, then the method returns a matrix having the same dimensions of right, whose generic entry is:

    LaTeX equation

  • If right is scalar, then the method returns a matrix having the same dimensions of left, whose generic entry is:

    LaTeX equation

  • If neither left nor right is scalar, then the method interprets the division of left by right as the solution LaTeX equation of the following system of simultaneous equations:

    LaTeX equation

    provided that both left and right have the same number of columns; otherwise, an exception is thrown.

    If right is square, then the solution is computed differently for specific patterns. More thoroughly, if right is upper or lower triangular, then a back or forward substitution algorithm is executed, respectively, or, if right is symmetric, a Cholesky decomposition is tentatively applied; in every other case, the solution is obtained by LU decomposition of matrix right.

    If right is not square, then the solution is computed by QR or LQ factorization of right, provided that it has full rank; otherwise, an exception is thrown.

Examples

In the following example, the division of a matrix by another is computed.

C#
using System;
using System.Numerics;

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

            // Create the right operand.
            data = new Complex[6] {
                new Complex(1, -1), new Complex(5, -5),
                new Complex(2, -2), new Complex(6, -6),
                new Complex(3, -3), new Complex(7, -7)
            };
            var right = ComplexMatrix.Dense(3, 2, data, StorageOrder.RowMajor);
            Console.WriteLine("right =");
            Console.WriteLine(right);

            // Divide left by right.
            var result = left / right;

            Console.WriteLine();
            Console.WriteLine("left / right =");
            Console.WriteLine(result);

            // In .NET languages that do not support overloaded operators,
            // you can use the alternative methods named Divide.
            result = ComplexMatrix.Divide(left, right);

            Console.WriteLine();
            Console.WriteLine("ComplexMatrix.Divide(left, right) returns");
            Console.WriteLine();
            Console.WriteLine(result);

            // Both operators and alternative methods are overloaded to 
            // support read-only matrix arguments.
            // Compute the division using a read-only wrapper of left.
            ReadOnlyComplexMatrix readOnlyLeft = left.AsReadOnly();
            result = readOnlyLeft / right;

            Console.WriteLine();
            Console.WriteLine("readOnlyLeft / right =");
            Console.WriteLine(result);
        }
    }
}

// Executing method Main() produces the following output:
// 
// left =
// (                0,                0) (                2,                2) 
// (                1,                1) (                3,                3) 
// 
// 
// right =
// (                1,               -1) (                5,               -5) 
// (                2,               -2) (                6,               -6) 
// (                3,               -3) (                7,               -7) 
// 
// 
// 
// left / right =
// (   1.50861996e-16,      0.666666667) (  -9.09236669e-17,      0.166666667) (  -1.08629925e-16,     -0.333333333) 
// (   8.32667268e-17,      0.166666667) (  -7.95662803e-18,      0.166666667) (  -6.05071994e-17,      0.166666667) 
// 
// 
// 
// ComplexMatrix.Divide(left, right) returns
// 
// (   1.50861996e-16,      0.666666667) (  -9.09236669e-17,      0.166666667) (  -1.08629925e-16,     -0.333333333) 
// (   8.32667268e-17,      0.166666667) (  -7.95662803e-18,      0.166666667) (  -6.05071994e-17,      0.166666667) 
// 
// 
// 
// readOnlyLeft / right =
// (   1.50861996e-16,      0.666666667) (  -9.09236669e-17,      0.166666667) (  -1.08629925e-16,     -0.333333333) 
// (   8.32667268e-17,      0.166666667) (  -7.95662803e-18,      0.166666667) (  -6.05071994e-17,      0.166666667) 
// 

See Also