SheafSystem  0.0.0.0
sec_st2.impl.h
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 
18 // Implementation for sec_st2 facet function templates.
19 
20 #ifndef SEC_ST2_IMPL_H
21 #define SEC_ST2_IMPL_H
22 
23 #ifndef SHEAF_DLL_SPEC_H
24 #include "SheafSystem/sheaf_dll_spec.h"
25 #endif
26 
27 #ifndef ASSERT_CONTRACT_H
28 #include "SheafSystem/assert_contract.h"
29 #endif
30 
31 #ifndef SEC_ST2_H
32 #include "SheafSystem/sec_st2.h"
33 #endif
34 
35 namespace fiber_bundle
36 {
37 
38 //==============================================================================
39 // NON-MEMBER FUNCTIONS
40 //==============================================================================
41 
42 //==============================================================================
43 
44 template <typename V0, typename VR>
45 void
46 trace_functor<V0, VR>::
47 operator()(const V0& x0, VR& xresult)
48 {
49  // Preconditions:
50 
51  require(precondition_of(xresult = trace(x0)));
52 
53  // Body:
54 
55  //trace(x0, xresult);
56  xresult = trace(x0);
57 
58  // Postconditions:
59 
60  ensure(postcondition_of(xresult = trace(x0)));
61 
62  // Exit:
63 
64  return;
65 }
66 
67 
68 template <typename V0, typename VR>
69 void
70 determinant_functor<V0, VR>::
71 operator()(const V0& x0, VR& xresult)
72 {
73  // Preconditions:
74 
75  require(precondition_of(xresult = determinant(x0)));
76 
77  // Body:
78 
79  vd_value_type lcomp;
80  determinant(x0, lcomp);
81  xresult.put_component(0, lcomp);
82 
83  //xresult = determinant(x0);
84 
85  // Postconditions:
86 
87  ensure(postcondition_of(xresult = determinant(x0)));
88 
89  // Exit:
90 
91  return;
92 }
93 
94 
95 //==============================================================================
96 
98 template <typename S0, typename SR>
99 void trace(const S0& x0, SR& xresult, bool xauto_access)
100 {
101  // Preconditions:
102 
103  require(x0.state_is_auto_read_accessible(xauto_access));
104 
105  // Body:
106 
107  if(xauto_access)
108  {
109  x0.get_read_access();
110  }
111 
112  typedef typename S0::fiber_type::volatile_type V0;
113  typedef typename SR::fiber_type::volatile_type VR;
114  trace_functor<V0, VR> f;
115  unary_op(x0, xresult, f, xauto_access);
116 
117  if(xauto_access)
118  {
119  x0.release_access();
120  }
121 
122  // Postconditions:
123 
124  // Exit:
125 
126  return;
127 }
128 
130 template <typename S0, typename SR>
131 void determinant(const S0& x0, SR& xresult, bool xauto_access)
132 {
133  // Preconditions:
134 
135  require(x0.state_is_auto_read_accessible(xauto_access));
136 
137  // Body:
138 
139  if(xauto_access)
140  {
141  x0.get_read_access();
142  }
143 
144  typedef typename S0::fiber_type::volatile_type V0;
145  typedef typename SR::fiber_type::volatile_type VR;
146  determinant_functor<V0, VR> f;
147  unary_op(x0, xresult, f, xauto_access);
148 
149  if(xauto_access)
150  {
151  x0.release_access();
152  }
153 
154  // Postconditions:
155 
156  // Exit:
157 
158  return;
159 }
160 
161 } // namespace fiber_bundle
162 
163 #endif // ifndef SEC_ST2_IMPL_H
void unary_op(const S0 &x0, SR &xresult, F xfunctor, bool xauto_access)
Unary operator.
Definition: sec_vd.impl.h:224
void trace(const S0 &x0, SR &xresult, bool xauto_access)
Definition: sec_st2.impl.h:99
void determinant(const S0 &x0, SR &xresult, bool xauto_access)
Definition: sec_st2.impl.h:131
Namespace for the fiber_bundles component of the sheaf system.
double vd_value_type
The type of component in the fiber; the scalar type in the fiber vector space.
Definition: fiber_bundle.h:63