Commit 1e583942 authored by Alexander Alekhin's avatar Alexander Alekhin

core(lda): don't perform calculations in constructor

- exceptions from constructor will not cause destructor calls
parent 68946510
...@@ -903,19 +903,19 @@ public: ...@@ -903,19 +903,19 @@ public:
// given in src. This function is a port of the EigenvalueSolver in JAMA, // given in src. This function is a port of the EigenvalueSolver in JAMA,
// which has been released to public domain by The MathWorks and the // which has been released to public domain by The MathWorks and the
// National Institute of Standards and Technology (NIST). // National Institute of Standards and Technology (NIST).
EigenvalueDecomposition(InputArray src, bool fallbackSymmetric = true) : EigenvalueDecomposition() :
n(0), n(0),
d(NULL), e(NULL), ort(NULL), d(NULL), e(NULL), ort(NULL),
V(NULL), H(NULL) V(NULL), H(NULL)
{ {
compute(src, fallbackSymmetric); // nothing
} }
// This function computes the Eigenvalue Decomposition for a general matrix // This function computes the Eigenvalue Decomposition for a general matrix
// given in src. This function is a port of the EigenvalueSolver in JAMA, // given in src. This function is a port of the EigenvalueSolver in JAMA,
// which has been released to public domain by The MathWorks and the // which has been released to public domain by The MathWorks and the
// National Institute of Standards and Technology (NIST). // National Institute of Standards and Technology (NIST).
void compute(InputArray src, bool fallbackSymmetric) void compute(InputArray src, bool fallbackSymmetric = true)
{ {
CV_INSTRUMENT_REGION(); CV_INSTRUMENT_REGION();
...@@ -970,7 +970,8 @@ void eigenNonSymmetric(InputArray _src, OutputArray _evals, OutputArray _evects) ...@@ -970,7 +970,8 @@ void eigenNonSymmetric(InputArray _src, OutputArray _evals, OutputArray _evects)
else else
src64f = src; src64f = src;
EigenvalueDecomposition eigensystem(src64f, false); EigenvalueDecomposition eigensystem;
eigensystem.compute(src64f, false);
// EigenvalueDecomposition returns transposed and non-sorted eigenvalues // EigenvalueDecomposition returns transposed and non-sorted eigenvalues
std::vector<double> eigenvalues64f; std::vector<double> eigenvalues64f;
...@@ -1146,7 +1147,8 @@ void LDA::lda(InputArrayOfArrays _src, InputArray _lbls) { ...@@ -1146,7 +1147,8 @@ void LDA::lda(InputArrayOfArrays _src, InputArray _lbls) {
// M = inv(Sw)*Sb // M = inv(Sw)*Sb
Mat M; Mat M;
gemm(Swi, Sb, 1.0, Mat(), 0.0, M); gemm(Swi, Sb, 1.0, Mat(), 0.0, M);
EigenvalueDecomposition es(M); EigenvalueDecomposition es;
es.compute(M);
_eigenvalues = es.eigenvalues(); _eigenvalues = es.eigenvalues();
_eigenvectors = es.eigenvectors(); _eigenvectors = es.eigenvectors();
// reshape eigenvalues, so they are stored by column // reshape eigenvalues, so they are stored by column
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment