📄 sample3_1.cs
字号:
/*
* 示例程序Sample3_1: Matrix类的基本用法
*/
using System;
using CSharpAlgorithm.Algorithm;
namespace CSharpAlgorithm.Sample
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
// 矩阵数据
double[] mtxData1 = {
1, 3, -2, 0, 4,
-2, -1, 5, -7, 2,
0, 8, 4, 1, -5,
3, -3, 2, -4, 1};
double[] mtxData2 = {
4, 2, -7, 0, 3,
9, 6, 1, 8, -2,
-4, 7, 2, -5, 5,
9, -8, 3, 6, 5};
// 构造矩阵
Matrix mtx1 = new Matrix(4, 5, mtxData1);
Matrix mtx2 = new Matrix(4, 5, mtxData2);
Matrix mtx3 = new Matrix(4, 5, mtxData1);
// 显示结果
Console.WriteLine("mtx1 = ");
Console.WriteLine(mtx1);
Console.WriteLine("\nmtx2 = ");
Console.WriteLine(mtx2);
Console.WriteLine("\nmtx3 = ");
Console.WriteLine(mtx3);
Console.WriteLine("\nmtx1的第2个列向量为(" + mtx1.ToStringCol(1, ",") + ")");
// 比较
if (mtx1.Equals(mtx2))
Console.WriteLine("\nmtx1 = mtx2");
else
Console.WriteLine("\nmtx1 != mtx2");
if (mtx1.Equals(mtx3))
Console.WriteLine("\nmtx1 = mtx3");
else
Console.WriteLine("\nmtx1 != mtx3");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -