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


C# DenseMatrix.LowerTriangle方法代码示例

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


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

示例1: Run

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

            // Create square matrix
            var matrix = new DenseMatrix(10);
            var k = 0;
            for (var i = 0; i < matrix.RowCount; i++)
            {
                for (var j = 0; j < matrix.ColumnCount; j++)
                {
                    matrix[i, j] = k++;
                }
            }

            Console.WriteLine(@"Initial square matrix");
            Console.WriteLine(matrix.ToString("#0.00\t", formatProvider));
            Console.WriteLine();

            // 1. Retrieve a new matrix containing the lower triangle of the matrix
            var lower = matrix.LowerTriangle();

            // Puts the lower triangle of the matrix into the result matrix.
            matrix.LowerTriangle(lower);
            Console.WriteLine(@"1. Lower triangle of the matrix");
            Console.WriteLine(lower.ToString("#0.00\t", formatProvider));
            Console.WriteLine();

            // 2. Retrieve a new matrix containing the upper triangle of the matrix
            var upper = matrix.UpperTriangle();

            // Puts the upper triangle of the matrix into the result matrix.
            matrix.UpperTriangle(lower);
            Console.WriteLine(@"2. Upper triangle of the matrix");
            Console.WriteLine(upper.ToString("#0.00\t", formatProvider));
            Console.WriteLine();

            // 3. Retrieve a new matrix containing the strictly lower triangle of the matrix
            var strictlylower = matrix.StrictlyLowerTriangle();

            // Puts the strictly lower triangle of the matrix into the result matrix.
            matrix.StrictlyLowerTriangle(strictlylower);
            Console.WriteLine(@"3. Strictly lower triangle of the matrix");
            Console.WriteLine(strictlylower.ToString("#0.00\t", formatProvider));
            Console.WriteLine();

            // 4. Retrieve a new matrix containing the strictly upper triangle of the matrix
            var strictlyupper = matrix.StrictlyUpperTriangle();

            // Puts the strictly upper triangle of the matrix into the result matrix.
            matrix.StrictlyUpperTriangle(strictlyupper);
            Console.WriteLine(@"4. Strictly upper triangle of the matrix");
            Console.WriteLine(strictlyupper.ToString("#0.00\t", formatProvider));
            Console.WriteLine();
        }
开发者ID:jvangael,项目名称:mathnet-numerics,代码行数:61,代码来源:MatrixTriangular.cs


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