?? sample3_15.cs
字號(hào):
/*
* 示例程序Sample3_15: Matrix類的實(shí)對(duì)稱三對(duì)角陣的全部特征值與特征向量的計(jì)算
*/
using System;
using CSharpAlgorithm.Algorithm;
namespace CSharpAlgorithm.Sample
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
// 矩陣數(shù)據(jù)
double[] mtxData16 = {
10.0,1.0,2.0,3.0,4.0,
1.0,9.0,-1.0,2.0,-3.0,
2.0,-1.0,7.0,3.0,-5.0,
3.0,2.0,3.0,12.0,-1.0,
4.0,-3.0,-5.0,-1.0,15.0};
// 構(gòu)造矩陣
Matrix mtx16 = new Matrix(5, 5, mtxData16);
// 實(shí)對(duì)稱三對(duì)角陣的全部特征值與特征向量的計(jì)算
Matrix mtxQ2 = new Matrix();
Matrix mtxT2 = new Matrix();
double[] bArray2 = new double[mtx16.GetNumColumns()];
double[] cArray2 = new double[mtx16.GetNumColumns()];
// 1: 約化對(duì)稱矩陣為對(duì)稱三對(duì)角陣: 豪斯荷爾德變換法
if (mtx16.MakeSymTri(mtxQ2, mtxT2, bArray2, cArray2))
{
// 2: 計(jì)算全部特征值與特征向量
if (mtx16.ComputeEvSymTri(bArray2, cArray2, mtxQ2, 60, 0.0001))
{
Console.WriteLine("特征值=");
String s = "";
for (int i=0; i<mtxQ2.GetNumColumns(); ++i)
{
s += bArray2[i].ToString("F") + ", ";
}
Console.WriteLine(s);
Console.WriteLine("-------------------------------");
Console.WriteLine("對(duì)應(yīng)的特征向量=");
for (int i=0; i<mtxQ2.GetNumColumns(); ++i)
{
Console.WriteLine(mtxQ2.ToStringCol(i, ", "));
}
}
else
{
Console.WriteLine("失敗");
}
}
else
{
Console.WriteLine("失敗");
}
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -