コード例 #1
0
        public void Substraction()
        {
            double[]   columnwise = new double[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 };
            double[][] avals      = { new double[] { 1.0, 4.0, 7.0, 10.0 }, new double[] { 2.0, 5.0, 8.0, 11.0 }, new double[] { 3.0, 6.0, 9.0, 12.0 } };

            int validld = 3;             /* leading dimension of intended test Matrices */

            //one dimensional array of doubles packed by columns ala Fortran
            //is passed to the constructor
            //the integer value tell the constructor how to
            //breakup one domensional value into mulidimensional column
            GeneralMatrix A   = new GeneralMatrix(columnwise, validld);
            GeneralMatrix B   = new GeneralMatrix(avals);
            double        tmp = B.GetElement(0, 0);

            avals[0][0] = 0.0;
            GeneralMatrix C = B.Subtract(A);

            avals[0][0] = tmp;
            B           = GeneralMatrix.Create(avals);
            tmp         = B.GetElement(0, 0);
            avals[0][0] = 0.0;
            Assert.IsTrue(tmp == B.GetElement(0, 0));
        }