internal static ComplexNumber[] DiagonalShoArrayToArray(ComplexArray shoArray)
        {
            ComplexNumber[,] asMatrix = ShoArrayToArray(shoArray);
            ComplexNumber[] result = new ComplexNumber[shoArray.Size()[0]];

            for (int i = 0; i < result.Length; i++)
            {
                result[i] = asMatrix[i, i];
            }
            return(result);
        }
示例#2
0
        /**
         *  Perform a 2D FFT inplace given a complex 2D array
         *  The direction dir, 1 for forward, -1 for reverse
         *  The size of the array (nx,ny)
         *  Return false if there are memory problems or
         *  the dimensions are not powers of 2
         */
        public static ComplexNumber[,] fft2d(ComplexNumber[,] c, int nx, int ny, EnumDirection direction)
        {
            int i, j;
            int m;//Power of 2 for current number of points

            double [] real;
            double [] imag;
            ComplexNumber [,] output; //=new COMPLEX [nx,ny];
            output = c;               // Copying Array
            // Transform the Rows
            real = new double[nx];
            imag = new double[nx];

            for (j = 0; j < ny; j++)
            {
                for (i = 0; i < nx; i++)
                {
                    real[i] = c[i, j].real;
                    imag[i] = c[i, j].imag;
                }
                // Calling 1D FFT Function for Rows
                m = (int)System.Math.Log((double)nx, 2);//Finding power of 2 for current number of points e.g. for nx=512 m=9
                fft1d(direction, m, ref real, ref imag);

                for (i = 0; i < nx; i++)
                {
                    output[i, j].real = real[i];
                    output[i, j].imag = imag[i];
                }
            }
            // Transform the columns
            real = new double[ny];
            imag = new double[ny];

            for (i = 0; i < nx; i++)
            {
                for (j = 0; j < ny; j++)
                {
                    real[j] = output[i, j].real;
                    imag[j] = output[i, j].imag;
                }
                // Calling 1D FFT Function for Columns
                m = (int)System.Math.Log((double)ny, 2);//Finding power of 2 for current number of points e.g. for nx=512 m=9
                fft1d(direction, m, ref real, ref imag);
                for (j = 0; j < ny; j++)
                {
                    output[i, j].real = real[j];
                    output[i, j].imag = imag[j];
                }
            }

            return(output);
        }
        /*======================================================================================================
         * Function:   GetRow
         * Arguments:  One matrix made of complex numbers and one row number
         * Returns:    One array made of complex numbers
         */

        private ComplexNumber[] GetRow(ComplexNumber[,] complexMatrix, int rowNumber)
        {
            // Initialize a new array
            ComplexNumber[] newArray = new ComplexNumber[complexMatrix.GetLength(1)];

            // Select each element in a specific row of the matrix and store into the new array
            for (int i = 0; i < complexMatrix.GetLength(1); i++)
            {
                newArray[i] = complexMatrix[rowNumber, i];
            }

            // Return the new array
            return(newArray);
        }
        /*======================================================================================================
         * Function:   GetColumn
         * Arguments:  One matrix made of complex numbers and one column number
         * Returns:    One array made of complex numbers
         */

        private ComplexNumber[] GetColumn(ComplexNumber[,] complexArray, int colNumber)
        {
            // Initialize a new array
            ComplexNumber[] newArray = new ComplexNumber[complexArray.GetLength(0)];

            // Select each element in a specific column of the matrix and store into the new array
            for (int i = 0; i < complexArray.GetLength(0); i++)
            {
                newArray[i] = complexArray[i, colNumber];
            }

            // Return the new array
            return(newArray);
        }
示例#5
0
        /*======================================================================================================
         * Function:   GetColumn
         * Arguments:  One matrix made of complex numbers and one column number
         * Returns:    One vector made of complex numbers
         */

        private ComplexNumber[] GetColumn(ComplexNumber[,] complexVector, int colNumber)
        {
            // Initialize a new vector
            ComplexNumber[] newVector = new ComplexNumber[complexVector.GetLength(0)];

            // Select each element in a specific column of the matrix and store into the new vector
            for (int i = 0; i < complexVector.GetLength(0); i++)
            {
                newVector[i] = complexVector[i, colNumber];
            }

            // Return the new vector
            return(newVector);
        }
示例#6
0
        /// <summary>
        /// Calculate Fast Fourier Transform of Input Image
        /// </summary>
        public void doFft(EnumDirection direction)
        {
            int directionAsInt;

            if (direction == EnumDirection.FORWARD)
            {
                directionAsInt = 1;
            }
            else
            {
                directionAsInt = -1;
            }

            //Initializing Fourier Transform Array
            //int i,j;
            /****Fourier =new ComplexNumber [Width,Height];****/
            Output = new ComplexNumber[Width, Height];
            //Copy Image Data to the Complex Array

            /***for (i=0;i<=Width -1;i++)
             *  for (j = 0; j <= Height - 1; j++)
             *  {
             *      Fourier[i, j].real =(double) GreyImage[i, j];
             *      Fourier[i, j].imag = 0;
             *  }***/
            //Calling Forward Fourier Transform
            Output = fft2d(Fourier, nx, ny, direction);

            if (direction == EnumDirection.BACKWARD)
            {
                int x, y;

                inverseResult = new double[Width, Height];

                for (y = 0; y < Height; y++)
                {
                    for (x = 0; x < Width; x++)
                    {
                        inverseResult[x, y] = Output[x, y].Magnitude();
                    }
                }
            }
            else
            {
                inverseResult = null;
            }

            return;
        }
        private static double[,] GetMagnitudes(ComplexNumber[,] dft)
        {
            var rows       = dft.GetLength(0);
            var cols       = dft.GetLength(1);
            var magnitudes = new double[rows, cols];

            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < cols; j++)
                {
                    magnitudes[i, j] = dft[i, j].Magnitude;
                }
            }
            return(magnitudes);
        }
        /*======================================================================================================
         * Function:   MultipyMatrices
         * Arguments:  Two matrices contain complex numbers
         * Returns:    One matrix made of complex numbers
         */

        public ComplexNumber[,] MultipyComplexMatrices(ComplexNumber[,] matrix1, ComplexNumber[,] matrix2)
        {
            // Initialize a matrix made of complex numbers
            ComplexNumber[,] newMatrix = new ComplexNumber[matrix1.GetLength(0), matrix2.GetLength(1)];

            //Compute each element in the new matrix
            for (int i = 0; i < matrix1.GetLength(0); i++)
            {
                for (int j = 0; j < matrix2.GetLength(1); j++)
                {
                    newMatrix[i, j] = MultiplyComplexArray(GetRow(matrix1, i), GetColumn(matrix2, j));
                }
            }

            // Return the new matrix calculated above
            return(newMatrix);
        }
示例#9
0
        /** \brief constructor for non inverse input
         *
         *
         */
        public FFT(double[,] input)
        {
            int x, y;

            nx = Width = input.GetLength(0);
            ny = Height = input.GetLength(1);

            Fourier = new ComplexNumber[Width, Height];

            for (y = 0; y < input.GetLength(1); y++)
            {
                for (x = 0; x < input.GetLength(0); x++)
                {
                    Fourier[x, y].real = input[x, y];
                }
            }
        }
示例#10
0
        /*======================================================================================================
         * Function:   ConfirmeMatrix
         * Arguments:  One matrix made of complex number
         * Returns:    Void
         */

        public void ConfirmeMatrix(ComplexNumber[,] matrix)
        {
            while (true)
            {
                //Print matrix
                PrintMatrix(matrix);

                if (!IsCorrect())
                {
                    //Change the specific element in the matrix
                    ChangeMatrixElement(matrix);
                }
                else
                {
                    break;
                }
            }
        }
