SheafSystem  0.0.0.0
st2.cc
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 #include "SheafSystem/st2.h"
22 
23 #include "SheafSystem/abstract_poset_member.impl.h"
24 #include "SheafSystem/assert_contract.h"
25 #include "SheafSystem/at0.h"
26 #include "SheafSystem/stp_space.h"
27 #include "SheafSystem/fiber_bundles_namespace.h"
28 #include "SheafSystem/schema_poset_member.h"
29 #include "SheafSystem/wsv_block.h"
30 
31 
32 using namespace std;
33 using namespace fiber_bundle; // Workaround for MS C++ bug.
34 
35 
36 //==============================================================================
37 // CLASS ST2_LITE
38 //==============================================================================
39 
40 //==============================================================================
41 // ST2 FACET
42 //==============================================================================
43 
44 // PUBLIC MEMBER FUNCTIONS
45 
48 {
49 
50  // Preconditions:
51 
52  // Body:
53 
54  // Postconditions:
55 
56  ensure(invariant());
57 
58  // Exit:
59 }
60 
62 st2_lite(const st2_lite& xother)
63 {
64  // Preconditions:
65 
66  // Body:
67 
68  *this = xother;
69 
70  // Postconditions:
71 
72  ensure(invariant());
73 
74  // Exit:
75 }
76 
79 operator=(const st2_lite& xother)
80 {
81  // Preconditions:
82 
83  // Body:
84 
85  // Postconditions:
86 
87  ensure(invariant());
88 
89  // Exit:
90 
91  return *this;
92 }
93 
96 {
97  // Preconditions:
98 
99  // Body:
100 
101  // Postconditions:
102 
103  // Exit:
104 
105 }
106 
108 st2_lite(const row_dofs_type& xrow_dofs)
109 {
110  // Preconditions:
111 
112  // Body:
113 
114  *this = xrow_dofs;
115 
116  // Postconditions:
117 
118  ensure(invariant());
119 
120  // Exit:
121 }
122 
125 operator=(const row_dofs_type& xrow_dofs)
126 {
127  // Preconditions:
128 
129  // Body:
130 
131  vd_lite::operator=(xrow_dofs);
132 
133  // Postconditions:
134 
135  postcondition_of(vd_lite::operator=(xrow_dofs));
136 
137  // Exit:
138 
139  return *this;
140 
141 }
142 
145 component(int xrow, int xcolumn) const
146 {
147  // Preconditions:
148 
149  require(xrow >= 0 && xrow < dd());
150  require(xcolumn >= 0 && xcolumn < dd());
151 
152  // Body:
153 
154  value_type result = component(index_for_row_column(xrow, xcolumn));
155 
156  // Postconditions:
157 
158  ensure(invariant());
159 
160  // Exit:
161 
162  return result;
163 }
164 
165 void
167 put_component(int xrow, int xcolumn, value_type xcomp)
168 {
169  // Preconditions:
170 
171  require(xrow >= 0 && xrow < dd());
172  require(xcolumn >= 0 && xcolumn < dd());
173 
174  // Body:
175 
176  put_component(index_for_row_column(xrow, xcolumn), xcomp);
177 
178  // Postconditions:
179 
180  ensure(invariant());
181  ensure(isunordered_or_equals(component(index_for_row_column(xrow, xcolumn)), xcomp));
182 
183  // Exit:
184 
185  return;
186 }
187 
188 int
190 index_for_row_column(int xrow, int xcolumn) const
191 {
192  // Preconditions:
193 
194  require(0 <= xrow && xrow < dd());
195  require(0 <= xcolumn && xcolumn < dd());
196 
197  // Body:
198 
199  // Convert (xrow, xcolumn) into an index into linear component storage
200  // (upper triangular stored by rows).
201 
202  int i = xrow;
203  int j = xcolumn;
204 
205  // Swap i and j if i > j.
206 
207  if(i > j)
208  {
209  int isave = i;
210  i = j;
211  j = isave;
212  }
213 
214  int result = j + (i*(2*dd()-1-i))/2;
215 
216  // Postconditions:
217 
218  ensure(invariant());
219  ensure(result >= 0);
220  ensure(result < dd()*dd());
221 
222  // Exit:
223 
224  return result;
225 }
226 
227 // PROTECTED MEMBER FUNCTIONS
228 
229 // PRIVATE MEMBER FUNCTIONS
230 
231 
232 //==============================================================================
233 // INTERIOR ALGEBRA (STP) FACET
234 //==============================================================================
235 
236 // PUBLIC MEMBER FUNCTIONS
237 
238 int
240 p() const
241 {
242  // Preconditions:
243 
244  // Body:
245 
246  int result = 2;
247 
248  // Postconditions:
249 
250  ensure(invariant());
251  ensure(result == 2);
252 
253  // Exit:
254 
255  return result;
256 }
257 
258 //==============================================================================
259 // TENSOR ALGEBRA (TP) FACET
260 //==============================================================================
261 
262 // PUBLIC MEMBER FUNCTIONS
263 
264 // PROTECTED MEMBER FUNCTIONS
265 
266 // PRIVATE MEMBER FUNCTIONS
267 
268 
269 //==============================================================================
270 // VECTOR ALGEBRA (VD) FACET
271 //==============================================================================
272 
273 // PUBLIC MEMBER FUNCTIONS
274 
275 // PROTECTED MEMBER FUNCTIONS
276 
277 // PRIVATE MEMBER FUNCTIONS
278 
279 
280 //==============================================================================
281 // CARTESIAN ALGEBRA (TUPLE) FACET
282 //==============================================================================
283 
284 // PUBLIC MEMBER FUNCTIONS
285 
286 // PROTECTED MEMBER FUNCTIONS
287 
288 // PRIVATE MEMBER FUNCTIONS
289 
290 
291 //==============================================================================
292 // ABSTRACT POSET MEMBER FACET
293 //==============================================================================
294 
295 // PUBLIC MEMBER FUNCTIONS
296 
297 const std::string&
299 class_name() const
300 {
301  // Preconditions:
302 
303  // Body:
304 
305  const string& result = static_class_name();
306 
307  // Postconditions:
308 
309  ensure(!result.empty());
310 
311  // Exit:
312 
313  return result;
314 }
315 
316 const std::string&
319 {
320  // Preconditions:
321 
322  // Body:
323 
324  static const string result("st2_lite");
325 
326  // Postconditions:
327 
328  ensure(!result.empty());
329 
330  // Exit:
331 
332  return result;
333 }
334 
337 clone() const
338 {
339  st2_lite* result = 0;
340 
341  // Preconditions:
342 
343  // Body:
344 
345  result = new st2_lite();
346 
347  // Postconditions:
348 
349  ensure(result != 0);
350  ensure(is_same_type(*result));
351 
352  // Exit:
353 
354  return result;
355 }
356 
357 // PROTECTED MEMBER FUNCTIONS
358 
359 // PRIVATE MEMBER FUNCTIONS
360 
361 
362 //==============================================================================
363 // ANY FACET
364 //==============================================================================
365 
366 // PUBLIC MEMBER FUNCTIONS
367 
368 bool
370 is_ancestor_of(const any_lite& xother) const
371 {
372  // Preconditions:
373 
374  require(&xother != 0);
375 
376  // Body:
377 
378  // True if other conforms to this.
379 
380  bool result = dynamic_cast<const st2_lite*>(&xother) != 0;
381 
382  // Postconditions:
383 
384  return result;
385 }
386 
387 bool
389 invariant() const
390 {
391  bool result = true;
392 
393  if(invariant_check())
394  {
395  // Prevent recursive calls to invariant.
396 
397  disable_invariant_check();
398 
399  // Must satisfy base class invariant.
400 
401  invariance(stp_lite::invariant());
402 
403  // Invariances for this class:
404 
405  // Finished, turn invariant checking back on.
406 
407  enable_invariant_check();
408  }
409 
410  // Exit
411 
412  return result;
413 }
414 
415 // PROTECTED MEMBER FUNCTIONS
416 
417 // PRIVATE MEMBER FUNCTIONS
418 
419 
420 //==============================================================================
421 // CLASS ST2
422 //==============================================================================
423 
424 // ===========================================================
425 // HOST FACTORY FACET OF CLASS ST2
426 // ===========================================================
427 
428 // PUBLIC MEMBER FUNCTIONS
429 
430 const sheaf::poset_path&
433 {
434  // Preconditions:
435 
436 
437  // Body:
438 
439  static const poset_path result(standard_schema_poset_name(), "st2_schema");
440 
441  // Postconditions:
442 
443  // Exit:
444 
445  return result;
446 }
447 
448 void
451 {
452  // Preconditions:
453 
454  require(xns.state_is_read_write_accessible());
455  require(xns.contains_poset(standard_schema_poset_name()));
456  require(!xns.contains_poset_member(standard_schema_path()));
457 
458  // Body:
459 
460  schema_poset_member lschema(xns,
461  standard_schema_path().member_name(),
462  stp::standard_schema_path(),
463  "",
464  false);
465 
466  lschema.detach_from_state();
467 
468  // Postconditions:
469 
470  ensure(xns.contains_poset_member(standard_schema_path()));
471 
472  // Exit:
473 
474  return;
475 }
476 
480  const poset_path& xhost_path,
481  const poset_path& xschema_path,
482  const poset_path& xvector_space_path,
483  bool xauto_access)
484 {
485  // cout << endl << "Entering st2::new_host." << endl;
486 
487  // Preconditions:
488 
489  require(xns.state_is_auto_read_write_accessible(xauto_access));
490 
491  require(!xhost_path.empty());
492  require(!xns.contains_path(xhost_path, xauto_access));
493 
494  require(xschema_path.full());
495  require(xns.path_is_auto_read_accessible(xschema_path, xauto_access));
496  require(schema_poset_member::conforms_to(xns, xschema_path, standard_schema_path()));
497 
498  require(xns.path_is_auto_read_accessible(xvector_space_path, xauto_access));
499  require(xns.contains_poset<scalar_type::host_type>(xvector_space_path, xauto_access));
500 
501  // Body:
502 
503  host_type& result =
504  host_type::new_table(xns, xhost_path, xschema_path, 2, xvector_space_path, xauto_access);
505 
506  // Postconditions:
507 
508  ensure(xns.owns(result, xauto_access));
509  ensure(result.path(true) == xhost_path);
510  ensure(result.state_is_not_read_accessible());
511  ensure(result.schema(true).path(xauto_access) == xschema_path);
512 
513  ensure(result.factor_ct(true) == result.d(true));
514  ensure(result.d(true) == schema_poset_member::row_dof_ct(xns, xschema_path, xauto_access));
515  ensure(result.vector_space_path(true) == xvector_space_path );
516  ensure(result.p(true) == 2);
517  ensure(result.dd(true) == result.d(true));
518  ensure(result.vector_space_path(true) == xhost_path );
519 
520  // Exit:
521 
522  // cout << "Leaving st2::new_host." << endl;
523  return result;
524 }
525 
526 // PROTECTED MEMBER FUNCTIONS
527 
528 // PRIVATE MEMBER FUNCTIONS
529 
530 
531 //==============================================================================
532 // ST2 FACET
533 //==============================================================================
534 
535 // PUBLIC MEMBER FUNCTIONS
536 
539 {
540  // Preconditions:
541 
542  // Body:
543 
544  // Postconditions:
545 
546  ensure(invariant());
547 }
548 
550 st2(const poset_state_handle* xhost, pod_index_type xhub_id)
551 {
552  // Preconditions:
553 
554  require(xhost != 0);
555  require(xhost->state_is_read_accessible());
556  require(xhost->contains_member(xhub_id));
557 
558  // Body:
559 
560  attach_to_state(xhost, xhub_id);
561 
562  // Postconditions:
563 
564  ensure(invariant());
565  ensure(invariant());
566  // ensure(host() == xhost);
567  ensure(index() == xhub_id);
568  ensure(is_attached());
569 }
570 
572 st2(const poset_state_handle* xhost, const scoped_index& xid)
573 {
574  // Preconditions:
575 
576  require(xhost != 0);
577  require(xhost->state_is_read_accessible());
578  require(xhost->contains_member(xid));
579 
580  // Body:
581 
582  attach_to_state(xhost, xid.hub_pod());
583 
584  // Postconditions:
585 
586  ensure(invariant());
587  ensure(invariant());
588  // ensure(host() == xhost);
589  ensure(index() ==~ xid);
590  ensure(is_attached());
591 }
592 
594 st2(const poset_state_handle* xhost, const std::string& xname)
595 {
596 
597  // Preconditions:
598 
599  require(xhost != 0);
600  require(xhost->state_is_read_accessible());
601  require(!xname.empty());
602  require(xhost->contains_member(xname));
603 
604  // Body:
605 
606  attach_to_state(xhost, xname);
607 
608  // Postconditions:
609 
610  ensure(invariant());
611  // ensure(host() == xhost);
612  ensure(name() == xname);
613  ensure(is_attached());
614 
615 }
616 
619 {
620 
621  // Preconditions:
622 
623  require(xother != 0);
624 
625  // Body:
626 
627  attach_to_state(xother);
628 
629  // Postconditions:
630 
631  ensure(invariant());
632  ensure(is_attached());
633  ensure(is_same_state(xother));
634 
635 }
636 
638 st2(poset_state_handle* xhost, bool xauto_access)
639 {
640 
641  // Preconditions:
642 
643  require(precondition_of(new_jim_state(xhost, 0, false, xauto_access)));
644 
645  // Body:
646 
647  new_jim_state(xhost, 0, false, xauto_access);
648 
649  // Postconditions:
650 
651  ensure(postcondition_of(new_jim_state(xhost, 0, false, xauto_access)));
652 
653  // Exit:
654 
655  return;
656 }
657 
662 {
663  // Preconditions:
664 
665  require(is_ancestor_of(&xother));
666  require(precondition_of(attach_to_state(&xother)));
667 
668  // Body:
669 
670  attach_to_state(&xother);
671 
672  // Postconditions:
673 
674  ensure(postcondition_of(attach_to_state(&xother)));
675 
676  // Exit:
677 
678  return *this;
679 }
680 
684 operator=(const st2& xother)
685 {
686  // Preconditions:
687 
688  require(precondition_of(attach_to_state(&xother)));
689 
690  // Body:
691 
692  attach_to_state(&xother);
693 
694  // Postconditions:
695 
696  ensure(postcondition_of(attach_to_state(&xother)));
697 
698  // Exit:
699 
700  return *this;
701 }
702 
705 {
706  // Preconditions:
707 
708  // Body:
709 
710  // Postconditions:
711 }
712 
716 {
717  // Preconditions:
718 
719  // Body:
720 
721  static const volatile_type result;
722 
723  // Postconditions:
724 
725  // Exit:
726 
727  return result;
728 }
729 
733 lite_type() const
734 {
735  // Preconditions:
736 
737  // Body:
738 
739  volatile_type* result = new volatile_type(sheaf::row_dofs(*this));
740 
741  // Postconditions:
742 
743  // Exit:
744 
745  return result;
746 }
747 
748 
751 component(int xrow, int xcolumn) const
752 {
753  // Preconditions:
754 
755  require(state_is_read_accessible());
756  require((0 <= xrow) && (xrow < dd()));
757  require((0 <= xcolumn) && (xcolumn < dd()));
758 
759  // Body:
760 
761  value_type result = component(index_for_row_column(xrow, xcolumn));
762 
763  // Postconditions:
764 
765  ensure(invariant());
766 
767  // Exit:
768 
769  return result;
770 }
771 
774 component(int xrow, int xcolumn, bool xauto_access) const
775 {
776  // Preconditions:
777 
778  require(state_is_auto_read_accessible(xauto_access));
779  require((0 <= xrow) && (xrow < dd(xauto_access)));
780  require((0 <= xcolumn) && (xcolumn < dd(xauto_access)));
781 
782  // Body:
783 
784  if(xauto_access)
785  {
786  get_read_access();
787  }
788 
789  value_type result = component(xrow, xcolumn);
790 
791  if(xauto_access)
792  {
793  release_access();
794  }
795 
796  // Postconditions:
797 
798  ensure(invariant());
799 
800  // Exit:
801 
802  return result;
803 }
804 
805 void
807 put_component(int xrow, int xcolumn, value_type xvalue)
808 {
809 
810  // Preconditions:
811 
812  require(state_is_read_write_accessible());
813  require((0 <= xrow) && (xrow < dd()));
814  require((0 <= xcolumn) && (xcolumn < dd()));
815 
816  // Body:
817 
818  put_component(index_for_row_column(xrow, xcolumn), xvalue);
819 
820  // Postconditions:
821 
822  ensure(invariant());
823  ensure(isunordered_or_equals(component(xrow, xcolumn), xvalue));
824 
825  // Exit:
826 
827  return;
828 }
829 
830 void
832 put_component(int xrow, int xcolumn, value_type xvalue, bool xauto_access)
833 {
834 
835  // Preconditions:
836 
837  require(state_is_auto_read_write_accessible(xauto_access));
838  require((0 <= xrow) && (xrow < dd(xauto_access)));
839  require((0 <= xcolumn) && (xcolumn < dd(xauto_access)));
840 
841  // Body:
842 
843  if(xauto_access)
844  {
845  get_read_write_access(true);
846  }
847 
848  put_component(index_for_row_column(xrow, xcolumn), xvalue);
849 
850  if(xauto_access)
851  {
852  release_access();
853  }
854 
855  // Postconditions:
856 
857  ensure(invariant());
858  ensure(isunordered_or_equals(component(xrow, xcolumn), xvalue));
859 
860  // Exit:
861 
862  return;
863 }
864 
865 int
867 index_for_row_column(int xrow, int xcolumn) const
868 {
869  // Preconditions:
870 
871  require(0 <= xrow && xrow < dd());
872  require(0 <= xcolumn && xcolumn < dd());
873 
874  // Body:
875 
876  // Convert (xrow, xcolumn) into an index into linear component storage
877  // (upper triangular stored by rows).
878 
879  int i = xrow;
880  int j = xcolumn;
881 
882  // Swap i and j if i > j.
883 
884  if(i > j)
885  {
886  int isave = i;
887  i = j;
888  j = isave;
889  }
890 
891  int result = j + (i*(2*dd()-1-i))/2;
892 
893  // Postconditions:
894 
895  // ensure(invariant());
896  ensure(result >= 0);
897  ensure(result < dd()*dd());
898 
899  // Exit:
900 
901  return result;
902 }
903 
904 // PROTECTED MEMBER FUNCTIONS
905 
906 // PRIVATE MEMBER FUNCTIONS
907 
908 
909 //==============================================================================
910 // STP FACET
911 //==============================================================================
912 
913 // PUBLIC MEMBER FUNCTIONS
914 
915 // PROTECTED MEMBER FUNCTIONS
916 
917 // PRIVATE MEMBER FUNCTIONS
918 
919 
920 //==============================================================================
921 // TENSOR ALGEBRA (TP) FACET
922 //==============================================================================
923 
924 // PUBLIC MEMBER FUNCTIONS
925 
926 // PROTECTED MEMBER FUNCTIONS
927 
928 // PRIVATE MEMBER FUNCTIONS
929 
930 
931 //==============================================================================
932 // VECTOR ALGEBRA (VD) FACET
933 //==============================================================================
934 
935 // PUBLIC MEMBER FUNCTIONS
936 
937 // PROTECTED MEMBER FUNCTIONS
938 
939 // PRIVATE MEMBER FUNCTIONS
940 
941 
942 //==============================================================================
943 // CARTESIAN ALGEBRA (TUPLE) FACET
944 //==============================================================================
945 
946 // PUBLIC MEMBER FUNCTIONS
947 
948 // PROTECTED MEMBER FUNCTIONS
949 
950 // PRIVATE MEMBER FUNCTIONS
951 
952 
953 //==============================================================================
954 // ABSTRACT POSET MEMBER FACET
955 //==============================================================================
956 
957 // PUBLIC MEMBER FUNCTIONS
958 
959 const std::string&
961 class_name() const
962 {
963  // Preconditions:
964 
965  // Body:
966 
967  const string& result = static_class_name();
968 
969  // Postconditions:
970 
971  ensure(!result.empty());
972 
973  // Exit:
974 
975  return result;
976 }
977 
978 const std::string&
981 {
982  // Preconditions:
983 
984  // Body:
985 
986  static const string result("st2");
987 
988  // Postconditions:
989 
990  ensure(!result.empty());
991 
992  // Exit:
993 
994  return result;
995 }
996 
999 clone() const
1000 {
1001 
1002  // Preconditions:
1003 
1004  // Body:
1005 
1006  // Create new handle of the current class.
1007 
1008  st2 *result = new st2();
1009 
1010  // Postconditions:
1011 
1012  ensure(result != 0);
1013  ensure(result->invariant());
1014 
1015  // Exit:
1016 
1017  return result;
1018 
1019 }
1020 
1021 // PROTECTED MEMBER FUNCTIONS
1022 
1023 // PRIVATE MEMBER FUNCTIONS
1024 
1025 
1026 //==============================================================================
1027 // ANY FACET
1028 //==============================================================================
1029 
1030 // PUBLIC MEMBER FUNCTIONS
1031 
1032 bool
1034 is_ancestor_of(const any* xother) const
1035 {
1036 
1037  // Preconditions:
1038 
1039  require(xother != 0);
1040 
1041  // Body:
1042 
1043  // If other may be dynamically cast to the type of this then this is an
1044  // ancestor of other.
1045 
1046  bool result = dynamic_cast<const st2*>(xother) != 0;
1047 
1048  // Postconditions:
1049 
1050  ensure(invariant());
1051 
1052  // Exit:
1053 
1054  return result;
1055 
1056 }
1057 
1058 bool
1060 invariant() const
1061 {
1062  bool result = true;
1063 
1064  // Preconditions:
1065 
1066  // Body:
1067 
1068  // Must satisfy base class invariant.
1069 
1070  invariance(stp::invariant());
1071 
1072  if (invariant_check())
1073  {
1074  // Prevent recursive calls to invariant.
1075 
1076  disable_invariant_check();
1077 
1078  // Invariants for this class:
1079 
1080  invariance(is_attached() ? (p() == 2) : true);
1081 
1082  // Finished, turn invariant checking back on.
1083 
1084  enable_invariant_check();
1085  }
1086 
1087  // Postconditions:
1088 
1089  ensure(is_derived_query);
1090 
1091  // Exit:
1092 
1093  return result;
1094 }
1095 
1096 // PROTECTED MEMBER FUNCTIONS
1097 
1098 // PRIVATE MEMBER FUNCTIONS
1099 
1100 
1101 //==============================================================================
1102 // NON-MEMBER FUNCTIONS
1103 //==============================================================================
1104 
1105 //==============================================================================
1106 // ST2 FACET
1107 //==============================================================================
1108 
1109 #include "SheafSystem/error_message.h"
1110 #include "SheafSystem/st2_e2.h"
1111 #include "SheafSystem/st2_e3.h"
1112 
1114 void
1116 trace(const st2& x0, vd_value_type& xresult, bool xauto_access)
1117 {
1118  // Preconditions:
1119 
1120  require(x0.state_is_auto_read_accessible(xauto_access));
1121 
1122  // Body:
1123 
1124  if(xauto_access)
1125  {
1126  x0.get_read_access();
1127  }
1128 
1129  xresult = 0;
1130 
1131  int ldd = x0.dd();
1132  for(int i=0; i<ldd; ++i)
1133  {
1134  xresult += x0.component(i, i);
1135  }
1136 
1137  if(xauto_access)
1138  {
1139  x0.release_access();
1140  }
1141 
1142  // Postconditions:
1143 
1144  ensure(unexecutable("xresult == trace(x0)"));
1145 
1146  // Exit:
1147 
1148  return;
1149 }
1150 
1154 trace(const st2& x0, bool xauto_access)
1155 {
1156  // Preconditions:
1157 
1158  require(precondition_of(trace(x0, result, xauto_access)));
1159 
1160  // Body:
1161 
1162  vd_value_type result;
1163 
1164  trace(x0, result, xauto_access);
1165 
1166  // Postconditions:
1167 
1168  ensure(postcondition_of(trace(x0, result, xauto_access)));
1169 
1170  // Exit:
1171 
1172  return result;
1173 }
1174 
1176 void
1178 trace(const st2_lite& x0, vd_value_type& xresult)
1179 {
1180  // Preconditions:
1181 
1182  // Body:
1183 
1184  xresult = 0;
1185 
1186  int ldd = x0.dd();
1187  for(int i=0; i<ldd; ++i)
1188  {
1189  xresult += x0.component(i, i);
1190  }
1191 
1192  // Postconditions:
1193 
1194  ensure(unexecutable("xresult == trace(x0)"));
1195 
1196  // Exit:
1197 
1198  return;
1199 }
1200 
1204 trace(const st2_lite& x0)
1205 {
1206  // Preconditions:
1207 
1208  require(precondition_of(trace(x0, result)));
1209 
1210  // Body:
1211 
1212  vd_value_type result;
1213 
1214  trace(x0, result);
1215 
1216  // Postconditions:
1217 
1218  ensure(postcondition_of(trace(x0, result)));
1219 
1220  // Exit:
1221 
1222  return result;
1223 }
1224 
1226 void
1228 determinant(const st2& x0, vd_value_type& xresult, bool xauto_access)
1229 {
1230  // Preconditions:
1231 
1232  require(x0.state_is_auto_read_accessible(xauto_access));
1233 
1234  // Body:
1235 
1236  const st2_e2* st2_e2_x0 = dynamic_cast<const st2_e2*>(&x0);
1237  const st2_e3* st2_e3_x0 = dynamic_cast<const st2_e3*>(&x0);
1238 
1239  if(st2_e2_x0)
1240  {
1241  determinant(*st2_e2_x0, xresult, xauto_access);
1242  }
1243  else if(st2_e3_x0)
1244  {
1245  determinant(*st2_e3_x0, xresult, xauto_access);
1246  }
1247  else
1248  {
1249  post_fatal_error_message(\
1250  "Unsupported argument types in call to determinant(...)");
1251  }
1252 
1253  // Postconditions:
1254 
1255  // Exit:
1256 
1257  return;
1258 }
1259 
1263 determinant(const st2& x0, bool xauto_access)
1264 {
1265  // Preconditions:
1266 
1267  require(precondition_of(determinant(x0, result, xauto_access)));
1268 
1269  // Body:
1270 
1271  vd_value_type result;
1272 
1273  determinant(x0, result, xauto_access);
1274 
1275  // Postconditions:
1276 
1277  ensure(postcondition_of(determinant(x0, result, xauto_access)));
1278 
1279  // Exit:
1280 
1281  return result;
1282 }
1283 
1284 void
1286 determinant(const st2_lite& x0, vd_value_type& xresult)
1287 {
1288  // Preconditions:
1289 
1290  // Body:
1291 
1292  const st2_e2_lite* st2_e2_x0 = dynamic_cast<const st2_e2_lite*>(&x0);
1293  const st2_e3_lite* st2_e3_x0 = dynamic_cast<const st2_e3_lite*>(&x0);
1294 
1295  if(st2_e2_x0)
1296  {
1297  determinant(*st2_e2_x0, xresult);
1298  }
1299  else if(st2_e3_x0)
1300  {
1301  determinant(*st2_e3_x0, xresult);
1302  }
1303  else
1304  {
1305  post_fatal_error_message(\
1306  "Unsupported argument types in call to determinant(...)");
1307  }
1308 
1309  // Postconditions:
1310 
1311  // Exit:
1312 
1313  return;
1314 }
1315 
1320 {
1321  // Preconditions:
1322 
1323  require(precondition_of(determinant(x0, result)));
1324 
1325  // Body:
1326 
1327  vd_value_type result;
1328 
1329  determinant(x0, result);
1330 
1331  // Postconditions:
1332 
1333  ensure(postcondition_of(determinant(x0, result)));
1334 
1335  // Exit:
1336 
1337  return result;
1338 }
1339 
virtual int dd() const
Dimension of the underlying vector space.
Definition: tp.cc:166
virtual poset_path path(bool xauto_access=true) const
The path of this poset.
bool state_is_auto_read_write_accessible(bool xauto_access) const
True if state is auto accessible for read and write, that is, if the state is already accessible for ...
static void make_standard_schema(namespace_poset &xns)
Creates the standard schema for this class in namespace xns.
Definition: st2.cc:450
static const std::string & static_class_name()
The name of this class.
Definition: st2.cc:318
virtual int dd() const
Dimension of the underlying vector space.
Definition: tp.cc:788
bool full() const
True if both poset name and member name are not empty.
Definition: poset_path.cc:311
virtual int p() const
Degree of this as an antisymmetric tensor space.
Definition: st2.cc:240
vd_value_type value_type
The type of component in the fiber; the scalar type in the fiber vector space.
Definition: st2.h:56
virtual volatile_type * lite_type() const
Virtual conversion to the associated volatile type.
Definition: st2.cc:733
poset_path path(bool xauto_access=true) const
A path to this component.
The default name space; a poset which contains other posets as members.
bool state_is_read_accessible() const
True if this is attached and if the state is accessible for read or access control is disabled...
bool path_is_auto_read_accessible(const poset_path &xpath, bool xauto_access) const
True if the state referred to xpath exists and is auto read accessible.
The standard fiber bundles name space; extends the standard sheaves namespace by defining base space...
virtual ~st2_lite()
Destructor.
Definition: st2.cc:95
poset_path vector_space_path() const
The path of the underlying vector space.
Definition: tp_space.cc:365
bool contains_poset_member(pod_index_type xposet_hub_id, pod_index_type xmember_hub_id, bool xauto_access=true) const
True if this contains a poset with hub id xposet_hub_id which contains a member with hub id xmember_h...
bool state_is_auto_read_accessible(bool xauto_access) const
True if the state is auto accessible for read, that is, if the state is already accessible for read o...
A client handle for a general, abstract partially order set.
A path defined by a poset name and a member name separated by a forward slash (&#39;/&#39;). For example: "cell_definitions/triangle".
Definition: poset_path.h:48
bool invariant() const
Class invariant.
Definition: st2.cc:1060
STL namespace.
virtual value_type component(int xrow, int xcolumn) const
The value of the component in a specified row and column.
Definition: st2.cc:145
virtual st2 * clone() const
Make a new handle, no state instance of current.
Definition: st2.cc:999
virtual void get_read_access() const
Get read access to the state associated with this.
bool is_ancestor_of(const any *xother) const
True if other conforms to current.
Definition: st2.cc:1034
SHEAF_DLL_SPEC void determinant(const st2 &x0, vd_value_type &xresult, bool xauto_access)
The determinant of a symmetric tensor (pre-allocated version for persistent types).
Definition: st2.cc:1228
SHEAF_DLL_SPEC void trace(const st2 &x0, vd_value_type &xresult, bool xauto_access)
The trace of a symmetric tensor (pre-allocated version for persistent types).
Definition: st2.cc:1116
T::row_dofs_type & row_dofs(T &x0)
The row dofs pod type for x0 (mutable version).
st2_lite()
Default constructor.
Definition: st2.cc:47
virtual void put_component(int xrow, int xcolumn, value_type xcomp)
Sets value of a component in a specified row and column.
Definition: st2.cc:167
static const std::string & static_class_name()
The name of this class.
Definition: st2.cc:980
static int d(const namespace_poset &xns, int xp, const poset_path &xvector_space_path, bool xauto_access)
The tensor dimension implied by tensor degree xp and the dimension of the domain vector space specifi...
Definition: stp_space.cc:86
virtual void release_access(bool xall=false) const
Release access. If xall is true, release all levels of access. Otherwise, release one level of access...
Abstract base class with useful features for all volatile objects.
Definition: any_lite.h:48
Abstract base class with useful features for all objects.
Definition: any.h:39
bool invariant() const
Class invariant.
Definition: st2.cc:389
A general symmetric tensor of degree 2 over an abstract vector space (volatile version).
Definition: st2.h:43
virtual const std::string & class_name() const
The name of this class.
Definition: st2.cc:961
virtual schema_poset_member & schema()
The schema for this poset (mutable version).
A space of scalars viewed as an antisymmetric tensor space of degree 0.
Definition: at0_space.h:42
bool state_is_read_write_accessible() const
True if this is attached and if the state is accessible for read and write or access control is disab...
static host_type & new_host(namespace_type &xns, const poset_path &xhost_path, const poset_path &xschema_path, const poset_path &xvector_space_path, bool xauto_access)
Creates a new host table for members of this type. The poset is created in namespace xns with path xh...
Definition: st2.cc:479
virtual bool is_ancestor_of(const any_lite &xother) const
Conformance test; true if other conforms to this.
Definition: st2.cc:370
A symmetric tensor of degree 2 over a Euclidean vector space of dimension 3 (volatile version)...
Definition: st2_e3.h:148
bool owns(const poset_state_handle &xposet, bool xauto_access) const
True if and only if this contains the poset xposet. synonym for contains_poset(xposet.poset_path(true), xauto_access)
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
virtual const volatile_type & lite_prototype() const
Virtual constructor for the associated volatile type.
Definition: st2.cc:715
bool contains_path(const poset_path &xpath, bool xauto_access=true) const
True if this contains the poset or poset member specified by xpath.
virtual bool contains_member(pod_index_type xmbr_hub_id, bool xauto_access=true) const
True if some version of this poset contains poset member with hub id xmbr_hub_id. ...
int p(int xd, int xdd) const
Tensor degree as a function of tensor dimension xd and domain dimension xdd.
Definition: tp_space.cc:235
virtual int index_for_row_column(int xrow, int xcolumn) const
The index into linear storage of the component in a specified row and column.
Definition: st2.cc:190
bool empty() const
True if both poset name and member name are empty.
Definition: poset_path.cc:291
virtual int index_for_row_column(int xrow, int xcolumn) const
Returns index into linear storage of the component in a specified row and column. ...
Definition: st2.cc:867
void put_component(int xrow, int xcolumn, value_type xvalue)
Sets the component with row index xrow and column index xcolumn to xvalue.
Definition: st2.cc:807
bool contains_poset(pod_index_type xhub_id, bool xauto_access=true) const
True if this contains a poset with hub id xhub_id..
static const poset_path & standard_schema_path()
The path to the standard schema for this class.
Definition: st2.cc:432
st2_lite & operator=(const st2_lite &xother)
Assignment operator.
Definition: st2.cc:79
static int factor_ct(int xd)
Factor_ct() as a function of dimension xd.
Definition: vd_space.cc:167
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
vd_value_type value_type
The POD ("plain old data") type of scalar in the vector space of this.
Definition: vd.h:423
A symmetric tensor of degree 2 over a Euclidean vector space of dimension 2 (persistent version)...
Definition: st2_e2.h:431
int dd() const
The dimension of the underlying ("domain") vector space.
Definition: tp_space.cc:317
virtual st2_lite * clone() const
Virtual constructor, makes a new instance of the same type as this.
Definition: st2.cc:337
~st2()
Destructor.
Definition: st2.cc:704
A symmetric tensor of degree 2 over a Euclidean vector space of dimension 2 (volatile version)...
Definition: st2_e2.h:150
virtual const std::string & class_name() const
The name of this class.
Definition: st2.cc:299
An abstract client handle for a member of a poset.
st2()
Default constructor.
Definition: st2.cc:538
An abstract symmetric tensor space of degree p.
Definition: stp_space.h:42
Namespace for the fiber_bundles component of the sheaf system.
A general symmetric tensor of degree 2 over an abstract vector space (persistent version).
Definition: st2.h:234
value_type component(int xrow, int xcolumn) const
The component with row index xrow and column index xcolumn.
Definition: st2.cc:751
virtual st2 & operator=(const abstract_poset_member &xother)
Assignment operator; synonym for attach_to_state(&xother).
Definition: st2.cc:661
Row dofs type for class vd.
Definition: vd.h:61
bool state_is_not_read_accessible() const
True if this is attached and if the state is accessible for read or if access control is disabled...
A client handle for a poset member which has been prepared for use as a schema.
double vd_value_type
The type of component in the fiber; the scalar type in the fiber vector space.
Definition: fiber_bundle.h:63
A symmetric tensor of degree 2 over a Euclidean vector space of dimension 3 (persistent version)...
Definition: st2_e3.h:435
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.
Definition: scoped_index.h:710
SHEAF_DLL_SPEC bool isunordered_or_equals(float x1, float x2)
True if isunordered(x1, x2) or x1 == x2.
Definition: sheaf.cc:102