GMatElastoPlasticQPot 0.18.3
Loading...
Searching...
No Matches
Cartesian2d_Array.hpp
Go to the documentation of this file.
1
9#ifndef GMATTENSOR_CARTESIAN2D_ARRAY_HPP
10#define GMATTENSOR_CARTESIAN2D_ARRAY_HPP
11
12#include "Cartesian2d.h"
13
14namespace GMatTensor {
15namespace Cartesian2d {
16
17template <size_t N>
18inline Array<N>::Array(const std::array<size_t, N>& shape)
19{
20 this->init(shape);
21}
22
23template <size_t N>
24inline void Array<N>::init(const std::array<size_t, N>& shape)
25{
26 m_shape = shape;
27 size_t nd = m_ndim;
28 std::copy(m_shape.begin(), m_shape.end(), m_shape_tensor2.begin());
29 std::copy(m_shape.begin(), m_shape.end(), m_shape_tensor4.begin());
30 std::fill(m_shape_tensor2.begin() + N, m_shape_tensor2.end(), nd);
31 std::fill(m_shape_tensor4.begin() + N, m_shape_tensor4.end(), nd);
32 m_size = std::accumulate(m_shape.begin(), m_shape.end(), 1, std::multiplies<size_t>());
33}
34
35template <size_t N>
36inline const std::array<size_t, N>& Array<N>::shape() const
37{
38 return m_shape;
39}
40
41template <size_t N>
42inline const std::array<size_t, N + 2>& Array<N>::shape_tensor2() const
43{
44 return m_shape_tensor2;
45}
46
47template <size_t N>
48inline const std::array<size_t, N + 4>& Array<N>::shape_tensor4() const
49{
50 return m_shape_tensor4;
51}
52
53template <size_t N>
55{
56 array_type::tensor<double, N + 2> ret = xt::empty<double>(m_shape_tensor2);
57
58#pragma omp parallel for
59 for (size_t i = 0; i < m_size; ++i) {
60 Cartesian2d::pointer::O2(&ret.flat(i * m_stride_tensor2));
61 }
62
63 return ret;
64}
65
66template <size_t N>
68{
69 array_type::tensor<double, N + 4> ret = xt::empty<double>(m_shape_tensor4);
70
71#pragma omp parallel for
72 for (size_t i = 0; i < m_size; ++i) {
73 Cartesian2d::pointer::O4(&ret.flat(i * m_stride_tensor4));
74 }
75
76 return ret;
77}
78
79template <size_t N>
81{
82 array_type::tensor<double, N + 2> ret = xt::empty<double>(m_shape_tensor2);
83
84#pragma omp parallel for
85 for (size_t i = 0; i < m_size; ++i) {
86 Cartesian2d::pointer::I2(&ret.flat(i * m_stride_tensor2));
87 }
88
89 return ret;
90}
91
92template <size_t N>
94{
95 array_type::tensor<double, N + 4> ret = xt::empty<double>(m_shape_tensor4);
96
97#pragma omp parallel for
98 for (size_t i = 0; i < m_size; ++i) {
99 Cartesian2d::pointer::II(&ret.flat(i * m_stride_tensor4));
100 }
101
102 return ret;
103}
104
105template <size_t N>
107{
108 array_type::tensor<double, N + 4> ret = xt::empty<double>(m_shape_tensor4);
109
110#pragma omp parallel for
111 for (size_t i = 0; i < m_size; ++i) {
112 Cartesian2d::pointer::I4(&ret.flat(i * m_stride_tensor4));
113 }
114
115 return ret;
116}
117
118template <size_t N>
120{
121 array_type::tensor<double, N + 4> ret = xt::empty<double>(m_shape_tensor4);
122
123#pragma omp parallel for
124 for (size_t i = 0; i < m_size; ++i) {
125 Cartesian2d::pointer::I4rt(&ret.flat(i * m_stride_tensor4));
126 }
127
128 return ret;
129}
130
131template <size_t N>
133{
134 array_type::tensor<double, N + 4> ret = xt::empty<double>(m_shape_tensor4);
135
136#pragma omp parallel for
137 for (size_t i = 0; i < m_size; ++i) {
138 Cartesian2d::pointer::I4s(&ret.flat(i * m_stride_tensor4));
139 }
140
141 return ret;
142}
143
144template <size_t N>
146{
147 array_type::tensor<double, N + 4> ret = xt::empty<double>(m_shape_tensor4);
148
149#pragma omp parallel for
150 for (size_t i = 0; i < m_size; ++i) {
151 Cartesian2d::pointer::I4d(&ret.flat(i * m_stride_tensor4));
152 }
153
154 return ret;
155}
156
157} // namespace Cartesian2d
158} // namespace GMatTensor
159
160#endif
array_type::tensor< double, N+4 > I4d() const
Array of Cartesian2d::I4d()
array_type::tensor< double, N+4 > O4() const
Array of Cartesian2d::O4()
const std::array< size_t, N+2 > & shape_tensor2() const
Shape of the array of second-order tensors.
const std::array< size_t, N+4 > & shape_tensor4() const
Shape of the array of fourth-order tensors.
array_type::tensor< double, N+4 > II() const
Array of Cartesian2d::II()
array_type::tensor< double, N+4 > I4s() const
Array of Cartesian2d::I4s()
array_type::tensor< double, N+4 > I4() const
Array of Cartesian2d::I4()
array_type::tensor< double, N+2 > I2() const
Array of Cartesian2d::I2()
void init(const std::array< size_t, N > &shape)
Constructor 'alias'.
array_type::tensor< double, N+4 > I4rt() const
Array of Cartesian2d::I4rt()
const std::array< size_t, N > & shape() const
Shape of the array (of scalars).
array_type::tensor< double, N+2 > O2() const
Array of Cartesian2d::O2()
void I4d(T *ret)
See Cartesian2d::I4d()
void I4(T *ret)
See Cartesian2d::I4()
void I2(T *ret)
See Cartesian2d::I2()
void I4rt(T *ret)
See Cartesian2d::I4rt()
void I4s(T *ret)
See Cartesian2d::I4s()
void O2(T *ret)
See Cartesian2d::O2()
void O4(T *ret)
See Cartesian2d::O4()
void II(T *ret)
See Cartesian2d::II()
xt::xtensor< T, N > tensor
Fixed (static) rank array.
Definition: config.h:86
Tensor products / operations.
Definition: Cartesian2d.h:20