Mentions légales du service

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

Add GPU2 MatButterfly::toMatSparse and its unit test.

parent 60c4a73f
No related branches found
No related tags found
No related merge requests found
......@@ -80,6 +80,17 @@ void test_get_type(MatButterfly<FPP, GPU2> &gpu_bm, MatButterfly<FPP, Cpu> &cpu_
cout << "OK" << endl;
}
void test_toMatSparse(MatButterfly<FPP, GPU2> &gpu_bm, MatButterfly<FPP, Cpu> &cpu_bm)
{
cout << "Test MatButterfly<FPP, GPU2>::toMatSparse()" << endl;
MatSparse<FPP, Cpu> sp_test;
gpu_bm.toMatSparse().tocpu(sp_test);
MatDense<FPP, Cpu> ds_test(sp_test);
MatDense<FPP, Cpu> ds_ref(cpu_bm.toMatSparse());
assert(verifyMatEq(ds_ref, ds_test));
cout << "OK" << endl;
}
int main(int argc, char** argv)
{
Faust::enable_gpu_mod();
......@@ -100,6 +111,7 @@ int main(int argc, char** argv)
test_get_nbrowcol(gpu_bm, cpu_bm);
test_get_type(gpu_bm, cpu_bm);
test_mul_matsparse(gpu_bm, cpu_bm);
test_toMatSparse(gpu_bm, cpu_bm);
return 0;
}
......@@ -48,6 +48,7 @@ namespace Faust
Real<FPP> norm() const;*/
void multiply(MatDense<FPP, GPU2> &other, const char op_this);
void multiply(MatSparse<FPP, GPU2> &other, const char op_this);
MatSparse<FPP, GPU2> toMatSparse();
};
}
......
......@@ -42,4 +42,14 @@ namespace Faust
this->multiply(Y, opThis);
M = Y;
}
template<typename FPP>
MatSparse<FPP, GPU2> MatButterfly<FPP, GPU2>::toMatSparse()
{
MatSparse<FPP, GPU2> sp(this->getNbRow(), this->getNbCol());
sp.setEyes();
multiply(sp, 'N');
return sp;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment