Mentions légales du service

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

Impl. MatButterfly::norm() with its unit test.

parent 7493b1b4
No related branches found
No related tags found
No related merge requests found
...@@ -40,7 +40,6 @@ void testClone(MatButterfly<FPP, Cpu>& butterflyMat) ...@@ -40,7 +40,6 @@ void testClone(MatButterfly<FPP, Cpu>& butterflyMat)
delete clone; delete clone;
} }
void testTranspose(MatButterfly<FPP, Cpu>& butterflyMat, MatSparse<FPP, Cpu>& spButterflyMat) void testTranspose(MatButterfly<FPP, Cpu>& butterflyMat, MatSparse<FPP, Cpu>& spButterflyMat)
{ {
auto size = butterflyMat.getNbRow(); auto size = butterflyMat.getNbRow();
...@@ -155,6 +154,14 @@ void testScalMul(const MatButterfly<FPP, Cpu>& butterflyMat, const MatSparse<FP ...@@ -155,6 +154,14 @@ void testScalMul(const MatButterfly<FPP, Cpu>& butterflyMat, const MatSparse<FP
std::cout << "MatButterfly scal. mul OK" << std::endl; std::cout << "MatButterfly scal. mul OK" << std::endl;
} }
void testNorm2(const MatButterfly<FPP, Cpu>& butterflyMat, const MatSparse<FPP, Cpu>& spButterflyMat)
{
// cout << butterflyMat.norm() << endl;
// cout << spButterflyMat.norm() << endl;
assert(std::abs(butterflyMat.norm() - spButterflyMat.norm()) < 1e-6);
std::cout << "MatButterfly fro-norm OK" << std::endl;
}
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
int log2size = 4; int log2size = 4;
...@@ -220,5 +227,6 @@ int main(int argc, char** argv) ...@@ -220,5 +227,6 @@ int main(int argc, char** argv)
testType(butterflyMat); testType(butterflyMat);
testScalMul(butterflyMat, spButterflyMat); testScalMul(butterflyMat, spButterflyMat);
testNorm2(butterflyMat, spButterflyMat);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
...@@ -292,8 +292,7 @@ namespace Faust ...@@ -292,8 +292,7 @@ namespace Faust
template<typename FPP> template<typename FPP>
matvar_t* MatButterfly<FPP, Cpu>::toMatIOVar(bool transpose, bool conjugate, const char *var_name) const matvar_t* MatButterfly<FPP, Cpu>::toMatIOVar(bool transpose, bool conjugate, const char *var_name) const
{ {
//TODO throw std::runtime_error("Saving MatButterfly to a .mat file is not supported.");
} }
template<typename FPP> template<typename FPP>
...@@ -305,7 +304,8 @@ namespace Faust ...@@ -305,7 +304,8 @@ namespace Faust
template<typename FPP> template<typename FPP>
Real<FPP> MatButterfly<FPP, Cpu>::norm() const Real<FPP> MatButterfly<FPP, Cpu>::norm() const
{ {
//TODO auto s = (D1.diagonal().array() * D1.diagonal().conjugate().array() + D2.diagonal().array() * D2.diagonal().conjugate().array()).sum();
return Faust::fabs(std::sqrt(s));
} }
template<typename FPP> template<typename FPP>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment