mirror of
https://github.com/triqs/dft_tools
synced 2024-12-25 05:43:40 +01:00
Fix #122
- the conj_ function was not written properly (T is a ref, the trait is_complex was not returning true). - a simpler version is clearly better !
This commit is contained in:
parent
7cf7d09c77
commit
e6234ed3d5
@ -33,7 +33,7 @@ template<typename Vd, typename Vi>
|
||||
void test() {
|
||||
Vd a(2),aa(2),c(2) ;a()=2.0; c() = 1;
|
||||
Vi b(2);b()=3;
|
||||
std::cout << blas::dot<false>(a,b) << std::endl;
|
||||
std::cerr << blas::dot<false>(a,b) << std::endl;
|
||||
|
||||
aa = 2*a;
|
||||
|
||||
@ -52,6 +52,18 @@ int main(int argc, char **argv) {
|
||||
|
||||
test<vector<double> , vector<int> >();
|
||||
|
||||
/// Added by I. Krivenko, #122
|
||||
/// test the complex version, specially with the zdotu workaround on Os X.
|
||||
vector<std::complex<double>> v(2);
|
||||
v(0) = 0;
|
||||
v(1) = {0, 1};
|
||||
|
||||
std::cerr << v << std::endl;
|
||||
std::cerr << blas::dot<false>(v, v) << std::endl;
|
||||
std::cerr << blas::dot<true>(v, v) << std::endl;
|
||||
assert_close( dot(v,v), -1);
|
||||
assert_close( dotc(v,v), 1);
|
||||
|
||||
// does not work for array just because of .size() vs .shape(0)...
|
||||
//test<array<double,1> , array<int,1> >();
|
||||
//test<array<double,1> , vector<int> >();
|
||||
|
@ -67,13 +67,10 @@ namespace triqs { namespace arrays { namespace blas {
|
||||
//return f77::dot(X.size(), Cx().data_start(), Cx().stride(), Cy().data_start(), Cy().stride());
|
||||
}
|
||||
|
||||
template< bool Star, typename T>
|
||||
typename std::enable_if<triqs::is_complex<T>::value && Star,T>::type
|
||||
_conj(T && x) { return conj(std::forward<T>(x));}
|
||||
|
||||
template< bool Star, typename T>
|
||||
typename std::enable_if<!( triqs::is_complex<T>::value && Star),T>::type
|
||||
_conj(T && x) { return std::forward<T>(x);}
|
||||
template <bool Star> std::complex<double> _conj(std::complex<double> const& x);
|
||||
template <> std::complex<double> _conj<true>(std::complex<double> const& x) { return conj(x); }
|
||||
template <> std::complex<double> _conj<false>(std::complex<double> const& x) { return x;}
|
||||
template <bool Star> double _conj(double x) { return x; }
|
||||
|
||||
/**
|
||||
* Calls dot product of 2 vectors.
|
||||
|
Loading…
Reference in New Issue
Block a user