?? matrixqr.cpp
字號:
//MatrixQR.cpp
//用豪斯荷爾德(Householder)變換對一般m*n階的實矩陣進行QR分解
#include <iostream> //輸入輸出流
#include "Matrix.h" //矩陣類及相關(guān)函數(shù)等的定義
using namespace std; //名字空間
void main() // 定義控制臺應(yīng)用程序的入口點
{
const double dma[4][3] =
{
{ 1.0, 1.0, -1.0},
{ 2.0, 1.0, 0.0},
{ 1.0, -1.0, 0.0},
{-1.0, 2.0, 1.0}
};
matrix<double> matA(&dma[0][0], 4, 3); //生成A陣
matrix<double> matQ(4, 4); //定義存放Q陣的矩陣對象
cout << "matA : " << endl;
MatrixLinePrint(matA); //按行輸出矩陣matA
cout << endl << "matQ : " << endl;
if(MatrixQR(matA, matQ)) //生成Q陣,且R陣在matA右上三角
MatrixLinePrint(matQ); //按行輸出矩陣matQ
cout << endl << "matR : " << endl;
MatrixLinePrint(matA); //按行輸出矩陣matR
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -