Mentions légales du service

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

Update TransformHelperPoly functions.

- minor change in polyFaust: use of copy_sp_mat.
- Allow to set an arbitrary T0 polynomial in basisChebyshev.
parent 1e928020
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
namespace Faust namespace Faust
{ {
template<typename FPP> template<typename FPP>
TransformHelper<FPP, Cpu>* basisChebyshev(MatSparse<FPP,Cpu>* L, int32_t K); TransformHelper<FPP, Cpu>* basisChebyshev(MatSparse<FPP,Cpu>* L, int32_t K, MatSparse<FPP, Cpu>* T0=nullptr);
template<typename FPP> template<typename FPP>
void poly(int d, int K, int n, const FPP* basisX, const FPP* coeffs, FPP* out); void poly(int d, int K, int n, const FPP* basisX, const FPP* coeffs, FPP* out);
...@@ -37,7 +37,7 @@ namespace Faust ...@@ -37,7 +37,7 @@ namespace Faust
void poly(int d, int n, const FPP* basisX, const FPP* coeffs, FPP* out); void poly(int d, int n, const FPP* basisX, const FPP* coeffs, FPP* out);
TransformHelper<FPP, Cpu>* polyFaust(const FPP* coeffs); TransformHelper<FPP, Cpu>* polyFaust(const FPP* coeffs);
~TransformHelperPoly(); ~TransformHelperPoly();
friend TransformHelper<FPP,Cpu>* basisChebyshev<>(MatSparse<FPP,Cpu>* L, int32_t K); friend TransformHelper<FPP,Cpu>* basisChebyshev<>(MatSparse<FPP,Cpu>* L, int32_t K, MatSparse<FPP, Cpu>* T0);
}; };
......
...@@ -174,6 +174,7 @@ namespace Faust ...@@ -174,6 +174,7 @@ namespace Faust
return basisP; return basisP;
} }
template<typename FPP> template<typename FPP>
TransformHelper<FPP, Cpu>* TransformHelperPoly<FPP>::polyFaust(const FPP* coeffs) TransformHelper<FPP, Cpu>* TransformHelperPoly<FPP>::polyFaust(const FPP* coeffs)
{ {
...@@ -187,16 +188,21 @@ namespace Faust ...@@ -187,16 +188,21 @@ namespace Faust
Id.resize(d, d, d); Id.resize(d, d, d);
Id.setEyes(); Id.setEyes();
coeffDiags = Id; coeffDiags = Id;
// copy_sp_mat(Id, coeffDiags);
coeffDiags *= coeffs[0]; coeffDiags *= coeffs[0];
for(int i=1;i < this->size(); i++) for(int i=1;i < this->size(); i++)
{ {
Id1 = Id; Id1 = Id;
// copy_sp_mat(Id, Id1);
Id1 *= coeffs[i]; Id1 *= coeffs[i];
tmp.hstack(coeffDiags, Id1); //TODO: hstack/vstack to concatenate "this" to argument matrix tmp.hstack(coeffDiags, Id1); //TODO: hstack/vstack to concatenate "this" to argument matrix
coeffDiags = tmp; // coeffDiags = tmp; // crash //TODO: fix
copy_sp_mat(tmp, coeffDiags);
} }
coeffDiags.set_id(false); coeffDiags.set_id(false);
facts[0] = new MatSparse<FPP,Cpu>(coeffDiags); auto fac0 = new MatSparse<FPP,Cpu>(); // ctor copy crash //TODO: fix
copy_sp_mat(coeffDiags, *fac0);
facts[0] = fac0;
for(int i=1;i <= this->size();i++) for(int i=1;i <= this->size();i++)
facts[i] = this->get_gen_fact_nonconst(i-1); facts[i] = this->get_gen_fact_nonconst(i-1);
return new TransformHelper<FPP,Cpu>(facts, (FPP) 1.0, return new TransformHelper<FPP,Cpu>(facts, (FPP) 1.0,
...@@ -225,7 +231,7 @@ namespace Faust ...@@ -225,7 +231,7 @@ namespace Faust
} }
template<typename FPP> template<typename FPP>
TransformHelper<FPP,Cpu>* basisChebyshev(MatSparse<FPP,Cpu>* L, int32_t K) TransformHelper<FPP,Cpu>* basisChebyshev(MatSparse<FPP,Cpu>* L, int32_t K, MatSparse<FPP, Cpu>* T0/*=nullptr*/)
{ {
// assuming L is symmetric // assuming L is symmetric
MatSparse<FPP,Cpu> *T1, *T2; MatSparse<FPP,Cpu> *T1, *T2;
...@@ -235,7 +241,10 @@ namespace Faust ...@@ -235,7 +241,10 @@ namespace Faust
// Identity // Identity
Id.resize(d, d, d); Id.resize(d, d, d);
Id.setEyes(); Id.setEyes();
facts[K] = new MatSparse<FPP,Cpu>(Id); if(T0 == nullptr)
facts[K] = new MatSparse<FPP,Cpu>(Id);
else
facts[K] = new MatSparse<FPP,Cpu>(*T0);
if (K > 0) if (K > 0)
{ {
// build the chebyshev polynomials by factor // build the chebyshev polynomials by factor
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment