diff --git a/la_traits.h b/la_traits.h index 054f4e3..788db4e 100644 --- a/la_traits.h +++ b/la_traits.h @@ -296,7 +296,7 @@ static void multiput(size_t n, int fd, const std::complex *x, bool dimensions } while(total < n); } -static void copy(std::complex *dest, std::complex *src, size_t n) {memcpy(dest,src,n*sizeof(std::complex));} +static void copy(std::complex *dest, const std::complex *src, size_t n) {memcpy(dest,src,n*sizeof(std::complex));} static void clear(std::complex *dest, size_t n) {memset(dest,0,n*sizeof(std::complex));} static void copyonwrite(std::complex &x) {}; static bool is_plaindata() {return true;} @@ -356,7 +356,7 @@ static void multiput(size_t n, int fd, const C *x, bool dimensions=0) } while(total < n); } -static void copy(C *dest, C *src, size_t n) {memcpy(dest,src,n*sizeof(C));} +static void copy(C *dest, const C *src, size_t n) {memcpy(dest,src,n*sizeof(C));} static void clear(C *dest, size_t n) {memset(dest,0,n*sizeof(C));} static void copyonwrite(C &x) {}; static bool is_plaindata() {return true;} @@ -396,7 +396,7 @@ static void put(int fd, const X &x, bool dimensions=1, bool transp=0, bool or static void get(int fd, X &x, bool dimensions=1, bool transp=0, bool orcaformat=false) {x.get(fd,dimensions,transp,orcaformat);} \ static void multiput(size_t n,int fd, const X *x, bool dimensions=1, bool orcaformat=false) {for(size_t i=0; i *x, bool dimensions=1, bool orcaformat=false) {for(size_t i=0; i *dest, X *src, size_t n) {for(size_t i=0; i *dest, const X *src, size_t n) {for(size_t i=0; i *dest, size_t n) {for(size_t i=0; i &x) {x.copyonwrite();}\ static bool is_plaindata() {return false;}\ @@ -439,7 +439,7 @@ static void put(int fd, const X &x, bool dimensions=1, bool transp=0, bool or static void get(int fd, X &x, bool dimensions=1, bool transp=0, bool orcaformat=false) {x.get(fd,dimensions,false,orcaformat);} \ static void multiput(size_t n,int fd, const X *x, bool dimensions=1, bool orcaformat=false) {for(size_t i=0; i *x, bool dimensions=1, bool orcaformat=false) {for(size_t i=0; i &x) {x.copyonwrite();} \ static bool is_plaindata() {return false;}\ diff --git a/mat.cc b/mat.cc index df373e9..8d9c701 100644 --- a/mat.cc +++ b/mat.cc @@ -113,6 +113,29 @@ const NRVec NRMat::row(const int i, int l) const { return r; } + +/***************************************************************************//** + * store given row of this matrix of general type T + * @param[in] i row index starting from zero + * @param[in] l consider this value as the count of columns + ******************************************************************************/ +template +void NRMat::rowset(const NRVec &r, const int i, int l) { +#ifdef DEBUG + if(i < 0 || i >= nn) laerror("illegal index"); +#endif + if(l < 0) l = mm; + LA_traits::copy( +#ifdef MATPTR + v[i] +#else + v + i*(size_t)l +#endif + , &r[0], l); +} + + + /***************************************************************************//** * routine for raw output * @param[in] fd file descriptor for output diff --git a/mat.h b/mat.h index eba5a8e..c12d61a 100644 --- a/mat.h +++ b/mat.h @@ -266,6 +266,9 @@ public: //! get the ith row const NRVec row(const int i, int l = -1) const; + //! set the ith row + void rowset(const NRVec &r, const int i, int l = -1); + //! get the jth column const NRVec column(const int j, int l = -1) const { NOT_GPU(*this); @@ -275,6 +278,13 @@ public: return r; }; + //! set the jth column + void columnset(const NRVec &r, const int j, int l = -1) { + NOT_GPU(*this); + if(l < 0) l = nn; + for(register int i=0; i &, const bool divide = 0, bool cache = false) const; //! set diagonal elements