Click or drag to resize

ComplexMatrixElementWiseMultiply Method (ComplexMatrix, ComplexMatrix)

Determines the element wise product of two matrices.

Namespace:  Novacta.Analytics
Assembly:  Novacta.Analytics (in Novacta.Analytics.dll) Version: 2.0.0
Syntax
public static ComplexMatrix ElementWiseMultiply(
	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 element wise multiplying left by right.
Exceptions
ExceptionCondition
ArgumentNullExceptionleft is null.
-or-
right is null.
ArgumentExceptionleft and right have not the same number of rows and columns.
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 returns a matrix whose generic entry is

LaTeX equation

provided that the dimensions of left agree with those of right; otherwise, an exception is thrown.

Examples

In the following example, some matrices are element wise multiplied.

C#
using System;
using System.Numerics;

namespace Novacta.Analytics.CodeExamples
{
    public class ComplexElementWiseMultiplyExample0  
    {
        public void Main()
        {
            // Create the left operand.
            var 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 left = ComplexMatrix.Dense(3, 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);

            // Element wise multiply left by right.
            var result = ComplexMatrix.ElementWiseMultiply(left, right);

            Console.WriteLine();
            Console.WriteLine("Element wise multiplication: left * right =");
            Console.WriteLine(result);

            // Class ReadOnlyComplexMatrix supports element wise multiplications
            // where some arguments are read-only matrices.
            // Compute the product using a read-only wrapper of left.
            ReadOnlyComplexMatrix readOnlyLeft = left.AsReadOnly();
            result = ReadOnlyComplexMatrix.ElementWiseMultiply(readOnlyLeft, right);

            Console.WriteLine();
            Console.WriteLine("Element wise multiplication: readOnlyLeft * right =");
            Console.WriteLine(result);
        }
    }
}

// Executing method Main() produces the following output:
// 
// left =
// (                1,               -1) (                5,               -5) 
// (                2,               -2) (                6,               -6) 
// (                3,               -3) (                7,               -7) 
// 
// 
// right =
// (               -1,                1) (               -5,                5) 
// (               -2,                2) (               -6,                6) 
// (               -3,                3) (               -7,                7) 
// 
// 
// 
// Element wise multiplication: left * right =
// (                0,                2) (                0,               50) 
// (                0,                8) (                0,               72) 
// (                0,               18) (                0,               98) 
// 
// 
// 
// Element wise multiplication: readOnlyLeft * right =
// (                0,                2) (                0,               50) 
// (                0,                8) (                0,               72) 
// (                0,               18) (                0,               98) 
// 

See Also