当前位置: 首页>>代码示例>>C#>>正文


C# GeneralMatrix.Add方法代码示例

本文整理汇总了C#中DotNetMatrix.GeneralMatrix.Add方法的典型用法代码示例。如果您正苦于以下问题:C# GeneralMatrix.Add方法的具体用法?C# GeneralMatrix.Add怎么用?C# GeneralMatrix.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DotNetMatrix.GeneralMatrix的用法示例。


在下文中一共展示了GeneralMatrix.Add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CalculateNextHessianApproximation

        protected override GeneralMatrix CalculateNextHessianApproximation(GeneralMatrix previousH, 
			double[]prevX, double[]curX, double[]prevGrad, double[]curGrad)
        {
            GeneralMatrix currentH = new GeneralMatrix(_nDim,_nDim);
            GeneralMatrix cX = new GeneralMatrix(curX,_nDim);
            GeneralMatrix pX = new GeneralMatrix(prevX,_nDim);
            GeneralMatrix cG = new GeneralMatrix(curGrad,_nDim);
            GeneralMatrix pG = new GeneralMatrix(prevGrad,_nDim);

            GeneralMatrix dX = cX.Subtract(pX);
            GeneralMatrix dG = cG.Subtract(pG);

            double aK1 = 1/(dX.Transpose().Multiply(dG).GetElement(0,0));
            GeneralMatrix aK2 = dX.Multiply(dX.Transpose());

            GeneralMatrix aK = aK2.Multiply(aK1);

            double bK1 = -1/(dG.Transpose().Multiply(previousH).Multiply(dG).GetElement(0,0));
            GeneralMatrix bK2 = previousH.Multiply(dG).Multiply(dG.Transpose()).Multiply(previousH.Transpose());

            GeneralMatrix bK =bK2.Multiply(bK1);

            currentH = previousH.Add(aK).Add(bK);

            return currentH;
        }
开发者ID:kriskniaz,项目名称:pCode,代码行数:26,代码来源:DFP.cs

示例2: Main


//.........这里部分代码省略.........
                errorCount = try_failure(errorCount, "Subtract... ", "(difference of identical Matrices is nonzero,\nSubsequent use of Subtract should be suspect)");
            }
            else
            {
                try_success("Subtract... ", "");
            }
            A = R.Copy();
            A.SubtractEquals(R);
            Z = new GeneralMatrix(A.RowDimension, A.ColumnDimension);
            try
            {
                A.SubtractEquals(S);
                errorCount = try_failure(errorCount, "SubtractEquals conformance check... ", "nonconformance not raised");
            }
            catch (System.ArgumentException e)
            {
                try_success("SubtractEquals conformance check... ", "");
                System.Console.Out.WriteLine(e.Message);
            }
            if (A.Subtract(Z).Norm1() != 0.0)
            {
                errorCount = try_failure(errorCount, "SubtractEquals... ", "(difference of identical Matrices is nonzero,\nSubsequent use of Subtract should be suspect)");
            }
            else
            {
                try_success("SubtractEquals... ", "");
            }

            A = R.Copy();
            B = GeneralMatrix.Random(A.RowDimension, A.ColumnDimension);
            C = A.Subtract(B);
            try
            {
                S = A.Add(S);
                errorCount = try_failure(errorCount, "Add conformance check... ", "nonconformance not raised");
            }
            catch (System.ArgumentException e)
            {
                try_success("Add conformance check... ", "");
                System.Console.Out.WriteLine(e.Message);
            }
            try
            {
                check(C.Add(B), A);
                try_success("Add... ", "");
            }
            catch (System.SystemException e)
            {
                errorCount = try_failure(errorCount, "Add... ", "(C = A - B, but C + B != A)");
                System.Console.Out.WriteLine(e.Message);
            }
            C = A.Subtract(B);
            C.AddEquals(B);
            try
            {
                A.AddEquals(S);
                errorCount = try_failure(errorCount, "AddEquals conformance check... ", "nonconformance not raised");
            }
            catch (System.ArgumentException e)
            {
                try_success("AddEquals conformance check... ", "");
                System.Console.Out.WriteLine(e.Message);
            }
            try
            {
                check(C, A);
开发者ID:eylvisaker,项目名称:tbsuite,代码行数:67,代码来源:TestMatrix.cs

示例3: UnaryMinus

 public void UnaryMinus()
 {
     A = R.UnaryMinus();
     Z = new GeneralMatrix(A.RowDimension, A.ColumnDimension);
     Assert.IsTrue(GeneralTests.Check(A.Add(R), Z));
 }
开发者ID:kriskniaz,项目名称:pCode,代码行数:6,代码来源:ArrayTests.cs


注:本文中的DotNetMatrix.GeneralMatrix.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。