示例#11
0
        /*======================================================================================================
         * Function:   PrintMatrix
         * Arguments:  One matrix made of complex numbers
         * Returns:    None
         */

        public void PrintMatrix(ComplexNumber[,] complexMatrix)
        {
            try
            {
                //Print a matrix in a specific format
                for (int i = 0; i < complexMatrix.GetLength(0); i++)
                {
                    Console.Write("[");
                    for (int j = 0; j < complexMatrix.GetLength(1); j++)
                    {
                        Console.Write(complexMatrix[i, j].ToString().PadRight(15));
                    }
                    Console.Write("]" + Environment.NewLine);
                }
                Console.WriteLine();
            }
            catch (NullReferenceException)
            {
                throw new NullReferenceException("Elements in the matrix cannot be null");
            }
        }
        /*======================================================================================================
         * Function:   ConvertToJagged
         * Arguments:  One matrix
         * Returns:    One jagged array
         */

        public ComplexNumber[][] ConvertToJagged(ComplexNumber[,] matrix)
        {
            //Define local variables
            int rows = matrix.GetLength(1);
            int cols = matrix.GetLength(0);

            ComplexNumber[][] newMatrix = new ComplexNumber[rows][];

            for (int i = 0; i < rows; i++)
            {
                ComplexNumber[] temp = new ComplexNumber[cols];
                for (int j = 0; j < cols; j++)
                {
                    //Assign values
                    temp[j] = matrix[i, j];
                }
                newMatrix[i] = temp;
            }

            //Return matrix
            return(newMatrix);
        }
        /*======================================================================================================
         * Function:   PrintMatrix
         * Arguments:  One matrix made of complex numbers
         * Returns:    None
         */

        public void PrintMatrix(ComplexNumber[,] matrix)
        {
            try
            {
                Console.WriteLine();

                // Display each element in the matrix in a specific format
                for (int i = 0; i < matrix.GetLength(0); i++)
                {
                    for (int j = 0; j < matrix.GetLength(1); j++)
                    {
                        Console.Write(String.Format("{0,9}   + {1,9}i    ",
                                                    (decimal)matrix[i, j].RealPart, (decimal)matrix[i, j].ImaginaryPart));
                    }
                    Console.WriteLine(Environment.NewLine);
                }
                Console.WriteLine();
            }
            catch (NullReferenceException)
            {
                throw new NullReferenceException("Elements in the array(matrix) cannot be null");
            }
        }
示例#14
0
 public DiagonalMatrix(ComplexNumber[,] matr) : base(matr)
 {
     Dimension = Value.GetLength(0);
 }
示例#15
0
文件: FFT.cs 项目: PtrMan/ai2
 /// <summary>
 /// Constructor for Inverse FFT
 /// </summary>
 /// <param name="Input"></param>
 public FFT(ComplexNumber[,] Input)
 {
     nx = Width = Input.GetLength(0);
     ny = Height = Input.GetLength(1);
     Fourier = Input;
 }
