diff --git a/t.cc b/t.cc index 09f7c89..6e00ecb 100644 --- a/t.cc +++ b/t.cc @@ -2574,12 +2574,13 @@ cout < & NRVec::operator=(const NRVec &rhs) { * @param[in] n requested size ******************************************************************************/ template -void NRVec::resize(const int n, const bool preserve) +void NRVec::resize(const int n, const bool preserve, const bool preserve_at_end) { #ifdef DEBUG if(n < 0) laerror("illegal dimension in NRVec::resize"); @@ -1254,18 +1263,36 @@ if(nnnnold) memset(v+nnold,0,(nn-nnold)*sizeof(T)); //just zero the new memory + if(preserve_at_end) + { + for(int i=0; innold) memset(v,0,(nn-nnold)*sizeof(T)); //just zero the new memory + } + else + { + for(int i=0; innold) memset(v+nnold,0,(nn-nnold)*sizeof(T)); //just zero the new memory + } if(do_delete) delete[] vold; #ifdef CUDALA } else { //!!!works only with plain data - cublasSetVector(nnmin, sizeof(T), vold, 1, v, 1); - TEST_CUBLAS("cublasSetVector"); - T a(0); - if(nn>nnold) smart_gpu_set(nn-nnold, a, v+nnold); + if(preserve_at_end) + { + cublasSetVector(nnmin, sizeof(T), vold+nnold-nnmin, 1, v+nn-nnmin, 1); + TEST_CUBLAS("cublasSetVector"); + T a(0); + if(nn>nnold) smart_gpu_set(nn-nnold, a, v); + } + else + { + cublasSetVector(nnmin, sizeof(T), vold, 1, v, 1); + TEST_CUBLAS("cublasSetVector"); + T a(0); + if(nn>nnold) smart_gpu_set(nn-nnold, a, v+nnold); + } if(do_delete) gpufree(vold); } #endif