Beispiel #1
0
        public void Multiply()
        {
            ComplexDoubleVector a = new ComplexDoubleVector(new double[4] {
                0, 1, 2, 3
            });
            ComplexDoubleVector b = new ComplexDoubleVector(new double[4] {
                4, 5, 6, 7
            });
            ComplexDoubleMatrix c = new ComplexDoubleMatrix(a.Length, b.Length);
            ComplexDoubleMatrix d = new ComplexDoubleMatrix(a.Length, b.Length);

            c = a * b;
            d = ComplexDoubleVector.Multiply(a, b);

            Assert.AreEqual(c[0, 0], a[0] * b[0]);
            Assert.AreEqual(c[0, 1], a[0] * b[1]);
            Assert.AreEqual(c[0, 2], a[0] * b[2]);
            Assert.AreEqual(c[0, 3], a[0] * b[3]);
            Assert.AreEqual(c[1, 0], a[1] * b[0]);
            Assert.AreEqual(c[1, 1], a[1] * b[1]);
            Assert.AreEqual(c[1, 2], a[1] * b[2]);
            Assert.AreEqual(c[1, 3], a[1] * b[3]);
            Assert.AreEqual(c[2, 0], a[2] * b[0]);
            Assert.AreEqual(c[2, 1], a[2] * b[1]);
            Assert.AreEqual(c[2, 2], a[2] * b[2]);
            Assert.AreEqual(c[2, 3], a[2] * b[3]);
            Assert.AreEqual(c[3, 0], a[3] * b[0]);
            Assert.AreEqual(c[3, 1], a[3] * b[1]);
            Assert.AreEqual(c[3, 2], a[3] * b[2]);
            Assert.AreEqual(c[3, 3], a[3] * b[3]);

            Assert.AreEqual(d[0, 0], a[0] * b[0]);
            Assert.AreEqual(d[0, 1], a[0] * b[1]);
            Assert.AreEqual(d[0, 2], a[0] * b[2]);
            Assert.AreEqual(d[0, 3], a[0] * b[3]);
            Assert.AreEqual(d[1, 0], a[1] * b[0]);
            Assert.AreEqual(d[1, 1], a[1] * b[1]);
            Assert.AreEqual(d[1, 2], a[1] * b[2]);
            Assert.AreEqual(d[1, 3], a[1] * b[3]);
            Assert.AreEqual(d[2, 0], a[2] * b[0]);
            Assert.AreEqual(d[2, 1], a[2] * b[1]);
            Assert.AreEqual(d[2, 2], a[2] * b[2]);
            Assert.AreEqual(d[2, 3], a[2] * b[3]);
            Assert.AreEqual(d[3, 0], a[3] * b[0]);
            Assert.AreEqual(d[3, 1], a[3] * b[1]);
            Assert.AreEqual(d[3, 2], a[3] * b[2]);
            Assert.AreEqual(d[3, 3], a[3] * b[3]);
        }
Beispiel #2
0
        public void ScalarMultiplyAndDivide()
        {
            ComplexDoubleVector a = new ComplexDoubleVector(new double[4] {
                0, 1, 2, 3
            });
            ComplexDoubleVector c = new ComplexDoubleVector(a);
            ComplexDoubleVector d = new ComplexDoubleVector(a);
            double scal           = -4;

            c.Multiply(scal);
            d.Divide(scal);

            Assert.AreEqual(c[0], a[0] * scal);
            Assert.AreEqual(c[1], a[1] * scal);
            Assert.AreEqual(c[2], a[2] * scal);
            Assert.AreEqual(c[3], a[3] * scal);

            Assert.AreEqual(d[0], a[0] / scal);
            Assert.AreEqual(d[1], a[1] / scal);
            Assert.AreEqual(d[2], a[2] / scal);
            Assert.AreEqual(d[3], a[3] / scal);

            c = a * scal;

            Assert.AreEqual(c[0], a[0] * scal);
            Assert.AreEqual(c[1], a[1] * scal);
            Assert.AreEqual(c[2], a[2] * scal);
            Assert.AreEqual(c[3], a[3] * scal);

            c = scal * a;

            Assert.AreEqual(c[0], a[0] * scal);
            Assert.AreEqual(c[1], a[1] * scal);
            Assert.AreEqual(c[2], a[2] * scal);
            Assert.AreEqual(c[3], a[3] * scal);
        }