implemented complex conjugation method where it was not available yet
This commit is contained in:
51
vec.cc
51
vec.cc
@@ -903,6 +903,57 @@ void NRVec<T>::storesubvector(const NRVec<int> &selection, const NRVec &rhs)
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************************//**
|
||||
* conjugate this general vector
|
||||
* @return reference to the (unmodified) matrix
|
||||
******************************************************************************/
|
||||
template<typename T>
|
||||
NRVec<T>& NRVec<T>::conjugateme() {
|
||||
#ifdef CUDALA
|
||||
if(location != cpu) laerror("general conjugation only on CPU");
|
||||
#endif
|
||||
for(int i=0; i<nn; ++i) v[i] = LA_traits<T>::conjugate(v[i]);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************//**
|
||||
* conjugate this complex vector
|
||||
* @return reference to the modified matrix
|
||||
******************************************************************************/
|
||||
template<>
|
||||
NRVec<std::complex<double> >& NRVec<std::complex<double> >::conjugateme() {
|
||||
copyonwrite();
|
||||
#ifdef CUDALA
|
||||
if(location == cpu){
|
||||
#endif
|
||||
cblas_dscal((size_t)nn, -1.0, ((double *)v) + 1, 2);
|
||||
#ifdef CUDALA
|
||||
}else{
|
||||
cublasDscal((size_t)nn, -1.0, ((double *)v) + 1, 2);
|
||||
}
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<>
|
||||
NRVec<std::complex<float> >& NRVec<std::complex<float> >::conjugateme() {
|
||||
copyonwrite();
|
||||
#ifdef CUDALA
|
||||
if(location == cpu){
|
||||
#endif
|
||||
cblas_sscal((size_t)nn, -1.0, ((float *)v) + 1, 2);
|
||||
#ifdef CUDALA
|
||||
}else{
|
||||
cublasSscal((size_t)nn, -1.0, ((float *)v) + 1, 2);
|
||||
}
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/***************************************************************************//**
|
||||
|
||||
Reference in New Issue
Block a user