SheafSystem  0.0.0.0
tp.impl.h
Go to the documentation of this file.
1 
2 //
3 // Copyright (c) 2014 Limit Point Systems, Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 
20 
21 #ifndef TP_IMPL_H
22 #define TP_IMPL_H
23 
24 #ifndef SHEAF_DLL_SPEC_H
25 #include "SheafSystem/sheaf_dll_spec.h"
26 #endif
27 
28 #ifndef TP_H
29 #include "SheafSystem/tp.h"
30 #endif
31 
32 namespace fiber_bundle
33 {
34 
35 namespace tp_algebra
36 {
37 
38 //==============================================================================
39 // TP FACET
40 //==============================================================================
41 
42 template <typename T0>
43 typename tensor_traits<T0::P, typename T0::vector_space_type>::atp_type*
44 alt(const T0& x0)
45 {
46  // Preconditions:
47 
48  require(precondition_of(alt(x0, *result)));
49 
50  // Body:
51 
52  typedef typename T0::vector_space_type VST;
53  typedef typename tensor_traits<T0::P, VST>::atp_type return_type;
54 
55  return_type* result =
56  reinterpret_cast<return_type*>(x0.atp_prototype(x0.p()).clone());
57 
58 
59  alt(x0, *result);
60 
61  // Postconditions:
62 
63  ensure(result != 0);
64  ensure(postcondition_of(alt(x0, *result)));
65 
66  // Exit:
67 
68  return result;
69 }
70 
71 template <typename T0>
73 sym(const T0& x0)
74 {
75  // Preconditions:
76 
77  require(precondition_of(sym(x0, *result)));
78 
79  // Body:
80 
81  typedef typename T0::vector_space_type VST;
82  typedef typename tensor_traits<T0::P, VST>::stp_type return_type;
83 
84  return_type* result =
85  reinterpret_cast<return_type*>(x0.stp_prototype(x0.p()).clone());
86 
87  sym(x0, *result);
88 
89  // Postconditions:
90 
91  ensure(result != 0);
92  ensure(postcondition_of(sym(x0, *result)));
93 
94  // Exit:
95 
96  return result;
97 }
98 
99 
100 template <typename T0>
102 alt(const T0& x0, bool xauto_access)
103 {
104  // Preconditions:
105 
106  require(precondition_of(alt(x0, *result, xauto_access)));
107 
108  // Body:
109 
110  typedef typename T0::vector_space_type VST;
111  typedef typename tensor_traits<T0::P, VST>::atp_type return_type;
112 
113  return_type* result =
114  reinterpret_cast<return_type*>(x0.new_atp(x0.p(xauto_access), xauto_access));
115 
116  alt(x0, *result, xauto_access);
117 
118  // Postconditions:
119 
120  ensure(result != 0);
121  ensure(postcondition_of(alt(x0, *result, xauto_access)));
122 
123  // Exit:
124 
125  return result;
126 }
127 
128 
129 template <typename T0>
131 sym(const T0& x0, bool xauto_access)
132 {
133  // Preconditions:
134 
135  require(precondition_of(sym(x0, *result, xauto_access)));
136 
137  // Body:
138 
139  typedef typename T0::vector_space_type VST;
140  typedef typename tensor_traits<T0::P, VST>::stp_type return_type;
141 
142  return_type* result =
143  reinterpret_cast<return_type*>(x0.new_stp(x0.p(xauto_access), xauto_access));
144 
145  sym(x0, *result, xauto_access);
146 
147  // Postconditions:
148 
149  ensure(result != 0);
150  ensure(postcondition_of(sym(x0, *result, xauto_access)));
151 
152  // Exit:
153 
154  return result;
155 }
156 
157 template <typename T0, typename T1>
159 tensor(const T0& x0, const T1& x1)
160 {
161  // Preconditions:
162 
163  require(precondition_of(tensor(x0, x1, *result)));
164 
165  // Body:
166 
167  typedef typename T0::vector_space_type VST;
168  typedef typename tensor_traits<T0::P + T1::P, VST>::tp_type return_type;
169 
170  return_type* result =
171  reinterpret_cast<return_type*>(x0.tp_prototype(x0.p() + x1.p()).clone());
172 
173  tensor(x0, x1, *result);
174 
175  // Postconditions:
176 
177  ensure(result != 0);
178  ensure(postcondition_of(tensor(x0, x1, *result)));
179 
180  // Exit:
181 
182  return result;
183 }
184 
185 template <typename T0, typename T1>
187 tensor(const T0& x0, const T1& x1, bool xauto_access)
188 {
189  // Preconditions:
190 
191  require(precondition_of(tensor(x0, x1, *result, xauto_access)));
192 
193  // Body:
194 
195  typedef typename T0::vector_space_type VST;
196  typedef typename tensor_traits<T0::P + T1::P, VST>::tp_type return_type;
197 
198  return_type* result =
199  reinterpret_cast<return_type*>(x0.new_tp(x0.p(xauto_access) + x1.p(xauto_access),
200  xauto_access));
201 
202  tensor(x0, x1, *result, xauto_access);
203 
204  // Postconditions:
205 
206  ensure(result != 0);
207  ensure(postcondition_of(tensor(x0, x1, *result, xauto_access)));
208 
209  // Exit:
210 
211  return result;
212 }
213 
214 } // end namespace tp_algebra
215 
216 } // end namespace fiber_bundle
217 
218 #endif // ifndef TP_IMPL_H
SHEAF_DLL_SPEC void alt(const t2_lite &x0, at2_lite &xresult)
The alternating (antisymmetric) part of tensor x0 (pre-allocated version for volatile types)...
Definition: t2.cc:1176
SHEAF_DLL_SPEC void sym(const t2_lite &x0, st2_lite &xresult)
The symmetric part of tensor x0 (pre-allocated version for volatile types).
Definition: t2.cc:1301
Tensor types of degree P over VECTOR_TYPE. No generic implementation defined, must be specialized for...
Definition: vd.h:714
SHEAF_DLL_SPEC void tensor(const at1_lite &x0, const at1_lite &x1, t2_lite &xresult)
Tensor product (pre-allocated version for volatile types).
Definition: t2.cc:1488
Namespace for the fiber_bundles component of the sheaf system.