Mentions légales du service

Skip to content
Snippets Groups Projects
Commit e2b02c6e authored by hhakim's avatar hhakim
Browse files

Fix in PALM4MSA 2020 1) the float MEG factorization warning/error 2) NaN in...

Fix in PALM4MSA 2020 1) the float MEG factorization warning/error 2) NaN in the numerator and denominator of lambda.

the 1) error was bypassed through NO_LAMBDA_ERROR env. var. but is no longer necessary by comparing the S norm to zero and not to espilon anymore.
For 2) if it happens the error is raised (except if NO_LAMBDA_ERROR is used, but the algorithm can't recover this, so that's not advisable).
parent b7943413
Branches
Tags
No related merge requests found
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "faust_MHTP.h" #include "faust_MHTP.h"
#include <functional> #include <functional>
#include <cstdlib> #include <cstdlib>
#include <cmath>
#define PALM4MSA2020_VERBOSE_CALC_ERR_ITE_PERIOD 1 // the period according to the relative error is computed and displayed in palm4msa2 #define PALM4MSA2020_VERBOSE_CALC_ERR_ITE_PERIOD 1 // the period according to the relative error is computed and displayed in palm4msa2
// this constant is overriden if the variable environment VERBOSE_CALC_ERR_ITE_PERIOD exists // this constant is overriden if the variable environment VERBOSE_CALC_ERR_ITE_PERIOD exists
......
...@@ -374,7 +374,7 @@ void Faust::update_lambda(Faust::TransformHelper<FPP,DEVICE>& S, std::vector<Tra ...@@ -374,7 +374,7 @@ void Faust::update_lambda(Faust::TransformHelper<FPP,DEVICE>& S, std::vector<Tra
gemm(A_H, S_mat, A_H_S, (FPP) 1.0, (FPP) 0.0, 'N', 'N'); gemm(A_H, S_mat, A_H_S, (FPP) 1.0, (FPP) 0.0, 'N', 'N');
tr = A_H_S.trace(); tr = A_H_S.trace();
nS = S_mat.norm(); nS = S_mat.norm();
if(std::numeric_limits<Real<FPP>>::epsilon() >= nS) if(Real<FPP>(0) == nS)
if(no_lambda_error) if(no_lambda_error)
{ {
// don't change lambda // don't change lambda
...@@ -383,6 +383,15 @@ void Faust::update_lambda(Faust::TransformHelper<FPP,DEVICE>& S, std::vector<Tra ...@@ -383,6 +383,15 @@ void Faust::update_lambda(Faust::TransformHelper<FPP,DEVICE>& S, std::vector<Tra
} }
else else
throw std::runtime_error("Error in update_lambda: S Frobenius norm is zero, can't compute lambda."); throw std::runtime_error("Error in update_lambda: S Frobenius norm is zero, can't compute lambda.");
if(std::isnan(std::real(tr)) || std::isnan(nS))
if(no_lambda_error)
{
// don't change lambda
std::cout << "WARNING: lambda didn't change because S contains NaN." << std::endl;
return;
}
else
throw std::runtime_error("Error in update_lambda: S (the Faust) contains nan elements in at least one of its matrices, can't compute lambda.");
lambda = std::real(tr)/(nS*nS); lambda = std::real(tr)/(nS*nS);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment