Mentions légales du service

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

Add Faust::Vect::Rand/setRand().

parent 6a93d779
No related branches found
No related tags found
No related merge requests found
......@@ -193,6 +193,8 @@ namespace Faust
bool equality(Vect<FPP,Cpu> const &x, FPP precision) const;
FPP mean();
static Faust::Vect<FPP, Cpu>* rand(faust_unsigned_int size);
void setRand();
// friend algebra
friend void Faust::gemv<>(const Faust::MatDense<FPP,Cpu> & A,const Faust::Vect<FPP,Cpu> & x,Faust::Vect<FPP,Cpu> & y,const FPP & alpha, const FPP & beta, char typeA);
......
......@@ -309,4 +309,27 @@ FPP Faust::Vect<FPP, Cpu>::normL1() const
sum += std::abs(vec.data()[j]);
return sum;
}
template<typename FPP>
Faust::Vect<FPP, Cpu>* Faust::Vect<FPP, Cpu>::rand(faust_unsigned_int size)
{
Faust::Vect<FPP, Cpu>* v = nullptr;
try
{
v = new Faust::Vect<FPP, Cpu>(size);
v->setRand();
}
catch(std::bad_alloc e)
{
// std::cerr << "Out of memory." << std::endl;
}
return v;
}
template<typename FPP>
void Faust::Vect<FPP, Cpu>::setRand()
{
vec = Eigen::Matrix<FPP, Eigen::Dynamic, 1>::Random(this->size(), 1);
}
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment