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


C# DenseMatrix.Cholesky方法代码示例

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


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

示例1: Run

        /// <summary>
        /// Run example
        /// </summary>
        /// <seealso cref="http://en.wikipedia.org/wiki/Cholesky_decomposition">Cholesky decomposition</seealso>
        public void Run()
        {
            // Format matrix output to console
            var formatProvider = (CultureInfo)CultureInfo.InvariantCulture.Clone();
            formatProvider.TextInfo.ListSeparator = " ";

            // Create square, symmetric, positive definite matrix
            var matrix = new DenseMatrix(new[,] { { 2.0, 1.0 }, { 1.0, 2.0 } });
            Console.WriteLine(@"Initial square, symmetric, positive definite matrix");
            Console.WriteLine(matrix.ToString("#0.00\t", formatProvider));
            Console.WriteLine();

            // Perform Cholesky decomposition
            var cholesky = matrix.Cholesky();
            Console.WriteLine(@"Perform Cholesky decomposition");

            // 1. Lower triangular form of the Cholesky matrix
            Console.WriteLine(@"1. Lower triangular form of the Cholesky matrix");
            Console.WriteLine(cholesky.Factor.ToString("#0.00\t", formatProvider));
            Console.WriteLine();

            // 2. Reconstruct initial matrix: A = L * LT
            var reconstruct = cholesky.Factor * cholesky.Factor.Transpose();
            Console.WriteLine(@"2. Reconstruct initial matrix: A = L*LT");
            Console.WriteLine(reconstruct.ToString("#0.00\t", formatProvider));
            Console.WriteLine();

            // 3. Get determinant of the matrix
            Console.WriteLine(@"3. Determinant of the matrix");
            Console.WriteLine(cholesky.Determinant);
            Console.WriteLine();

            // 4. Get log determinant of the matrix
            Console.WriteLine(@"4. Log determinant of the matrix");
            Console.WriteLine(cholesky.DeterminantLn);
            Console.WriteLine();
        }
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:41,代码来源:Cholesky.cs

示例2: CholeskyFailsWithNonSquareMatrix

 public void CholeskyFailsWithNonSquareMatrix()
 {
     var matrix = new DenseMatrix(3, 2);
     Assert.That(() => matrix.Cholesky(), Throws.ArgumentException);
 }
开发者ID:EraYaN,项目名称:EV2020,代码行数:5,代码来源:CholeskyTests.cs


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