ALPSCore reference
outer_product.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1998-2018 ALPS Collaboration. See COPYRIGHT.TXT
3  * All rights reserved. Use is subject to license terms. See LICENSE.TXT
4  * For use in publications, see ACKNOWLEDGE.TXT
5  */
6 
7 #ifndef ALPS_NUMERIC_OUTER_PRODUCT_HPP
8 #define ALPS_NUMERIC_OUTER_PRODUCT_HPP
9 
14 
15 #include <complex>
16 #include <type_traits>
17 
18 namespace alps { namespace numeric {
19 
20 template <class T>
21 inline
22 typename std::enable_if<!is_sequence<T>::value,typename covariance_type<T>::type>::type
23 outer_product(T a, T b)
24 {
25  return a*b;
26 }
27 
28 
29 template <class T>
30 inline std::complex<T> outer_product(std::complex<T> const& a, std::complex<T> const& b)
31 {
32  return std::conj(a)*b;
33 }
34 
35 
36 template <class T>
37 inline
38 typename std::enable_if<is_sequence<T>::value,typename covariance_type<T>::type>::type
39 outer_product(T a, T b)
40 {
41  throw std::logic_error("Outer product beween vectors is not implemented. "
42  "Please use the new ALEA library if you need vector-vector covariance!");
43 }
44 
45 } } // end namespace alps::numeric
46 
47 #endif // ALPS_NUMERIC_OUTER_PRODUCT_HPP
std::enable_if<!is_sequence< T >::value, typename covariance_type< T >::type >::type outer_product(T a, T b)
std::conditional< is_sequence< T >::value, detail::matrix_covariance_type< typename average_type< typename element_type< T >::type >::type >, typename average_type< T >::type >::type type