MPQC 3.0.0-alpha
Loading...
Searching...
No Matches
permute.hpp
1#ifndef MPQC_MATH_TENSOR_PERMUTE_HPP
2#define MPQC_MATH_TENSOR_PERMUTE_HPP
3
4#include "mpqc/math/tensor/forward.hpp"
5#include "mpqc/math/tensor/exception.hpp"
6
7#include <boost/mpl/int.hpp>
8#include <boost/mpl/vector_c.hpp>
9
10namespace mpqc {
11
14
15 template<typename T, class O>
16 void permute_in_place(TensorBase<T,3,O> &t, boost::mpl::vector_c<int,1,0,2>) {
17 const typename TensorBase<T,3,O>::Dims &dims = t.dims();
18 if (dims[0] != dims[1]) {
19 throw TensorDimensionsException(0, 1, dims[0], dims[1]);
20 }
21 for (int k = 0; k < dims[2]; ++k) {
22 for (int j = 0; j < dims[1]; ++j) {
23 for (int i = 0; i < j; ++i) {
24 std::swap(t(i,j,k), t(j,i,k));
25 }
26 }
27 }
28 }
29
30 template<typename T, class O>
31 void permute_in_place(TensorBase<T,3,O> &t, boost::mpl::vector_c<int,0,2,1>) {
32 const typename TensorBase<T,3,O>::Dims &dims = t.dims();
33 if (dims[1] != dims[2])
34 throw TensorDimensionsException(1, 2, dims[1], dims[2]);
35 for (int k = 0; k < dims[2]; ++k) {
36 for (int j = 0; j < k; ++j) {
37 for (int i = 0; i < dims[0]; ++i) {
38 std::swap(t(i,j,k), t(i,k,j));
39 }
40 }
41 }
42 }
43
44 template<int I, int J, int K, typename T, class O>
45 void permute_in_place(TensorBase<T,3,O> &t) {
46 permute_in_place(t, boost::mpl::vector_c<int,I,J,K>());
47 }
48
50
51}
52
53#endif /* MPQC_MATH_TENSOR_PERMUTE_HPP */
Contains new MPQC code since version 3.
Definition integralenginepool.hpp:37

Generated at Wed Sep 25 2024 02:45:30 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.12.0.