Click or drag to resize

ComplexMatrixInPlaceApply Method

Evaluates the specified function at each entry of this instance, and substitutes each entry with its corresponding function value.

Namespace:  Novacta.Analytics
Assembly:  Novacta.Analytics (in Novacta.Analytics.dll) Version: 2.0.0
Syntax
public void InPlaceApply(
	Func<Complex, Complex> func
)

Parameters

func
Type: SystemFuncComplex, Complex
The function to apply to each matrix entry.
Exceptions
ExceptionCondition
ArgumentNullExceptionfunc is null.
Remarks

Let LaTeX equation be a matrix, and consider its generic entry

LaTeX equation

where LaTeX equation and LaTeX equation are the number of rows and columns of LaTeX equation, respectively.

Let LaTeX equation the function represented by func. Then method InPlaceApply(FuncComplex, Complex) transforms LaTeX equation by setting LaTeX equation

Examples

In the following example, the entries in a matrix are all squared.

C#
using System;
using System.Numerics;

namespace Novacta.Analytics.CodeExamples
{
    public class ComplexInPlaceApplyExample0  
    {
        public void Main()
        {
            // Create a matrix.
            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 matrix = ComplexMatrix.Dense(3, 2, data, StorageOrder.RowMajor);
            Console.WriteLine("Initial data matrix:");
            Console.WriteLine(matrix);

            // Square all matrix entries.
            matrix.InPlaceApply((x) => x*x);

            Console.WriteLine();
            Console.WriteLine("Matrix transformed by squaring its entries:");
            Console.WriteLine(matrix);
        }
    }
}

// Executing method Main() produces the following output:
// 
// Initial data matrix:
// (                1,               -1) (                5,               -5) 
// (                2,               -2) (                6,               -6) 
// (                3,               -3) (                7,               -7) 
// 
// 
// 
// Matrix transformed by squaring its entries:
// (                0,               -2) (                0,              -50) 
// (                0,               -8) (                0,              -72) 
// (                0,              -18) (                0,              -98) 
// 

See Also