Mentions légales du service

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

Add a TransformHelper ctor signature to authorize Transform object argument to...

Add a TransformHelper ctor signature to authorize Transform object argument to be moved internally (instead of being copied).

This is an option, by default it is copied like before.
It follows the previous commit and update the test added.
parent 0f5c9f0d
Branches
Tags
No related merge requests found
......@@ -43,6 +43,7 @@
#include "faust_MatDense.h"
#include "faust_MatSparse.h"
#include "faust_Transform.h"
#include "faust_TransformHelper.h"
#include <string>
......@@ -116,5 +117,18 @@ int main(int argc, char* argv[])
assert(ref_fact == test_fact3);
}
cout << "Test move into a TransformHelper object: " << endl;
TransformHelper<FPP,Cpu> th(t3, true); //true to do a std::move(t3) in constructor
for(int i=0;i<n_mats;i++)
{
MatGeneric<FPP,Cpu>* ref_fact = facts[i];
unsigned long long test_fact4 = th.get_fact_addr(i);
cout << "orig ptr fact[" << i << "]: " << ref_fact << " the moved one by ctor: " << ((void*)test_fact4) << endl;
assert((unsigned long long) ref_fact == test_fact4);
}
return 0;
}
......@@ -88,7 +88,7 @@ namespace Faust {
TransformHelper(TransformHelper<FPP,Cpu>* th, bool transpose, bool conjugate);
TransformHelper(TransformHelper<FPP,Cpu>* th, Slice s[2]);
TransformHelper(TransformHelper<FPP,Cpu>* th, faust_unsigned_int* row_ids, faust_unsigned_int num_rows, faust_unsigned_int* col_ids, faust_unsigned_int num_cols);
TransformHelper(Transform<FPP,Cpu> &t);
TransformHelper(Transform<FPP,Cpu> &t, const bool moving=false);
Vect<FPP,Cpu> multiply(const Vect<FPP,Cpu> x) const;
Vect<FPP,Cpu> multiply(const Vect<FPP,Cpu> x, const bool transpose);
......@@ -159,6 +159,7 @@ TransformHelper(Transform<FPP,Cpu> &t);
static TransformHelper<FPP,Cpu>* fourierFaust(unsigned int n);
~TransformHelper();
unsigned long long get_fact_addr(const faust_unsigned_int id) const;
private:
void copy_slices(TransformHelper<FPP, Cpu>* th, const bool transpose = false);
const MatGeneric<FPP,Cpu>* get_gen_fact(const faust_unsigned_int id) const;
......
......@@ -200,9 +200,12 @@ namespace Faust {
}
template<typename FPP>
TransformHelper<FPP,Cpu>::TransformHelper(Transform<FPP,Cpu> &t) : is_transposed(false), is_conjugate(false), is_sliced(false), is_fancy_indexed(false)
TransformHelper<FPP,Cpu>::TransformHelper(Transform<FPP,Cpu> &t, const bool moving /* default to false */) : is_transposed(false), is_conjugate(false), is_sliced(false), is_fancy_indexed(false)
{
this->transform = make_shared<Transform<FPP,Cpu>>(t);
if(moving)
this->transform = make_shared<Transform<FPP,Cpu>>(std::move(t));
else
this->transform = make_shared<Transform<FPP,Cpu>>(t);
}
template<typename FPP>
......@@ -445,6 +448,12 @@ namespace Faust {
return this->transform->data[is_transposed?size()-id-1:id];
}
template<typename FPP>
unsigned long long TransformHelper<FPP,Cpu>::get_fact_addr(const faust_unsigned_int id) const
{
return (unsigned long long) this->transform->data[is_transposed?size()-id-1:id];
}
template<typename FPP>
void TransformHelper<FPP,Cpu>::get_fact(const faust_unsigned_int id,
const int** rowptr,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment