Exemplo n.º 1
0
        private static void TestSubtraction(LinearAlgebraProviderChoice providers)
        {
            TestSettings.RunMultiproviderTest(providers, delegate()
            {
                var A1       = Matrix.CreateFromArray(SquareSingular10by10.Matrix);
                var A2       = Matrix.CreateFromArray(SymmPosDef10by10.Matrix);
                var expected = Matrix.CreateFromArray(
                    MatrixOperations.LinearCombination(1.0, SquareSingular10by10.Matrix, -1.0, SymmPosDef10by10.Matrix));

                // operator+
                comparer.AssertEqual(expected, A1 - A2);
            });
        }
Exemplo n.º 2
0
        private static void TestAxpy()
        {
            Skip.IfNot(TestSettings.TestMkl, TestSettings.MessageWhenSkippingMKL);

            int n = 5;

            double[] a         = { 1, 2, 3, 4, 5 };
            double[] b         = { 10, 20, 30, 40, 50 };
            double[] cExpected = MatrixOperations.LinearCombination(1.0, a, 1.0, b);

            double[] cComputed = new double[5];
            Array.Copy(b, cComputed, n);
            CBlas.Daxpy(a.Length, 1.0, ref a[0], 1, ref cComputed[0], 1);

            comparer.AssertEqual(cExpected, cComputed);
        }
Exemplo n.º 3
0
        private static void TestLinearCombination(LinearAlgebraProviderChoice providers)
        {
            TestSettings.RunMultiproviderTest(providers, delegate()
            {
                var A1         = Matrix.CreateFromArray(SquareSingular10by10.Matrix);
                double scalar1 = 2.0;
                var A2         = Matrix.CreateFromArray(SymmPosDef10by10.Matrix);
                double scalar2 = 3.5;
                var expected   = Matrix.CreateFromArray(
                    MatrixOperations.LinearCombination(scalar1, SquareSingular10by10.Matrix, scalar2, SymmPosDef10by10.Matrix));

                // LinearCombination()
                comparer.AssertEqual(expected, A1.LinearCombination(scalar1, A2, scalar2));

                // LinearCombinationIntoThis()
                Matrix temp = A1.Copy();
                temp.LinearCombinationIntoThis(scalar1, A2, scalar2);
                comparer.AssertEqual(expected, temp);
            });
        }