Décomposition de Cholesky
Hello,
Je suis un débutant en c++ qui cherche à calculer la racine carrée d'une matrice par la décomposition de Cholesky.
J'ai trouvé une bibliothèque qui fournit une fonction Cholesky. http://www.robertnz.net/download.html.
Cette fonction demande en paramètre une matrice de variance-covariance de type const SymmetricMatrix&.
C'est la que ça coince, je n'arrive pas à construire la classe SymmetricMatrix (ça pourra également coincer plus tard mais je n'en suis qu'au début). Lorsque j'essaie de mettre des données dans la matrice de type const SymmetricMatrix, j'ai droit à plusieurs erreurs.
Erreur 1:
'initializing' : cannot convert from 'int' to 'SymmetricMatrix &'
Erreur 2:
error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'Correl' (or there is no acceptable conversion)
Avec ces suggestions:
1> c:\program files\microsoft visual studio 8\vc\include\newmat.h(520): could be 'void GeneralMatrix::operator <<(const double *)'
1> c:\program files\microsoft visual studio 8\vc\include\newmat.h(521): or 'void GeneralMatrix::operator <<(const float *)'
1> c:\program files\microsoft visual studio 8\vc\include\newmat.h(522): or 'void GeneralMatrix::operator <<(const int *)'
1> c:\program files\microsoft visual studio 8\vc\include\newmat.h(523): or 'void GeneralMatrix::operator <<(const BaseMatrix &)'
1> c:\program files\microsoft visual studio 8\vc\include\newmat.h(576): or 'MatrixInput GeneralMatrix::operator <<(double)'
1> c:\program files\microsoft visual studio 8\vc\include\newmat.h(577): or 'MatrixInput GeneralMatrix::operator <<(float)'
1> c:\program files\microsoft visual studio 8\vc\include\newmat.h(578): or 'MatrixInput GeneralMatrix::operator <<(int)'
1> while trying to match the argument list '(SymmetricMatrix, Correl)'
1>h:\vba appl\alpha_project\alpha_project\alpha_project.cpp(36) :
Erreur 3:
error C2679: binary '=' : no operator found which takes a right-hand operand of type 'Correl' (or there is no acceptable conversion)
Avec ces suggestions:
1> c:\program files\microsoft visual studio 8\vc\include\newmat.h(633): could be 'void Matrix::operator =(const BaseMatrix &)'
1> c:\program files\microsoft visual studio 8\vc\include\newmat.h(634): or 'void Matrix::operator =(Real)'
1> c:\program files\microsoft visual studio 8\vc\include\newmat.h(635): or 'void Matrix::operator =(const Matrix &)'
1> while trying to match the argument list '(Matrix, Correl)'
1>Build log was saved at "file://h:\VBA appl\Alpha_Project\Alpha_Project\Debug\BuildLog.htm"
1>Alpha_Project - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
#include "stdafx.h"
#include "newmatap.h"
#include <math.h>
#include <vector>
#include <iostream>
class Correl
{
public:
double Input[2][2];
Correl(double covx, double covyx, double covxy, double covyy)
{
Input[0][0]=covx;
Input[0][1]=covyx;
Input[1][0]=covxy;
Input[1][1]=covyy;
}
};
int _tmain(int argc, _TCHAR* argv[])
{
Correl PourTruc(1,1,1,1);
Matrix lb(2,2);
SymmetricMatrix& Truc(2);
Truc << PourTruc;
lb=PourTruc;
return 0;
} |
En gros mon problème est comment passer en paramètres la matrice d'input.
Si quelqu'un à une solution qui passe par une autre voie que la librairy newmat, je suis également preneur...
Merci par avance,