SheafSystem  0.0.0.0
stp.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 
22 #ifndef STP_IMPL_H
23 #define STP_IMPL_H
24 
25 #ifndef SHEAF_DLL_SPEC_H
26 #include "SheafSystem/sheaf_dll_spec.h"
27 #endif
28 
29 #ifndef STP_H
30 #include "SheafSystem/stp.h"
31 #endif
32 
33 namespace fiber_bundle
34 {
35 
36 namespace stp_algebra
37 {
38 
39 template <typename T0, typename T1>
40 typename tensor_traits<T0::P + T1::P, typename T0::vector_space_type>::tp_type*
41 symmetric_product(const T0& x0, const T1& x1)
42 {
43  // Preconditions:
44 
45  require(precondition_of(symmetric_product(x0, x1, *result)));
46 
47  // Body:
48 
49  typedef typename T0::vector_space_type VST;
50  typedef typename tensor_traits<T0::P + T1::P, VST>::tp_type return_type;
51 
52  return_type* result =
53  reinterpret_cast<return_type*>(x0.tp_prototype(x0.p() + x1.p()).clone());
54 
55  symmetric_product(x0, x1, *result);
56 
57  // Postconditions:
58 
59  ensure(result != 0);
60  ensure(postcondition_of(symmetric_product(x0, x1, *result)));
61 
62  // Exit:
63 
64  return result;
65 }
66 
67 template <typename T0, typename T1>
69 symmetric_product(const T0& x0, const T1& x1, bool xauto_access)
70 {
71  // Preconditions:
72 
73  require(precondition_of(symmetric_product(x0, x1, *result, xauto_access)));
74 
75  // Body:
76 
77  typedef typename T0::vector_space_type VST;
78  typedef typename tensor_traits<T0::P + T1::P, VST>::tp_type return_type;
79 
80  return_type* result =
81  reinterpret_cast<return_type*>(x0.new_tp(x0.p(xauto_access) + x1.p(xauto_access),
82  xauto_access));
83 
84  symmetric_product(x0, x1, *result, xauto_access);
85 
86  // Postconditions:
87 
88  ensure(result != 0);
89  ensure(postcondition_of(symmetric_product(x0, x1, *result, xauto_access)));
90 
91  // Exit:
92 
93  return result;
94 }
95 
96 } // namespace stp_algebra
97 
98 } // namespace fiber_bundle
99 
100 #endif // ifndef STP_IMPL_H
SHEAF_DLL_SPEC void symmetric_product(const stp_lite &x0, const stp_lite &x1, stp_lite &xresult)
Symmetric product (pre-allocated version for volatile types).
Definition: stp.cc:898
Tensor types of degree P over VECTOR_TYPE. No generic implementation defined, must be specialized for...
Definition: vd.h:714
Namespace for the fiber_bundles component of the sheaf system.