Mentions légales du service

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

Make optional to multiply the permutation to the last butterfly.

parent 72998d8f
Branches
Tags
No related merge requests found
...@@ -49,7 +49,7 @@ namespace Faust ...@@ -49,7 +49,7 @@ namespace Faust
Faust::TransformHelper<FPP, Cpu>* butterfly_hierarchical_balanced(const Faust::MatDense<FPP, Cpu>& A, const std::vector<Faust::MatSparse<FPP, Cpu>*> &supports, FactMeth meth = LIFTING); Faust::TransformHelper<FPP, Cpu>* butterfly_hierarchical_balanced(const Faust::MatDense<FPP, Cpu>& A, const std::vector<Faust::MatSparse<FPP, Cpu>*> &supports, FactMeth meth = LIFTING);
template<typename FPP> template<typename FPP>
Faust::TransformHelper<FPP, Cpu>* butterfly_hierarchical(const Faust::MatDense<FPP, Cpu>& A, const ButterflyFactDir &dir=RIGHT, Faust::MatSparse<FPP, Cpu>* P=nullptr); Faust::TransformHelper<FPP, Cpu>* butterfly_hierarchical(const Faust::MatDense<FPP, Cpu>& A, const ButterflyFactDir &dir=RIGHT, Faust::MatSparse<FPP, Cpu>* P=nullptr, const bool mul_perm=true);
}; };
......
...@@ -658,7 +658,7 @@ namespace Faust ...@@ -658,7 +658,7 @@ namespace Faust
} }
template<typename FPP> template<typename FPP>
Faust::TransformHelper<FPP, Cpu>* butterfly_hierarchical(const Faust::MatDense<FPP, Cpu>& A, const ButterflyFactDir &dir/*=RIGHT*/, Faust::MatSparse<FPP, Cpu>* P/*=nullptr*/) Faust::TransformHelper<FPP, Cpu>* butterfly_hierarchical(const Faust::MatDense<FPP, Cpu>& A, const ButterflyFactDir &dir/*=RIGHT*/, Faust::MatSparse<FPP, Cpu>* P/*=nullptr*/, const bool mul_perm /*= true*/)
{ {
double log2_size = log2((double)A.getNbRow()); double log2_size = log2((double)A.getNbRow());
if(A.getNbRow() != A.getNbCol()) if(A.getNbRow() != A.getNbCol())
...@@ -690,18 +690,26 @@ namespace Faust ...@@ -690,18 +690,26 @@ namespace Faust
const MatSparse<FPP, Cpu>* sp_last_fac; const MatSparse<FPP, Cpu>* sp_last_fac;
const MatDense<FPP, Cpu>* ds_last_fac; const MatDense<FPP, Cpu>* ds_last_fac;
auto new_last_fac = new MatSparse<FPP, Cpu>(*P); auto new_last_fac = new MatSparse<FPP, Cpu>(*P);
if(sp_last_fac = dynamic_cast<const MatSparse<FPP, Cpu>*>(th->get_gen_fact(th->size()-1))) if(mul_perm)
{ {
sp_last_fac->multiply(*new_last_fac, 'N'); if(sp_last_fac = dynamic_cast<const MatSparse<FPP, Cpu>*>(th->get_gen_fact(th->size()-1)))
{
sp_last_fac->multiply(*new_last_fac, 'N');
}
else if(ds_last_fac = dynamic_cast<const MatDense<FPP, Cpu>*>(th->get_gen_fact(th->size()-1)))
{
ds_last_fac->multiply(*new_last_fac, 'N');
}
else
// it can't happen but still
throw std::runtime_error("butterfly supports only MatSparse and MatDense matrix");
th->replace(new_last_fac, th->size()-1);
} }
else if(ds_last_fac = dynamic_cast<const MatDense<FPP, Cpu>*>(th->get_gen_fact(th->size()-1))) else
{ {
ds_last_fac->multiply(*new_last_fac, 'N'); // the permutation is not multiplied
th->push_back(new_last_fac);
} }
else
// it can't happen but still
throw std::runtime_error("butterfly supports only MatSparse and MatDense matrix");
th->replace(new_last_fac, th->size()-1);
if(Pt != nullptr) if(Pt != nullptr)
delete Pt; delete Pt;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment