Mentions légales du service

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

Add MatDense<FPP, Cpu>::setRand.

parent f50a60c6
Branches
Tags 3.35.17
No related merge requests found
Pipeline #834126 skipped
......@@ -15,29 +15,29 @@ int main(int argc, char* argv[])
faust_unsigned_int dim1 = 3;
faust_unsigned_int dim2 = 4;
MatDense<FPP,Cpu>* M;
MatDense<FPP,Cpu> M(dim1, dim2);
MatDense<FPP,Cpu> M_copy;
M = MatDense<FPP,Cpu>::randMat(dim1,dim2);
M_copy = *M;
M.setRand();
M_copy = M;
cout<<"mat value"<<endl;
M->Display();
M.Display();
M->conjugate(false);
M.conjugate(false);
cout<<"conjugate mat value (without eval)"<<endl;
M->Display();
M.Display();
M->transpose();
M.transpose();
cout<<"conjugate-transpose mat value (with eval)"<<endl;
M->Display();
M.Display();
M->conjugate();
M.conjugate();
cout << "transpose mat value from conjugate-transpose (with eval)" << endl;
M->Display();
M.Display();
M->transpose();
assert(M->isEqual(M_copy));
M.transpose();
assert(M.isEqual(M_copy));
cout << "mat value:" << endl;
M->Display();
M.Display();
return 0;
}
......@@ -264,6 +264,10 @@ namespace Faust
// \brief Sets all nonzeros to one.
void setNZtoOne();
// \brief Sets the matrix to random values.
// \note using this function is preferable instead of using randMat functions.
void setRand();
//! \brief Returns the identity matrix.
static MatDense<FPP,Cpu> eye(faust_unsigned_int nrows, faust_unsigned_int ncols);
......
......@@ -261,6 +261,15 @@ namespace Faust
isZeros = false;
}
template<typename FPP>
void MatDense<FPP,Cpu>::setRand()
{
mat = EigDenseMat::Random(mat.rows(), mat.cols());
isZeros = false;
this->is_identity = false;
}
template<typename FPP>
void MatDense<FPP, Cpu>::setNZtoOne()
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment