SheafSystem  0.0.0.0
atp.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 ATP_IMPL_H
22 #define ATP_IMPL_H
23 
24 #ifndef SHEAF_DLL_SPEC_H
25 #include "SheafSystem/sheaf_dll_spec.h"
26 #endif
27 
28 #ifndef ATP_H
29 #include "SheafSystem/atp.h"
30 #endif
31 
32 namespace fiber_bundle
33 {
34 
35 namespace atp_algebra
36 {
37 
38 //==============================================================================
39 // ATP FACET:
40 //==============================================================================
41 
42 template <typename T0, typename T1>
43 typename tensor_traits<static_cast<int>(T0::P) - static_cast<int>(T1::P), typename T0::vector_space_type>::atp_type*
44 hook(const T0& x0, const T1& x1)
45 {
46  // Preconditions:
47 
48  require(precondition_of(hook(x0, x1, *result)));
49 
50  // Body:
51 
52  typedef typename T0::vector_space_type VST;
53  typedef typename tensor_traits<static_cast<int>(T0::P) - static_cast<int>(T1::P), VST>::atp_type return_type;
54 
55  // Can not cast to the return type here because the compile uses the
56  // at0_lite conversion operator to double to find a conversion path
57  // for hook(T0&, T1&, bool).
58 
59  atp_lite* result = x0.atp_prototype(x0.p() - x1.p()).clone();
60 
61  hook(x0, x1, *result);
62 
63  // Postconditions:
64 
65  ensure(result != 0);
66  ensure(postcondition_of(hook(x0, x1, *result)));
67 
68  // Exit:
69 
70  return reinterpret_cast<return_type*>(result);
71 }
72 
73 
74 template <typename T0, typename T1>
75 typename tensor_traits<static_cast<int>(T0::P) + static_cast<int>(T1::P), typename T0::vector_space_type>::atp_type*
76 wedge(const T0& x0, const T1& x1)
77 {
78  // Preconditions:
79 
80  require(precondition_of(wedge(x0, x1, *result)));
81 
82  // Body:
83 
84  typedef typename T0::vector_space_type VST;
85  typedef typename tensor_traits<static_cast<int>(T0::P) + static_cast<int>(T1::P), VST>::atp_type return_type;
86 
87  // Can not cast to the return type here because the compile uses the
88  // at0_lite conversion operator to double to find a conversion path
89  // for wedge(T0&, T1&, bool).
90 
91  atp_lite* result = x0.atp_prototype(x0.p() + x1.p()).clone();
92 
93  wedge(x0, x1, *result);
94 
95  // Postconditions:
96 
97  ensure(result != 0);
98  ensure(postcondition_of(wedge(x0, x1, *result)));
99 
100  // Exit:
101 
102  return reinterpret_cast<return_type*>(result);
103 }
104 
105 template <typename T0, typename T1>
106 typename tensor_traits<static_cast<int>(T0::P) - static_cast<int>(T1::P), typename T0::vector_space_type>::atp_type*
107 hook(const T0& x0, const T1& x1, bool xauto_access)
108 {
109  // Preconditions:
110 
111  require(precondition_of(hook(x0, x1, *result, xauto_access)));
112 
113  // Body:
114 
115  typedef typename T0::vector_space_type VST;
116  typedef typename tensor_traits<static_cast<int>(T0::P) - static_cast<int>(T1::P), VST>::atp_type return_type;
117 
118  return_type* result =
119  reinterpret_cast<return_type*>(x0.new_atp(x0.p(xauto_access) - x1.p(xauto_access),
120  xauto_access));
121 
122  hook(x0, x1, *result, xauto_access);
123 
124  // Postconditions:
125 
126  ensure(result != 0);
127  ensure(postcondition_of(hook(x0, x1, *result, xauto_access)));
128 
129  // Exit:
130 
131  return result;
132 }
133 
134 template <typename T0, typename T1>
135 typename tensor_traits<static_cast<int>(T0::P) + static_cast<int>(T1::P), typename T0::vector_space_type>::atp_type*
136 wedge(const T0& x0, const T1& x1, bool xauto_access)
137 {
138  // Preconditions:
139 
140  require(precondition_of(wedge(x0, x1, *result, xauto_access)));
141 
142  // Body:
143 
144  typedef typename T0::vector_space_type VST;
145  typedef typename tensor_traits<static_cast<int>(T0::P) + static_cast<int>(T1::P), VST>::atp_type return_type;
146 
147  return_type* result =
148  reinterpret_cast<return_type*>(x0.new_atp(x0.p(xauto_access) + x1.p(xauto_access), xauto_access));
149 
150  wedge(x0, x1, *result, xauto_access);
151 
152  // Postconditions:
153 
154  ensure(result != 0);
155  ensure(postcondition_of(wedge(x0, x1, *result, xauto_access)));
156 
157  // Exit:
158 
159  return result;
160 }
161 
162 } // namespace atp_algebra
163 
164 } // namespace fiber_bundle
165 
166 #endif // ifndef ATP_IMPL_H
An antisymmetric tensor of degree p over an abstract vector space (volatile version).
Definition: atp.h:44
SHEAF_DLL_SPEC void wedge(const e2 &x0, const e2 &x1, at2_e2 &xresult, bool xauto_access)
The exterior (wedge) product of two antisymmetric tensors (pre-allocated version for persistent types...
Definition: at2_e2.cc:1779
Tensor types of degree P over VECTOR_TYPE. No generic implementation defined, must be specialized for...
Definition: vd.h:714
SHEAF_DLL_SPEC void hook(const e2 &x0, const e2 &x1, at0 &xresult, bool xauto_access)
The interior (hook) product of two antisymmetric tensors (pre-allocated version for persistent types)...
Definition: at2_e2.cc:1328
virtual const atp_lite & atp_prototype(int xp) const
Prototype for antisymmetric tensors of degree xp over this vector space.
Definition: vd.cc:459
Namespace for the fiber_bundles component of the sheaf system.