public ComplexMatrix(OrderedPair size)
 {
     var matrix = new ComplexVector[size.M];
     for (var i = 0; i < size.M; i++)
     {
         matrix[i] = new ComplexVector(size.N);
     }
     this.matrix = matrix;
 }
Beispiel #2
0
        public ComplexMatrix(OrderedPair size)
        {
            var matrix = new ComplexVector[size.M];

            for (var i = 0; i < size.M; i++)
            {
                matrix[i] = new ComplexVector(size.N);
            }
            this.matrix = matrix;
        }
Beispiel #3
0
        public ComplexMatrix ScalarProduct(Complex c)
        {
            var result = new ComplexVector[this.Size.M];

            for (var m = 0; m < this.Size.M; m++)
            {
                result[m] = this[m].ScalarProduct(c);
            }

            return(new ComplexMatrix(result));
        }
 public ComplexMatrix(ComplexVector[] matrix)
 {
     var size = -1;
     for (var i = 0; i < matrix.Length; i++)
     {
         if (size == -1) size = matrix[i].Size;
         else if (size != matrix[i].Size)
         {
             throw new MatrixSizeException(MatrixSizeException.RANK_MESSAGE);
         }
     }
     this.matrix = matrix;
 }
Beispiel #5
0
        public static ComplexMatrix operator -(ComplexMatrix m1, ComplexMatrix m2)
        {
            if (m1.Size != m2.Size)
            {
                throw new MatrixSizeException(MatrixSizeException.SUBTRACTION_MESSAGE);
            }

            var result = new ComplexVector[m1.Size.M];

            for (var m = 0; m < m1.Size.M; m++)
            {
                result[m] = m1[m] - m2[m];
            }

            return(new ComplexMatrix(result));
        }
        public static Complex InnerProduct(ComplexVector v1, ComplexVector v2)
        {
            if (v1.Size != v2.Size)
            {
                throw new VectorSizeException(VectorSizeException.INNER_PRODUCT_MESSAGE);
            }

            var result = new Complex();

            for (var i = 0; i < v1.Size; i++)
            {
                result += v1[i] * v2[i].Conjugate;
            }

            return(result);
        }
        public ComplexMatrix(Complex[][] matrix)
        {
            var vectors = new ComplexVector[matrix.Length];
            var size = -1;

            for (var i = 0; i < matrix.Length; i++)
            {
                vectors[i] = new ComplexVector(matrix[i]);

                if (size == -1) size = vectors[i].Size;
                else if (size != vectors[i].Size)
                {
                    throw new MatrixSizeException(MatrixSizeException.RANK_MESSAGE);
                }
            }

            this.matrix = vectors;
        }
Beispiel #8
0
        public ComplexMatrix(Complex[][] matrix)
        {
            var vectors = new ComplexVector[matrix.Length];
            var size    = -1;

            for (var i = 0; i < matrix.Length; i++)
            {
                vectors[i] = new ComplexVector(matrix[i]);

                if (size == -1)
                {
                    size = vectors[i].Size;
                }
                else if (size != vectors[i].Size)
                {
                    throw new MatrixSizeException(MatrixSizeException.RANK_MESSAGE);
                }
            }

            this.matrix = vectors;
        }
Beispiel #9
0
        public void VectorScalarMultiplication()
        {
            var expected = new ComplexVector(
                new Complex[] { new Complex(12, 21), new Complex(0, 0), new Complex(13, 13), new Complex(12, 8) });
            var result = v3.ScalarProduct(c9);

            Assert.AreEqual(expected, result);
        }
        public ComplexMatrix ScalarProduct(Complex c)
        {
            var result = new ComplexVector[this.Size.M];
            for (var m = 0; m < this.Size.M; m++)
            {
                result[m] = this[m].ScalarProduct(c);
            }

            return new ComplexMatrix(result);
        }
 public static double Distance(ComplexVector v1, ComplexVector v2)
 {
     return((v1 - v2).Norm);
 }
 public static double Distance(ComplexVector v1, ComplexVector v2)
 {
     return (v1 - v2).Norm;
 }
        public static Complex InnerProduct(ComplexVector v1, ComplexVector v2)
        {
            if (v1.Size != v2.Size)
                throw new VectorSizeException(VectorSizeException.INNER_PRODUCT_MESSAGE);

            var result = new Complex();

            for (var i = 0; i < v1.Size; i++)
            {
                result += v1[i] * v2[i].Conjugate;
            }

            return result;
        }
        public static ComplexMatrix operator -(ComplexMatrix m1, ComplexMatrix m2)
        {
            if (m1.Size != m2.Size)
                throw new MatrixSizeException(MatrixSizeException.SUBTRACTION_MESSAGE);

            var result = new ComplexVector[m1.Size.M];
            for (var m = 0; m < m1.Size.M; m++)
            {
                result[m] = m1[m] - m2[m];
            }

            return new ComplexMatrix(result);
        }
Beispiel #15
0
        public void VectorSubtraction()
        {
            var expected = new ComplexVector(
                new Complex[] { new Complex(-10, -6.3), new Complex(7, 10), new Complex(-1.8, -8.1), new Complex(0, 1) });
            var result = v1 - v2;

            Assert.AreEqual(expected, result);
        }
Beispiel #16
0
        public void VectorInverse()
        {
            var expected = new ComplexVector(
                new Complex[] { new Complex(-6, 4), new Complex(-7, -3), new Complex(-4.2, 8.1), new Complex(0, 3) });
            var result = v1.Inverse;

            Assert.AreEqual(expected, result);
        }
Beispiel #17
0
        public void VectorConjugate()
        {
            var expected = new ComplexVector(
                new Complex[] { new Complex(6, -3), new Complex(0, 0), new Complex(5, -1), new Complex(4, 0) });
            var result = v3.Conjugate;

            Assert.AreEqual(expected, result);
        }
Beispiel #18
0
        public void VectorAddition()
        {
            var expected = new ComplexVector(
                new Complex[] { new Complex(22, -1.7), new Complex(7, -4), new Complex(10.2, -8.1), new Complex(0, -7) });
            var result = v1 + v2;

            Assert.AreEqual(expected, result);
        }
Beispiel #19
0
        public void MatrixRow()
        {
            var expected = new ComplexVector(
                new Complex[] { new Complex(3, -1), new Complex(1, 4), new Complex(-2, 1), new Complex(1, -1) });
            var result = m1.Row(1);

            Assert.AreEqual(expected, result);
        }
Beispiel #20
0
        public void MatrixColumn()
        {
            var expected = new ComplexVector(
                new Complex[] { new Complex(5, -4), new Complex(1, -1), new Complex(-4, 2) });
            var result = m1.Column(3);

            Assert.AreEqual(expected, result);
        }