MPD78
02-15-2010, 09:20 AM
Hello all,
In looking at the code for the struct, QRdcmp, the line containing the constructor for the matrix A is:
QRdcmp(MatDoub_I &a);
There isn't a MatDoub_O for the output. Does this mean that there isn't a way to obtain just the QR decomposition of the matrix A? (Without modifying the existing code.)
Here is my simple example program. This is modeled after this post.
http://www.nr.com/forum/showthread.php?t=1389&highlight=cholesky post #2 by davekw7x
#include "qrdcmp.h"
int main()
{
// Loop counters
Int i,j;
Int pause; // dummy variable
// Matrix size
const Int N = 3;
// Array for the constructor
const Doub a_d[N*N] = {
2.0, 1.0, 3.0,
-1.0, 0.0, 7.0,
0.0, -1.0, -1.0
};
MatDoub a(N,N,a_d);
// Perform the QR decomposition
QRdcmp qr(a);
// Send original matrix and output to the screen
cout << "The original matrix" << endl << endl;
cout << scientific << setprecision(4) << showpos;
for(i=0;i<N;i++){
for(j=0;j<N;j++){
cout << setw(15) << a_d[i * N +j];
}
cout << endl;
}
// If possible, this is where the code for the
// output of just the QR decomposition would go.
cin >> pause; // dummy variable to keep the output screen visible
return 0;
}
If it is possible to obtain just the QR decomposition, any help on how to do that would be greatly appreciated.
Thanks
Matt
In looking at the code for the struct, QRdcmp, the line containing the constructor for the matrix A is:
QRdcmp(MatDoub_I &a);
There isn't a MatDoub_O for the output. Does this mean that there isn't a way to obtain just the QR decomposition of the matrix A? (Without modifying the existing code.)
Here is my simple example program. This is modeled after this post.
http://www.nr.com/forum/showthread.php?t=1389&highlight=cholesky post #2 by davekw7x
#include "qrdcmp.h"
int main()
{
// Loop counters
Int i,j;
Int pause; // dummy variable
// Matrix size
const Int N = 3;
// Array for the constructor
const Doub a_d[N*N] = {
2.0, 1.0, 3.0,
-1.0, 0.0, 7.0,
0.0, -1.0, -1.0
};
MatDoub a(N,N,a_d);
// Perform the QR decomposition
QRdcmp qr(a);
// Send original matrix and output to the screen
cout << "The original matrix" << endl << endl;
cout << scientific << setprecision(4) << showpos;
for(i=0;i<N;i++){
for(j=0;j<N;j++){
cout << setw(15) << a_d[i * N +j];
}
cout << endl;
}
// If possible, this is where the code for the
// output of just the QR decomposition would go.
cin >> pause; // dummy variable to keep the output screen visible
return 0;
}
If it is possible to obtain just the QR decomposition, any help on how to do that would be greatly appreciated.
Thanks
Matt