示例#16
0
文件: FFT.cs 项目: PtrMan/ai2
        /// <summary>
        /// Calculate Fast Fourier Transform of Input Image
        /// </summary>
        public void doFft(EnumDirection direction)
        {
            int directionAsInt;

            if( direction == EnumDirection.FORWARD )
            {
                directionAsInt = 1;
            }
            else
            {
                directionAsInt = -1;
            }

            //Initializing Fourier Transform Array
            //int i,j;
            /****Fourier =new ComplexNumber [Width,Height];****/
            Output = new ComplexNumber[Width, Height];
            //Copy Image Data to the Complex Array
            /***for (i=0;i<=Width -1;i++)
                for (j = 0; j <= Height - 1; j++)
                {
                    Fourier[i, j].real =(double) GreyImage[i, j];
                    Fourier[i, j].imag = 0;
                }***/
            //Calling Forward Fourier Transform
            Output = fft2d(Fourier, nx, ny, directionAsInt);

            if( direction == EnumDirection.BACKWARD )
            {
                int x, y;

                inverseResult = new double[Width, Height];

                for( y = 0; y < Height; y++ )
                {
                    for( x = 0; x < Width; x++ )
                    {
                        inverseResult[x, y] = Output[x, y].Magnitude();
                    }
                }
            }
            else
            {
                inverseResult = null;
            }

            return;
        }
        public static void Main(string[] args)
        {
            var calculator = new ComplexCalculator();

            //Create a integer represent task type
            int taskType = calculator.GetTaskType();

            switch (taskType)
            {
            //Define the process to calculate two arrays
            case 1:

                Console.WriteLine("\nSet the first vector!");

                //Define a integer represent vector size
                int vectorSize = calculator.SetVectorSize();

                //Set the first array based on user input
                ComplexNumber[] complexArray1 = calculator.SetComplexArray(vectorSize);
                calculator.ConfirmArray(complexArray1);

                Console.WriteLine("\nSet the second vector!");

                //Set the second array based on user input
                ComplexNumber[] complexArray2 = calculator.SetComplexArray(vectorSize);
                calculator.ConfirmArray(complexArray2);

                //Print calculation result
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.WriteLine("\nResult: ");
                Console.Write(calculator.MultiplyComplexArray(complexArray1, complexArray2).ToString());
                Console.WriteLine();
                Console.ResetColor();
                break;

            //Define the process to calculate two matrices
            case 2:

                //Define two integers strings represent the sizes
                int[] matrixSize1;
                int[] matrixSize2;

                //Check the sizes of two matrices
                while (true)
                {
                    Console.WriteLine("\nSet the first matrix or vector!");

                    //Set the first matrix size based on user input
                    matrixSize1 = calculator.SetMatrixSize();

                    Console.WriteLine(Environment.NewLine + "Set the second matrix or vector!");

                    //Set the first matrix size based on user input
                    matrixSize2 = calculator.SetMatrixSize();
                    if (calculator.CanMatch(matrixSize1, matrixSize2))
                    {
                        break;
                    }
                }

                //Set the first matrix based on user input
                ComplexNumber[,] matrix1 = calculator.SetComplexMatrix(matrixSize1);
                calculator.ConfirmeMatrix(matrix1);

                //Set the second matrix based on user input
                ComplexNumber[,] matrix2 = calculator.SetComplexMatrix(matrixSize2);
                calculator.ConfirmeMatrix(matrix2);

                //Print calculation result
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.WriteLine(Environment.NewLine + "Result: ");
                calculator.PrintMatrix(calculator.MultipyComplexMatrices(matrix1, matrix2));
                Console.ResetColor();
                break;

            case 3:
                //Define two integers strings represent the sizes
                int[] matrixSize3;
                int[] matrixSize4;

                //Check the sizes of two matrices
                while (true)
                {
                    Console.WriteLine("\nSet the first matrix or vector!");

                    //Set the first matrix size based on user input
                    matrixSize3 = calculator.SetMatrixSize();
                    Console.WriteLine(Environment.NewLine + "Set the second matrix or vector!");

                    //Set the first matrix size based on user input
                    matrixSize4 = calculator.SetMatrixSize();
                    if (calculator.CanMatch(matrixSize3, matrixSize4))
                    {
                        break;
                    }
                }

                //Set the first matrix based on user input
                ComplexNumber[,] matrix3 = calculator.SetComplexMatrix(matrixSize3);
                calculator.ConfirmeMatrix(matrix3);

                //Set the second matrix based on user input
                ComplexNumber[,] matrix4 = calculator.SetComplexMatrix(matrixSize4);
                calculator.ConfirmeMatrix(matrix4);

                //Compute inverse
                ComplexNumber[][] jaggedArray3   = calculator.ConvertToJagged(matrix3);
                ComplexNumber[][] jagged3Inverse = calculator.MatrixInverse(jaggedArray3);
                ComplexNumber[,] matrix3Inverse = calculator.ConvertToMatrix(jagged3Inverse);

                //Compute division
                ComplexNumber[,] result = calculator.MultipyComplexMatrices(matrix3Inverse, matrix4);

                //Print calculation result
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.WriteLine(Environment.NewLine + "Result: ");
                calculator.PrintMatrix(result);
                Console.ResetColor();
                break;
            }

            //Call garbage collection
            GC.Collect();
            Console.ReadKey();
        }
示例#18
0
文件: FFT.cs 项目: PtrMan/ai2
        /** \brief constructor for non inverse input
         *
         *
         */
        public FFT(double[,] input)
        {
            int x, y;

            nx = Width = input.GetLength(0);
            ny = Height = input.GetLength(1);

            Fourier = new ComplexNumber[Width, Height];

            for( y = 0; y < input.GetLength(1); y++ )
            {
                for( x = 0; x < input.GetLength(0); x++ )
                {
                    Fourier[x, y].real = input[x, y];
                }
            }
        }
        /*==============================================================================
         * Function:   Main
         * Arguments:  string[] args
         * Returns:    None
         */

        static void Main(string[] args)
        {
            //Implement ComplexNumber and ComplexCalculator Classes
            ComplexCalculator calculator     = new ComplexCalculator();
            ComplexNumber     complexNumber1 = new ComplexNumber(1d, 1d);
            ComplexNumber     complexNumber2 = new ComplexNumber(5d, -5d);

            ComplexNumber addResult      = complexNumber1 + complexNumber2;
            ComplexNumber subtractResult = complexNumber1 - complexNumber2;
            ComplexNumber multiplyResult = complexNumber1 * complexNumber2;

            // Print the addition result of two complex numbers
            Console.WriteLine(String.Format("({0}) + ({1}) = {2}",
                                            complexNumber1, complexNumber2, addResult));

            // Print the subtraction result of two complex numbers
            Console.WriteLine(String.Format("({0}) - ({1}) = {2}",
                                            complexNumber1, complexNumber2, subtractResult));

            // Print the multiplication result of two complex numbers
            Console.WriteLine(String.Format("({0}) x ({1}) = {2}",
                                            complexNumber1, complexNumber2, multiplyResult));

            // Print the absolute value of complexNumber2
            Console.WriteLine(String.Format("The absolute value of {0} : {1}",
                                            complexNumber2, complexNumber2.AbsoluteValue));

            // Print the phase of complexNumber2
            Console.WriteLine(String.Format("The phase of {0} : {1}",
                                            complexNumber2, complexNumber2.Phase));

            // Print the polar form of complexNumber2
            Console.WriteLine(String.Format("The polar form of {0} : {1}",
                                            complexNumber2, complexNumber2.PolarForm));

            //Define several complex numbers with different sign
            ComplexNumber complexNumber3 = new ComplexNumber(3, 5);
            ComplexNumber complexNumber4 = new ComplexNumber(3, -5);
            ComplexNumber complexNumber5 = new ComplexNumber(0, 5);
            ComplexNumber complexNumber6 = new ComplexNumber(0, -5);
            ComplexNumber complexNumber7 = new ComplexNumber(3, 0);
            ComplexNumber complexNumber8 = new ComplexNumber(0, 0);

            //Print complex numbers
            Console.WriteLine(Environment.NewLine);
            Console.WriteLine(String.Format("ComplexNumber(3, 5)  : {0}", complexNumber3));
            Console.WriteLine(String.Format("ComplexNumber(3, -5) : {0}", complexNumber4));
            Console.WriteLine(String.Format("ComplexNumber(0, 5)  : {0}", complexNumber5));
            Console.WriteLine(String.Format("ComplexNumber(0, -5) : {0}", complexNumber6));
            Console.WriteLine(String.Format("ComplexNumber(3, 0)  : {0}", complexNumber7));
            Console.WriteLine(String.Format("ComplexNumber(0, 0)  : {0}", complexNumber8));

            //Define two 2x2 matrices
            ComplexNumber[,] matrix1 = new ComplexNumber[2, 2]
            {
                { new ComplexNumber(1, 1), new ComplexNumber(2, 0) },
                { new ComplexNumber(0, 0), new ComplexNumber(2, 5) }
            };
            ComplexNumber[,] matrix2 = new ComplexNumber[2, 2]
            {
                { new ComplexNumber(5, -5), new ComplexNumber(0, -2) },
                { new ComplexNumber(0, 4.2), new ComplexNumber(-11.1, 0) }
            };

            ComplexNumber[,] result1 = calculator.MultipyComplexMatrices(matrix1, matrix2);

            //Print the matrix calculated above
            Console.WriteLine(Environment.NewLine);
            Console.WriteLine("Result of matrix1 multiply matrix2");
            calculator.PrintMatrix(result1);
            Console.ReadKey();
        }
        /*==============================================================================
         * Function:   Main
         * Arguments:  string[] args
         * Returns:    None
         */

        static void Main(string[] args)
        {
            //Create an instance of ComplexCalculator class
            var calculator = new ComplexCalculator();

            //Create a integer represent task type
            int taskType = calculator.GetTaskType();

            //Decide the task type
            switch (taskType)
            {
            //Define the process to calculate two arrays
            case 1:

                Console.WriteLine("\nSet the first vector!");

                //Define a integer represent vector size
                int vectorSize = calculator.SetVectorSize();

                //Set the first array based on user input
                ComplexNumber[] complexArray1 = calculator.SetComplexVector(vectorSize);
                calculator.ConfirmVector(complexArray1);

                Console.WriteLine("\nSet the second vector!");

                //Set the second array based on user input
                ComplexNumber[] complexArray2 = calculator.SetComplexVector(vectorSize);
                calculator.ConfirmVector(complexArray2);

                //Print calculation result
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.WriteLine("\nResult: ");
                Console.Write(calculator.MultiplyComplexVector(complexArray1, complexArray2).ToString());
                Console.WriteLine();
                Console.ResetColor();
                break;

            //Define the process to calculate two matrices
            case 2:

                //Define two integers strings represent the sizes
                int[] matrixSize1;
                int[] matrixSize2;

                //Check the sizes of two matrices
                while (true)
                {
                    Console.WriteLine("\nSet the first matrix or vector!");

                    //Set the first matrix size based on user input
                    matrixSize1 = calculator.SetMatrixSize();

                    Console.WriteLine(Environment.NewLine + "Set the second matrix or vector!");

                    //Set the first matrix size based on user input
                    matrixSize2 = calculator.SetMatrixSize();
                    if (calculator.CanMatch(matrixSize1, matrixSize2))
                    {
                        break;
                    }
                }

                //Set the first matrix based on user input
                ComplexNumber[,] matrix1 = calculator.SetComplexMatrix(matrixSize1);
                calculator.ConfirmeMatrix(matrix1);

                //Set the second matrix based on user input
                ComplexNumber[,] matrix2 = calculator.SetComplexMatrix(matrixSize2);
                calculator.ConfirmeMatrix(matrix2);

                //Print calculation result
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.WriteLine(Environment.NewLine + "Result: ");
                calculator.PrintMatrix(calculator.MultipyComplexMatrices(matrix1, matrix2));
                Console.ResetColor();
                break;
            }

            //Call garbage collection
            GC.Collect();
            Console.ReadKey();
        }
示例#21
0
        /*======================================================================================================
         * Function:   ChangeMatrixElement
         * Arguments:  One matrix made of complex numbers
         * Returns:    Void
         */

        private void ChangeMatrixElement(ComplexNumber[,] matrix)
        {
            //Define local variables
            int  rownumber;
            int  colnumber;
            bool needHint = true;

            Console.WriteLine("Which element you want to replace?" +
                              "Enter the position of that element" +
                              Environment.NewLine +
                              "Ex: 1,2  3,4");
            do
            {
                //Read user input
                string[] position = ReadInput();
                if (position.Length != 2)
                {
                    Console.WriteLine("The position of a element contains its row number " +
                                      "and its column number. Ex: 2,2 or 3,5");
                    continue;
                }
                if (!CanConvertToInt(position[0]) || !CanConvertToInt(position[1]))
                {
                    Console.WriteLine("The position must be numeric and should be integer!");
                    continue;
                }

                //Assign two integers
                rownumber = Convert.ToInt32(position[0]);
                colnumber = Convert.ToInt32(position[1]);

                if (rownumber <= 0 || colnumber <= 0)
                {
                    Console.WriteLine("The row number and column number of a matrix" +
                                      "cannot be or less than zero!");
                    continue;
                }
                if (rownumber > matrix.GetLength(0))
                {
                    Console.WriteLine(String.Format("Your matrix only have {0} row, " +
                                                    "you cannot change the element be change in {1} row",
                                                    matrix.GetLength(0), rownumber));
                    continue;
                }
                if (colnumber > matrix.GetLength(1))
                {
                    Console.WriteLine(String.Format("Your matrix only have {0} column, " +
                                                    "you cannot change the element be change in {1} column",
                                                    matrix.GetLength(1), colnumber));
                    continue;
                }
                else
                {
                    rownumber -= 1;
                    colnumber -= 1;
                    break;
                }
            } while (true);

            //Reset the specific element in the matrix
            matrix[rownumber, colnumber] = SetComplexNumber(needHint);
        }
示例#22
0
        /// <summary>
        /// Constructor for Inverse FFT
        /// </summary>
        /// <param name="Input"></param>

        public FFT(ComplexNumber[,] Input)
        {
            nx      = Width = Input.GetLength(0);
            ny      = Height = Input.GetLength(1);
            Fourier = Input;
        }
        /*==============================================================================
         * Function:   Main
         * Arguments:  None
         * Returns:    None
         */

        static void Main(string[] args)
        {
            //Implement ComplexNumber and ComplexCalculator Classes
            ComplexCalculator calculator     = new ComplexCalculator();
            ComplexNumber     complexNumber1 = new ComplexNumber(1d, 1d);
            ComplexNumber     complexNumber2 = new ComplexNumber(5d, -5d);

            ComplexNumber complexNumber3 = new ComplexNumber(2d, 0);
            ComplexNumber complexNumber4 = new ComplexNumber(0, 4.2);


            //Calculate the result of multiplication
            var multiplyResult1 = calculator.MutiplyComplex(complexNumber1, complexNumber2);
            var multiplyResult2 = calculator.MutiplyComplex(complexNumber3, complexNumber4);


            //Print the first multiplication result
            Console.Write(String.Format("{0} + {1}i  Mutiply  {2} + {3}i :  ",
                                        complexNumber1.RealPart, complexNumber1.ImaginaryPart,
                                        complexNumber2.RealPart, complexNumber2.ImaginaryPart));

            multiplyResult1.PrintComplexNumber();

            //Print the second multiplication result
            Console.Write(String.Format("{0} + {1}i  Mutiply  {2} + {3}i :  ",
                                        complexNumber3.RealPart, complexNumber3.ImaginaryPart,
                                        complexNumber4.RealPart, complexNumber4.ImaginaryPart));

            multiplyResult2.PrintComplexNumber();

            //Add two multiplyresults
            var addResult1 = calculator.AddComplex(multiplyResult1, multiplyResult2);

            //Print addResult1
            Console.Write(String.Format("{0} + {1}i  Add  {2} + {3}i :  ",
                                        multiplyResult1.RealPart, multiplyResult1.ImaginaryPart,
                                        multiplyResult2.RealPart, multiplyResult2.ImaginaryPart));

            addResult1.PrintComplexNumber();


            /*====================================== CASE 1 ======================================*/

            //Define two 2x2 matrices
            ComplexNumber[,] matrix1 = new ComplexNumber[2, 2]
            {
                { new ComplexNumber(1, 1), new ComplexNumber(2, 0) },
                { new ComplexNumber(0, 0), new ComplexNumber(2, 5) }
            };
            ComplexNumber[,] matrix2 = new ComplexNumber[2, 2]
            {
                { new ComplexNumber(5, -5), new ComplexNumber(0, -2) },
                { new ComplexNumber(0, 4.2), new ComplexNumber(-11.1, 0) }
            };

            //Calculate the multiplication of two 2x2 matrices
            ComplexNumber[,] result1 = calculator.MultipyComplexMatrices(matrix1, matrix2);

            //Print the matrix calculated above
            Console.WriteLine("Result of matrix1 multiply matrix2");
            calculator.PrintMatrix(result1);


            /*====================================== CASE 2 ======================================*/

            //Define two 2x3 matrices
            ComplexNumber[,] matrix3 = new ComplexNumber[2, 3]
            {
                { new ComplexNumber(1, 1), new ComplexNumber(2, 0), new ComplexNumber(5, -5) },
                { new ComplexNumber(0, 0), new ComplexNumber(2, 5), new ComplexNumber(0, 4.2) }
            };

            //Calculate the multiplication of one 2x2 and one 2x3 matrices
            ComplexNumber[,] result2 = calculator.MultipyComplexMatrices(result1, matrix3);

            //Print the matrix calculated above
            Console.WriteLine("Result of result1 multiply matrix3");
            calculator.PrintMatrix(result2);


            /*====================================== CASE 3 ======================================*/

            //Define two 3x3 matrices
            ComplexNumber[,] matrix4 = new ComplexNumber[3, 3]
            {
                { new ComplexNumber(1, 1), new ComplexNumber(2, 0), new ComplexNumber(2, 0) },
                { new ComplexNumber(0, 0), new ComplexNumber(2, 5), new ComplexNumber(0, 9) },
                { new ComplexNumber(1, -1), new ComplexNumber(3.7, -4.5), new ComplexNumber(9.5, -3) }
            };

            //Calculate the multiplication of one 2x3 and one 3x3 matrices
            ComplexNumber[,] result3 = calculator.MultipyComplexMatrices(result2, matrix4);

            //Print the matrix calculated above
            Console.WriteLine("Result of result2 multiply matrix4");
            calculator.PrintMatrix(result3);


            /*====================================== CASE 4 ======================================*/

            //Define two 3x2 matrices
            ComplexNumber[,] matrix5 = new ComplexNumber[3, 2]
            {
                { new ComplexNumber(5, 4), new ComplexNumber(2, 0) },
                { new ComplexNumber(0, 0), new ComplexNumber(2, 5) },
                { new ComplexNumber(1, -1), new ComplexNumber(3.7, -4.5) }
            };

            //Calculate the multiplication of one 2x3 and one 3x2 matrices
            ComplexNumber[,] result4 = calculator.MultipyComplexMatrices(result3, matrix5);

            //Print the matrix calculated above
            Console.WriteLine("Result of result3 multiply matrix5");
            calculator.PrintMatrix(result4);


            /*====================================== CASE 5 ======================================*/

            //Define two 2x2 matrices
            ComplexNumber[,] matrix6 = new ComplexNumber[2, 2]
            {
                { new ComplexNumber(0, 0), new ComplexNumber(0, 0) },
                { new ComplexNumber(0, 0), new ComplexNumber(0, 0) }
            };

            //Calculate the multiplication of the 2x2 matrix obtained in CASE 4 and one 2x2 zero matrix
            ComplexNumber[,] result5 = calculator.MultipyComplexMatrices(result4, matrix6);

            //Print the matrix calculated above
            Console.WriteLine("Result of result4 multiply matrix6");
            calculator.PrintMatrix(result5);

            /*====================================== CASE 6 ======================================*/

            //Calculate the multiplication of the 2x2 zero matrix obtained above and matrix1
            ComplexNumber[,] result6 = calculator.MultipyComplexMatrices(result5, matrix1);

            //Print the matrix calculated above
            Console.WriteLine("Result of result5 multiply matrix1");
            calculator.PrintMatrix(result6);
        }