Mentions légales du service

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

Add MatDense::get_cols(vector<int>) and MatDense::setOnes().

parent 661a37f2
Branches
No related tags found
No related merge requests found
...@@ -270,6 +270,9 @@ void spgemm(const Faust::MatSparse<FPP,Cpu> & A,const Faust::MatDense<FPP,Cpu> & ...@@ -270,6 +270,9 @@ void spgemm(const Faust::MatSparse<FPP,Cpu> & A,const Faust::MatDense<FPP,Cpu> &
//! \brief Check if the dimension of the matrix are consistent, if not throws an error //! \brief Check if the dimension of the matrix are consistent, if not throws an error
void check_dim_validity(); void check_dim_validity();
//! \brief Set all matrix coefficients to one.
void setOnes();
//! \brief Set the matrix to the zero matrix //! \brief Set the matrix to the zero matrix
void setZeros(); void setZeros();
...@@ -397,6 +400,8 @@ void spgemm(const Faust::MatSparse<FPP,Cpu> & A,const Faust::MatDense<FPP,Cpu> & ...@@ -397,6 +400,8 @@ void spgemm(const Faust::MatSparse<FPP,Cpu> & A,const Faust::MatDense<FPP,Cpu> &
Faust::Vect<FPP,Cpu> get_row(faust_unsigned_int id) const; Faust::Vect<FPP,Cpu> get_row(faust_unsigned_int id) const;
Faust::MatDense<FPP,Cpu>* get_cols(faust_unsigned_int start_col_id, faust_unsigned_int num_cols) const; Faust::MatDense<FPP,Cpu>* get_cols(faust_unsigned_int start_col_id, faust_unsigned_int num_cols) const;
Faust::MatDense<FPP,Cpu>* get_cols(faust_unsigned_int* col_ids, faust_unsigned_int n) const; Faust::MatDense<FPP,Cpu>* get_cols(faust_unsigned_int* col_ids, faust_unsigned_int n) const;
Faust::MatDense<FPP,Cpu>* get_cols(vector<int> col_ids) const;
Faust::MatDense<FPP,Cpu>* get_rows(faust_unsigned_int start_row_id, faust_unsigned_int num_rows) const; Faust::MatDense<FPP,Cpu>* get_rows(faust_unsigned_int start_row_id, faust_unsigned_int num_rows) const;
Faust::MatDense<FPP,Cpu>* get_rows(faust_unsigned_int* row_ids, faust_unsigned_int n) const; Faust::MatDense<FPP,Cpu>* get_rows(faust_unsigned_int* row_ids, faust_unsigned_int n) const;
......
...@@ -152,6 +152,15 @@ void Faust::MatDense<FPP,Cpu>::check_dim_validity() ...@@ -152,6 +152,15 @@ void Faust::MatDense<FPP,Cpu>::check_dim_validity()
t_check_dim.stop(); t_check_dim.stop();
#endif #endif
}
template<typename FPP>
void Faust::MatDense<FPP,Cpu>::setOnes()
{
FPP* ptr_data = getData();
for (int i=0 ; i<this->dim1*this->dim2; i++)
ptr_data[i] = FPP(1.0);
isZeros = false;
isIdentity = false;
} }
template<typename FPP> template<typename FPP>
...@@ -903,6 +912,19 @@ Faust::MatDense<FPP,Cpu>* Faust::MatDense<FPP,Cpu>::get_cols(faust_unsigned_int* ...@@ -903,6 +912,19 @@ Faust::MatDense<FPP,Cpu>* Faust::MatDense<FPP,Cpu>::get_cols(faust_unsigned_int*
return cols; return cols;
} }
template<typename FPP>
Faust::MatDense<FPP,Cpu>* Faust::MatDense<FPP,Cpu>::get_cols(vector<int> col_ids) const
{
//TODO: check args
int n = col_ids.size();
FPP *data = new FPP[this->getNbRow()*n];
for(int i=0; i<n;i++)
memcpy(data+i*this->getNbRow(), getData()+col_ids[i]*this->getNbRow(), this->getNbRow()*sizeof(FPP));
Faust::MatDense<FPP, Cpu>* cols = new Faust::MatDense<FPP, Cpu>(data, this->getNbRow(), n);
delete[] data;
return cols;
}
template<typename FPP> template<typename FPP>
Faust::MatDense<FPP,Cpu>* Faust::MatDense<FPP,Cpu>::get_rows(faust_unsigned_int start_row_id, faust_unsigned_int num_rows) const Faust::MatDense<FPP,Cpu>* Faust::MatDense<FPP,Cpu>::get_rows(faust_unsigned_int start_row_id, faust_unsigned_int num_rows) const
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment