implemented complex conjugation method where it was not available yet

This commit is contained in:
2024-05-03 16:56:21 +02:00
parent 518c75fb20
commit 3ba6d03eee
8 changed files with 129 additions and 11 deletions

51
vec.cc
View File

@@ -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;
}
/***************************************************************************//**