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


C# Matrix.PrintMatrix方法代码示例

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


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

示例1: Main

        static void Main(string[] args)
        {
            int[,] arr1 = {
                {1,2,3},
                {4,5,6}
                
            };

            int[,] arr2 = {
                {7,8},
                {9,10},
                {11,12},
            };

            double[,] arr3 = {
                {1.5,2.5,3.7},
                {4,5,6}
                
            };

            double[,] arr4 = {
                {7,8},
                {9,10},
                {11,12},
            };

            //string[,] arr5 = new string[20,20];

           /* int[,] arr2 = {    check true and false operators
                {0,0},
                {0,0},
                {0,0},
            };
            */
            
            Matrix<int> matrix = new Matrix<int>(arr1);
            Matrix<int> matrix1 = new Matrix<int>(arr2);
            Matrix<double> matrix2 = new Matrix<double>(arr3);
            Matrix<double> matrix3 = new Matrix<double>(arr4);
           // Matrix<string> matrix4 = new Matrix<string>(arr5);
            //matrix.printMatrix();
            matrix = matrix * matrix1;
            matrix2 = matrix2 * matrix3;
            if (matrix)
            {
                matrix.PrintMatrix();
                matrix2.PrintMatrix();
            }
            else
            {
                Console.WriteLine("Matrix has 0 Value");
            }
           
        }
开发者ID:RRRRRRRRRR,项目名称:thegodmode.github.com,代码行数:54,代码来源:TestMatrix.cs

示例2: Main

        static void Main(string[] args)
        {
            var rows = 4;
            var cols = 4;
            var matrix = new Matrix<int>(rows, cols);

            var counter = 0;
            for (int row = 0; row < rows; row++)
            {
                for (int col = 0; col < cols; col++)
                {
                    matrix[row, col] = counter++;
                }
            }

            var getRow = 1;
            var getCol = 1;
            matrix.PrintMatrix();
            Console.WriteLine("matrix[{0}, {1}] = {2}", getRow, getCol, matrix[1, 1]);

            var matrixOne = new Matrix<int>(2, 2);
            matrixOne[0, 0] = 1;
            matrixOne[0, 1] = 2;
            matrixOne[1, 0] = 3;
            matrixOne[1, 1] = 4;

            var matrixTwo = new Matrix<int>(2, 2);
            matrixTwo[0, 0] = 5;
            matrixTwo[0, 1] = 6;
            matrixTwo[1, 0] = 7;
            matrixTwo[1, 1] = 8;

            Console.WriteLine(new string('-', 10));

            Console.WriteLine("Matrix (a)");
            Console.WriteLine(new string('-', 10));

            matrixOne.PrintMatrix();
            Console.WriteLine(new string('-', 10));
            Console.WriteLine("Matrix (b)");
            Console.WriteLine(new string('-', 10));

            matrixTwo.PrintMatrix();
            Console.WriteLine(new string('=', 10));
            Console.WriteLine("Plus (a + b)");
            Console.WriteLine("Equals (=)");
            var matrixPlus = matrixOne + matrixTwo;
            matrixPlus.PrintMatrix();

            Console.WriteLine(new string('=', 10));
            Console.WriteLine("Minus (a - b)");
            Console.WriteLine("Equals (=)");
            var matrixMinus = matrixOne - matrixTwo;
            matrixMinus.PrintMatrix();

            // for more info:
            // http://www.mathsisfun.com/algebra/matrix-multiplying.html
            var mOne = new Matrix<int>(2, 3);
            mOne[0, 0] = 1;
            mOne[0, 1] = 2;
            mOne[0, 2] = 3;
            mOne[1, 0] = 4;
            mOne[1, 1] = 5;
            mOne[1, 2] = 6;

            var mTwo = new Matrix<int>(3, 2);
            mTwo[0, 0] = 7;
            mTwo[0, 1] = 8;
            mTwo[1, 0] = 9;
            mTwo[1, 1] = 10;
            mTwo[2, 0] = 11;
            mTwo[2, 1] = 12;

            Console.WriteLine(new string('-', 10));

            Console.WriteLine("Matrix (A)");
            mOne.PrintMatrix();
            Console.WriteLine(new string('-', 10));
            Console.WriteLine("Matrix (B)");
            mTwo.PrintMatrix();
            Console.WriteLine(new string('-', 10));

            Console.WriteLine(new string('=', 10));
            Console.WriteLine("Multiply (A * B)");
            Console.WriteLine("Equals (=)");
            var matrixMultiply = mOne * mTwo;
            matrixMultiply.PrintMatrix();
        }
开发者ID:monikaBchvarova,项目名称:C-Sharp,代码行数:88,代码来源:Test.cs

示例3: Main

        private static void Main(string[] args)
        {
            var matrixOne = new Matrix<int>(2, 2);
            matrixOne[0, 0] = 1;
            matrixOne[0, 1] = 2;
            matrixOne[1, 0] = 3;
            matrixOne[1, 1] = 4;

            var matrixTwo = new Matrix<int>(2, 2);
            matrixTwo[0, 0] = 0;
            matrixTwo[0, 1] = 6;
            matrixTwo[1, 0] = 7;
            matrixTwo[1, 1] = 8;

            Console.WriteLine(new string('-', 10));

            Console.WriteLine("Matrix (a)");
            Console.WriteLine(new string('-', 10));

            matrixOne.PrintMatrix();
            Console.WriteLine(new string('-', 10));
            Console.WriteLine("Matrix (b)");
            Console.WriteLine(new string('-', 10));

            matrixTwo.PrintMatrix();
            Console.WriteLine(new string('=', 10));
            Console.WriteLine("Plus (a + b)");
            Console.WriteLine("Equals (=)");
            var matrixPlus = matrixOne + matrixTwo;
            matrixPlus.PrintMatrix();

            Console.WriteLine(new string('=', 10));
            Console.WriteLine("Minus (a - b)");
            Console.WriteLine("Equals (=)");
            var matrixMinus = matrixOne - matrixTwo;
            matrixMinus.PrintMatrix();

            var mOne = new Matrix<int>(2, 3);
            mOne[0, 0] = 1;
            mOne[0, 1] = 2;
            mOne[0, 2] = 3;
            mOne[1, 0] = 4;
            mOne[1, 1] = 5;
            mOne[1, 2] = 6;

            var mTwo = new Matrix<int>(3, 2);
            mTwo[0, 0] = 7;
            mTwo[0, 1] = 8;
            mTwo[1, 0] = 9;
            mTwo[1, 1] = 10;
            mTwo[2, 0] = 11;
            mTwo[2, 1] = 12;

            Console.WriteLine(new string('-', 10));

            Console.WriteLine("Matrix (A)");
            mOne.PrintMatrix();
            Console.WriteLine(new string('-', 10));
            Console.WriteLine("Matrix (B)");
            mTwo.PrintMatrix();
            Console.WriteLine(new string('-', 10));

            Console.WriteLine(new string('=', 10));
            Console.WriteLine("Multiply (A * B)");
            Console.WriteLine("Equals (=)");
            var matrixMultiply = mOne*mTwo;
            matrixMultiply.PrintMatrix();

            Console.WriteLine(new string('=', 10));

            matrixOne.PrintMatrix();

            if (matrixOne)
            {
                Console.WriteLine("Matrix has ZERO value");
            }
            else
            {
                Console.WriteLine("Does NOT have ZERO value");
            }

            Console.WriteLine(new string('=', 10));

            matrixTwo.PrintMatrix();
            if (matrixTwo)
            {
                Console.WriteLine("Matrix has ZERO value");
            }
            else
            {
                Console.WriteLine("Does NOT have ZERO value");
            }

            Console.WriteLine(new string('=', 10));
        }
开发者ID:monikaBchvarova,项目名称:C-Sharp,代码行数:95,代码来源:MatrixTest.cs


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