Ich habe momentan einige Probs mit meinem Code, um ein Array in ein Upper (u) und ein Lower (I) Array zu zerlegen.
Ich verwende die doolittle-Methode
Mein Code:
#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 helfen, wenn du kannst ...
PS: nicht sicher, ob es hierher gehört, könnte auf der Mathematikseite besser sein
Antworten:
2 für die Antwort № 1Schau es dir an http://download.intel.com/design/PentiumIII/sml/24504601.pdf Es wurde eine Komplettlösung mit Quellcode!
1 für die Antwort № 2
Vielleicht möchten Sie QuantLib ausprobieren. http://quantlib.org/index.shtml
Hier ist ein Beispiel für Code, der die QuantLib-Bibliothek zum Zerlegen eines 3x3-Arrays verwendet. Er verwendet eine Cholesky-Zerlegung, kann aber hilfreich sein. http://quantcorner.wordpress.com/2011/02/20/matrix-decomposition-with-quantlib/
-3 für die Antwort № 3
Überprüfen Sie Ihre "s" Iteration, die es sein sollte for (int s = 0; s