/ C ++での/ LU分解 - c ++、配列

C ++でのLUの分解 - c ++、配列

私は現在、配列を上(u)と下(l)の配列に分解するコードをいくつか持っています。

私はdoolittleメソッドを使用しています

私のコード:

#include <iostream>

using namespace std;

int main(){

double a[10][10];
double l[10][10];
double u[10][10];
double som=0;
int RANG;
cin >> RANG;
for(int i=0; i<RANG; i++){
for(int j=0; j<RANG;j++){
cin >> a[i][j];
}
}
for(int i=0; i<RANG; i++){
for(int j=0; j<RANG;j++){
u[i][j]=0;
l[i][j]=0;
}
}

for(int i=0;i<RANG;i++) {
l[i][i]=1;

for(int j=i;j<RANG;j++) {
for(int s=0;s<i-1;s++) {
som+= l[i][s]*u[s][j];
}
u[i][j]=a[i][j]-som;
}

for(int k=i+1;k<RANG;k++) {
double som=0;
for(int s=0;s<i-1;s++) {
som+=l[k][s]*u[s][i];
}
l[k][i]=(a[k][i]-som)/u[i][i];
}
}
cout << "l:" << endl;
for(int i=0; i<RANG; i++){
for(int j=0; j<RANG;j++){
cout << l[i][j] << "t";
}
cout << endl << endl;
}
cout << "u: " << endl;
for(int i=0; i<RANG; i++){
for(int j=0; j<RANG;j++){
cout << u[i][j] << "t";
}
cout << endl << endl;
}
return 0;
}

できる場合はPLZヘルプ...

PS:それがここに属しているかどうかわからない、数学のサイトでより良いかもしれない

回答:

回答№1は2

見て http://download.intel.com/design/PentiumIII/sml/24504601.pdf それはソースコードと一緒に完全な解決を得ました!


回答№2の場合は1

QuantLibをチェックアウトすることができます。 http://quantlib.org/index.shtml

ここでは、QuantLibライブラリを使用して3x3配列を分解するコードの例を示します。これはコレスキー分解を使用しますが、おそらくそれは役に立ちます。 http://quantcorner.wordpress.com/2011/02/20/matrix-decomposition-with-quantlib/


回答№3の-3

あなたの "s"反復をチェックしてください for(int s = 0; s