.NET Matrix Library
CMatrix Constructor
See Also  Example Send Feedback



Initializes a new instance of the CMatrix class. Initializes a new instance of the CMatrix class.

Overload List

OverloadDescription
CMatrix Constructor(Matrix,Matrix)Initializes a new instance of the CMatrix class and initializes the real and imaginary parts of its complex elements using the values from two Matrix objects .  
CMatrix Constructor(Int32,Int32,Complex)Initializes a new instance of the CMatrix class specifying the number of rows and columns of the newly created matrix, initializing its diagonal elements to the specified complex value.  
CMatrix Constructor(Int32,Int32)Initializes a new instance of the CMatrix class specifying the number of rows and columns of the newly created matrix.  
CMatrix Constructor(Complex[,],Int32,Int32)Initializes a new instance of the CMatrix class using the contents of a two dimensional complex array specifying the size of the newly created matrix.  
CMatrix Constructor(Complex[,])Initializes a new instance of the CMatrix class using the contents of a two dimensional complex array.  
CMatrix Constructor(Complex[],Int32,Int32)Initializes a new instance of the CMatrix class using the content of a one-dimensional array.  
CMatrix Constructor(Complex[],Int32,Int32,StorageOrder)Initializes a new instance of the CMatrix class using the content of a one-dimensional array.  
CMatrix Constructor(CMatrix)Initializes a new instance of the CMatrix class copying the content of an existing matrix.  
CMatrix Constructor()Initializes a new instance of the CMatrix class creating a complex 3x3 matrix.  

Example

The following example shows various ways to initialize complex matrices (CMatrix objects).
Visual BasicCopy Code
Imports System
Imports System.Numerics
Imports Bluebit.MatrixLibrary



Class Test

    Public Shared Sub Main()

        'Declaring a 4x4 Matrix with all elements initialized to 0
        Dim A As New CMatrix(4, 4)
        Console.WriteLine("CMatrix A:")
        Console.WriteLine(A)

        'Declaring a 3x3 unary matrix 
        Dim B As New CMatrix(3, 3, New Complex(1, 0))
        Console.WriteLine("CMatrix B:")
        Console.WriteLine(B)

        'Copy constructor - Matrix C will copy the elements of matrix B
        Dim C As New CMatrix(B)
        Console.WriteLine("CMatrix.C")
        Console.WriteLine(C)

        'Declaring an Complex array ...
        Dim cArray(1, 1) As Complex
        cArray(0, 0) = New Complex(1.234, 2.345)
        cArray(0, 1) = New Complex(3.456, 4.567)
        cArray(1, 0) = New Complex(5.678, 6.789)
        cArray(1, 1) = New Complex(7.891, 8.912)
        ' ... and creating a Matrix using its content
        Dim D As New CMatrix(cArray)
        Console.WriteLine("Matrix D:")
        Console.WriteLine(D)

        Console.Read()
    End Sub

End Class
C#Copy Code
using System;
using System.Numerics;
using Bluebit.MatrixLibrary;

class Test
{

	static void Main(string[] args)
	{

       //Declaring a 4x4 Matrix with all elements initialized to 0
        CMatrix A = new CMatrix(4, 4);
        Console.WriteLine("CMatrix A:");
        Console.WriteLine(A);

        //Declaring a 3x3 unary matrix 
        CMatrix  B  = new CMatrix(3, 3, new Complex(1, 0));
        Console.WriteLine("CMatrix B:");
        Console.WriteLine(B);

        //Copy constructor - Matrix C will copy the elements of matrix B
        CMatrix  C = new CMatrix(B);
        Console.WriteLine("CMatrix.C");
        Console.WriteLine(C);

        //Declaring an Complex array ...
        Complex[,] cArray = new Complex[2,2];
        cArray[0, 0] = new Complex(1.234, 2.345);
        cArray[0, 1] = new Complex(3.456, 4.567);
        cArray[1, 0] = new Complex(5.678, 6.789);
        cArray[1, 1] = new Complex(7.891, 8.912);
        // ... and creating a Matrix using its content
        CMatrix D = new CMatrix(cArray);
        Console.WriteLine("Matrix D:");
        Console.WriteLine(D);

        Console.Read();
	}
}
C++Copy Code
#include "stdafx.h"

using namespace System;
using namespace System::Numerics;
using namespace Bluebit::MatrixLibrary;

int main(array<System::String ^> ^args)
{
       //Declaring a 4x4 Matrix with all elements initialized to 0
        CMatrix	^A = gcnew CMatrix(4, 4);
        Console::WriteLine("CMatrix A:");
        Console::WriteLine(A);

        //Declaring a 3x3 unary matrix 
        CMatrix	^B  = gcnew CMatrix(3, 3, Complex(1.0, 0.0));
        Console::WriteLine("CMatrix B:");
        Console::WriteLine(B);

        //Copy constructor - Matrix C will copy the elements of matrix B
        CMatrix ^C = gcnew CMatrix(B);
        Console::WriteLine("CMatrix.C");
        Console::WriteLine(C);

        //Declaring a complex array ...
		array<Complex,2> ^cArray = gcnew array<Complex,2>(2,2);
        cArray[0, 0] = Complex(1.234, 2.345);
        cArray[0, 1] = Complex(3.456, 4.567);
        cArray[1, 0] = Complex(5.678, 6.789);
        cArray[1, 1] = Complex(7.891, 8.912);
        // ... and creating a Matrix using its content
        CMatrix^ D = gcnew CMatrix(cArray);
        Console::WriteLine("Matrix D:");
        Console::WriteLine(D);

        Console::Read();
    
	return 0;
}

Requirements

Target Platforms: Windows 2000, Windows XP, Windows Server 2003 family, Windows Vista, Windows Server 2008 family, Windows 7

See Also

.NET Matrix Library