Example #1
0
        public void Multiply()
        {
            ComplexFloatVector a = new ComplexFloatVector(new float[4] {
                0, 1, 2, 3
            });
            ComplexFloatVector b = new ComplexFloatVector(new float[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 = ComplexFloatVector.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]);
        }
Example #2
0
        public void ScalarMultiplyAndDivide()
        {
            ComplexFloatVector a = new ComplexFloatVector(new float[4] {
                0, 1, 2, 3
            });
            ComplexFloatVector c = new ComplexFloatVector(a);
            ComplexFloatVector d = new ComplexFloatVector(a);
            float 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);
        }