SheafSystem  0.0.0.0
gln.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 
22 #ifdef _WIN32
23 
24 // We're compiling with MS C++;
25 // make sure we get M_PI defined.
26 
27 #define _USE_MATH_DEFINES
28 
29 #endif
30 
31 #include "SheafSystem/gln.impl.h"
32 
33 #include "SheafSystem/abstract_poset_member.impl.h"
34 #include "SheafSystem/assert_contract.h"
35 #include "SheafSystem/at1.h"
36 #include "SheafSystem/at1_space.h"
37 #include "SheafSystem/gln_space.h"
38 #include "SheafSystem/fiber_bundles_namespace.h"
39 #include "SheafSystem/schema_poset_member.h"
40 #include "SheafSystem/std_cmath.h"
41 #include "SheafSystem/wsv_block.h"
42 
43 
44 using namespace std;
45 using namespace fiber_bundle; // Workaround for MS C++ bug.
46 
47 
48 //==============================================================================
49 // CLASS GLN_TABLE_DOFS_TYPE
50 //==============================================================================
51 
52 
53 //==============================================================================
54 // CLASS GLN_ROW_DOFS_TYPE
55 //==============================================================================
56 
57 //==============================================================================
58 // CLASS GLN_LITE
59 //==============================================================================
60 
61 
62 //============================================================================
63 // GLN FACET OF CLASS GLN_LITE
64 //============================================================================
65 
66 // PUBLIC MEMBER FUNCTIONS
67 
70 {
71 
72  // Preconditions:
73 
74  // Body:
75 
76  // Postconditions:
77 
78  ensure(invariant());
79 
80  // Exit:
81 }
82 
84 gln_lite(const gln_lite& xother)
85 {
86  // Preconditions:
87 
88  // Body:
89 
90  *this = xother;
91 
92  // Postconditions:
93 
94  ensure(invariant());
95 
96  // Exit:
97 }
98 
101 operator=(const gln_lite& xother)
102 {
103  // Preconditions:
104 
105  // Body:
106 
107  // Postconditions:
108 
109  ensure(invariant());
110 
111  // Exit:
112 
113  return *this;
114 }
115 
118 {
119  // Preconditions:
120 
121  // Body:
122 
123  // Postconditions:
124 
125  // Exit:
126 
127 }
128 
130 gln_lite(const row_dofs_type& xrow_dofs)
131 {
132  // Preconditions:
133 
134  // Body:
135 
136  *this = xrow_dofs;
137 
138  // Postconditions:
139 
140  ensure(invariant());
141 
142  // Exit:
143 }
144 
147 operator=(const row_dofs_type& xrow_dofs)
148 {
149  // Preconditions:
150 
151  // Body:
152 
153  int ld = d();
154  for(int i=0; i<ld; ++i)
155  {
156  put_component(i, xrow_dofs[i]);
157  }
158 
159  // Postconditions:
160 
161  ensure(invariant());
162  ensure_for_all(i, 0, d(), component(i) == xrow_dofs[i]);
163 
164  // Exit:
165 
166  return *this;
167 
168 }
169 
170 int
172 d() const
173 {
174  // Preconditions:
175 
176  // Body:
177 
178  int result = 2*n()*n();
179 
180  // Postconditions:
181 
182  ensure(invariant());
183  ensure(result == 2*n()*n());
184 
185  // Exit:
186 
187  return result;
188 
189 }
190 
191 int
193 n() const
194 {
195  // Preconditions:
196 
197  // Body:
198 
199  int result = 0; // Just to silence compiler.
200 
201  // Postconditions:
202 
203  ensure(invariant());
204  ensure(result == 0);
205 
206  // Exit:
207 
208  return result;
209 }
210 
211 
214 component(int xindex) const
215 {
216  // Preconditions:
217 
218  require((0 <= xindex) &&(xindex < d()));
219 
220  // Body:
221 
222  value_type result = sheaf::row_dofs(*this)[xindex];
223 
224  // Postconditions:
225 
226  ensure(invariant());
227 
228  // Exit:
229 
230  return result;
231 }
232 
233 void
235 put_component(int xindex, value_type xcomp)
236 {
237  // Preconditions:
238 
239  require((0 <= xindex) && (xindex <= d()));
240 
241  // Body:
242 
243  sheaf::row_dofs(*this)[xindex] = xcomp;
244 
245  // Postconditions:
246 
247  ensure(invariant());
248  ensure(isunordered_or_equals(component(xindex), xcomp));
249 
250  // Exit:
251 
252  return;
253 }
254 
255 void
257 components(dof_type xcomps[], int xcomps_dimension) const
258 {
259  // Preconditions:
260 
261  require(xcomps != 0);
262  require(xcomps_dimension >= d());
263 
264  // Body:
265 
266  int ld = d();
267  for(int i=0; i<ld; ++i)
268  {
269  xcomps[i] = component(i);
270  }
271 
272  // Postconditions:
273 
274  ensure(invariant());
275 
276  // Exit:
277 
278  return;
279 }
280 
281 void
283 put_components(const dof_type xcomps[], int xcomps_dimension)
284 {
285  // Preconditions:
286 
287  require(xcomps != 0);
288  require(xcomps_dimension >= d());
289 
290  // Body:
291 
292  int ld = d();
293  for(int i=0; i<ld; ++i)
294  {
295  put_component(i, xcomps[i]);
296  }
297 
298  // Postconditions:
299 
300  ensure(invariant());
301 
302  // Exit:
303 
304  return;
305 }
306 
309 operator[] (int xindex)
310 {
311  // Preconditions:
312 
313  require(xindex >= 0 && xindex < d());
314 
315  // Body:
316 
317  value_type& result = sheaf::row_dofs(*this)[xindex];
318 
319  // Postconditions:
320 
321  // Exit:
322 
323  return result;
324 }
325 
328 operator[] (int xindex) const
329 {
330  // Preconditions:
331 
332  require(xindex >= 0 && xindex < d());
333 
334  // Body:
335 
336  const value_type& result = sheaf::row_dofs(*this)[xindex];
337 
338  // Postconditions:
339 
340  // Exit:
341 
342  return result;
343 }
344 
345 //============================================================================
346 // GROUP FACET OF CLASS GLN_LITE
347 //============================================================================
348 
349 // PUBLIC MEMBER FUNCTIONS
350 
351 // PROTECTED MEMBER FUNCTIONS
352 
353 // PRIVATE MEMBER FUNCTIONS
354 
355 
356 //============================================================================
357 // ABSTRACT POSET MEMBER FACET OF CLASS GLN_LITE
358 //============================================================================
359 
360 // PUBLIC MEMBER FUNCTIONS
361 
362 const std::string&
364 class_name() const
365 {
366  // Preconditions:
367 
368  // Body:
369 
370  const string& result = static_class_name();
371 
372  // Postconditions:
373 
374  ensure(!result.empty());
375 
376  // Exit:
377 
378  return result;
379 }
380 
381 const std::string&
384 {
385  // Preconditions:
386 
387  // Body:
388 
389  static const string result("gln_lite");
390 
391  // Postconditions:
392 
393  ensure(!result.empty());
394 
395  // Exit:
396 
397  return result;
398 }
399 
402 clone() const
403 {
404  gln_lite* result = 0;
405 
406  // Preconditions:
407 
408  // Body:
409 
410  is_abstract();
411 
412  // Postconditions:
413 
414  ensure(result != 0);
415  ensure(is_same_type(*result));
416 
417  // Exit:
418 
419  return result;
420 }
421 
422 
425 table_dofs() const
426 {
427  // Preconditions:
428 
429  // Body:
430 
431  int ln = n();
432 
434 
435  char* lscalar_space_path = new char[1];
436  lscalar_space_path[0] = 0;
437 
438  char* lvector_space_path = new char[1];
439  lvector_space_path[0] = 0;
440 
441  table_dofs_type result =
442  {
443  lscalar_space_path,
444  lvector_space_path,
445  ln
446  };
447 
448  // Postconditions:
449 
450  // Exit:
451 
452  return result;
453 }
454 
455 // PROTECTED MEMBER FUNCTIONS
456 
457 // PRIVATE MEMBER FUNCTIONS
458 
459 
460 //============================================================================
461 // ANY FACET OF CLASS GLN_LITE
462 //============================================================================
463 
464 // PUBLIC MEMBER FUNCTIONS
465 
466 bool
468 is_ancestor_of(const any_lite& xother) const
469 {
470  // Preconditions:
471 
472  require(&xother != 0);
473 
474  // Body:
475 
476  // True if other conforms to this.
477 
478  bool result = dynamic_cast<const gln_lite*>(&xother) != 0;
479 
480  // Postconditions:
481 
482  return result;
483 }
484 
485 
486 bool
488 invariant() const
489 {
490  bool result = true;
491 
492  if(invariant_check())
493  {
494  // Prevent recursive calls to invariant.
495 
496  disable_invariant_check();
497 
498  // Must satisfy base class invariant.
499 
500  invariance(group_lite::invariant());
501 
502  // Invariances for this class:
503 
504  // Finished, turn invariant checking back on.
505 
506  enable_invariant_check();
507  }
508 
509  // Exit
510 
511  return result;
512 }
513 
514 // PROTECTED MEMBER FUNCTIONS
515 
516 // PRIVATE MEMBER FUNCTIONS
517 
518 
519 //==============================================================================
520 // CLASS GLN
521 //==============================================================================
522 
523 // ===========================================================
524 // HOST FACTORY FACET
525 // ===========================================================
526 
527 // PUBLIC MEMBER FUNCTIONS
528 
529 const std::string&
532 {
533  // Preconditions:
534 
535 
536  // Body:
537 
538  static const string result("fiber_space_schema");
539 
540  // Postconditions:
541 
542  ensure(!result.empty());
543 
544  // Exit:
545 
546  return result;
547 }
548 
549 const sheaf::poset_path&
552 {
553  // Preconditions:
554 
555 
556  // Body:
557 
558  static const poset_path result(standard_schema_poset_name(), "gln_schema");
559 
560  // Postconditions:
561 
562  ensure(result.full());
563  ensure(result.poset_name() == standard_schema_poset_name());
564 
565  // Exit:
566 
567  return result;
568 }
569 
570 void
573 {
574  // Preconditions:
575 
576  require(xns.state_is_read_write_accessible());
577  require(xns.contains_poset(standard_schema_poset_name()));
578  require(!xns.contains_poset_member(standard_schema_path()));
579 
580  // Body:
581 
582 
583  // Dof id space space of schema member (e.g. fiber_space_poset/gln_schema) in
584  // will be defined in same order as dof id space of fiber_schema_poset/top,
585  // independent of which order we declare them in.
586  // The members of gln_table_dofs_type must be also declared in this same order;
587  // so we might as well declare the dofs in the same order for consistency.
588 
591 
592  string lmember_names;
593  lmember_names += "scalar_space_path C_STRING true";
594  lmember_names += " vector_space_path C_STRING true";
595  lmember_names += " n INT true";
596 
597  schema_poset_member lschema(xns,
598  standard_schema_path().member_name(),
599  poset_path(standard_schema_poset_name(), "bottom"),
600  lmember_names,
601  false);
602 
603  lschema.detach_from_state();
604 
605  // Postconditions:
606 
607  ensure(xns.contains_poset_member(standard_schema_path()));
608 
609  // Exit:
610 
611  return;
612 }
613 
617  const poset_path& xhost_path,
618  const poset_path& xschema_path,
619  const poset_path& xvector_space_path,
620  bool xauto_access)
621 {
622  // cout << endl << "Entering gln::new_host." << endl;
623 
624  // Preconditions:
625 
626  require(xns.state_is_auto_read_write_accessible(xauto_access));
627 
628  require(!xhost_path.empty());
629  require(!xns.contains_path(xhost_path, xauto_access));
630 
631  require(xschema_path.full());
632  require(xns.path_is_auto_read_accessible(xschema_path, xauto_access));
633  require(schema_poset_member::conforms_to(xns, xschema_path, standard_schema_path()));
634 
635  require(xns.path_is_auto_read_accessible(xvector_space_path, xauto_access));
636  require(xns.contains_poset<vector_space_type::host_type>(xvector_space_path, xauto_access));
637 
638  require(schema_poset_member::row_dof_ct(xns, xschema_path, xauto_access) == host_type::d(xns, xvector_space_path, xauto_access));
639 
640  // Body:
641 
642  host_type& result =
643  host_type::new_table(xns, xhost_path, xschema_path, xvector_space_path, xauto_access);
644 
645  // Postconditions:
646 
647  ensure(xns.owns(result, xauto_access));
648  ensure(result.path(true) == xhost_path);
649  ensure(result.state_is_not_read_accessible());
650  ensure(result.schema(true).path(xauto_access) == xschema_path);
651 
652  ensure(result.scalar_space_path(true) == xns.member_poset<vector_space_type::host_type>(xvector_space_path, xauto_access).scalar_space_path(xauto_access) );
653  ensure(result.n(true) == xns.member_poset<vector_space_type::host_type>(xvector_space_path, xauto_access).d());
654  ensure(result.vector_space_path(true) == xvector_space_path );
655 
656  ensure(result.d(true) == host_type::d(xns, xvector_space_path, xauto_access));
657 
658  // Exit:
659 
660  // cout << "Leaving gln::new_host." << endl;
661  return result;
662 }
663 
664 
665 // PROTECTED MEMBER FUNCTIONS
666 
667 // PRIVATE MEMBER FUNCTIONS
668 
669 
670 //============================================================================
671 // GLN FACET OF CLASS GLN
672 //============================================================================
673 
674 // PUBLIC MEMBER FUNCTIONS
675 
678 {
679 
680  // Preconditions:
681 
682  // Body:
683 
684  // Postconditions:
685 
686  ensure(invariant());
687 
688  // Exit:
689 
690  return;
691 }
692 
694 gln(const gln& xother, bool xnew_jem)
695 {
696 
697  // Preconditions:
698 
699  require(xnew_jem ? xother.is_attached() : true);
700 
701  // Body:
702 
703  // Note: even though the code here is identical to that in
704  // the copy constructors of all descendants of abstract_poset_member,
705  // this can not just call base class copy constructor
706  // because it must invoke versions defined in this class of virtual
707  // attach_to_state and virtual attach_handle_data_members
708  // (called from new_jem_state).
709 
710  if (xnew_jem)
711  {
712  new_jem_state(const_cast<gln*>(&xother), true, true);
713  }
714  else
715  {
716  attach_to_state(&xother);
717  }
718 
719  // Postconditions:
720 
721  ensure(invariant());
722  ensure(is_attached() == xother.is_attached() );
723 }
724 
729 {
730  // Preconditions:
731 
732  require(is_ancestor_of(&xother));
733  require(precondition_of(attach_to_state(&xother)));
734 
735  // Body:
736 
737  attach_to_state(&xother);
738 
739  // Postconditions:
740 
741  ensure(postcondition_of(attach_to_state(&xother)));
742 
743  // Exit:
744 
745  return *this;
746 }
747 
751 operator=(const gln& xother)
752 {
753  // Preconditions:
754 
755  require(precondition_of(attach_to_state(&xother)));
756 
757  // Body:
758 
759  attach_to_state(&xother);
760 
761  // Postconditions:
762 
763  ensure(postcondition_of(attach_to_state(&xother)));
764 
765  // Exit:
766 
767  return *this;
768 }
769 
773 {
774 
775  // Preconditions:
776 
777  // Body:
778 
779  // Postconditions:
780 
781  // Exit:
782 
783  return;
784 }
785 
787 gln(poset* xhost, bool xauto_access)
788 {
789 
790  // Preconditions:
791 
792  require(precondition_of(new_jim_state(xhost, 0, false, xauto_access)));
793 
794  // Body:
795 
796  new_jim_state(xhost, 0, false, xauto_access);
797 
798  // Postconditions:
799 
800  ensure(postcondition_of(new_jim_state(xhost, 0, false, xauto_access)));
801 
802  // Exit:
803 
804  return;
805 }
806 
808 gln(const poset* xhost, pod_index_type xhub_id)
809 {
810  // Preconditions:
811 
812  require(xhost != 0);
813  require(xhost->state_is_read_accessible());
814  require(xhost->contains_member(xhub_id));
815 
816  // Body:
817 
818  attach_to_state(xhost, xhub_id);
819 
820  // Postconditions:
821 
822  ensure(invariant());
823  ensure(is_attached());
824  // ensure(host() == xhost);
825  ensure(index() == xhub_id);
826 }
827 
829 gln(const poset* xhost, const scoped_index& xid)
830 {
831  // Preconditions:
832 
833  require(xhost != 0);
834  require(xhost->state_is_read_accessible());
835  require(xhost->contains_member(xid));
836 
837  // Body:
838 
839  attach_to_state(xhost, xid.hub_pod());
840 
841  // Postconditions:
842 
843  ensure(invariant());
844  ensure(is_attached());
845  // ensure(host() == xhost);
846  ensure(index() ==~ xid);
847 }
848 
850 gln(const poset* xhost, const std::string& xname)
851 {
852 
853  // Preconditions:
854 
855  require(xhost != 0);
856  require(xhost->state_is_read_accessible());
857  require(!xname.empty());
858  require(xhost->contains_member(xname));
859 
860  // Body:
861 
862  attach_to_state(xhost, xname);
863 
864  // Postconditions:
865 
866  ensure(invariant());
867  ensure(is_attached());
868  // ensure(host() == xhost);
869  ensure(name() == xname);
870 
871 }
872 
874 gln(gln* xother)
875 {
876 
877  // Preconditions:
878 
879  require(xother != 0);
880 
881  // Body:
882 
883  attach_to_state(xother);
884 
885  // Postconditions:
886 
887  ensure(invariant());
888  ensure(is_attached());
889  ensure(is_same_state(xother));
890 
891 }
892 
893 int
895 n() const
896 {
897  // Preconditions:
898 
899  require(state_is_read_accessible());
900 
901  // Body:
902 
903  int result = host()->n();
904 
905  // Postconditions:
906 
907  ensure(result >= 0);
908 
909  // Exit:
910 
911  return result;
912 }
913 
914 int
916 n(bool xauto_access) const
917 {
918  // Preconditions:
919 
920  require(state_is_auto_read_accessible(xauto_access));
921 
922  // Body:
923 
924  int result = host()->n(xauto_access);
925 
926  // Postconditions:
927 
928  ensure(result >= 0);
929 
930  // Exit:
931 
932  return result;
933 }
934 
938 {
939  // Preconditions:
940 
941  require(state_is_read_accessible());
942 
943  // Body:
944 
945  poset_path result = host()->scalar_space_path();
946 
947  // Postconditions:
948 
949  ensure(!result.empty());
950 
951  // Exit:
952 
953  return result;
954 }
955 
958 scalar_space_path(bool xauto_access) const
959 {
960  // Preconditions:
961 
962  require(state_is_auto_read_accessible(xauto_access));
963 
964  // Body:
965 
966  poset_path result = host()->scalar_space_path(xauto_access);
967 
968  // Postconditions:
969 
970  ensure(!result.empty());
971 
972  // Exit:
973 
974  return result;
975 }
976 
980 {
981  // Preconditions:
982 
983  require(state_is_read_accessible());
984 
985  // Body:
986 
987  poset_path result = host()->vector_space_path();
988 
989  // Postconditions:
990 
991  ensure(!result.empty());
992 
993  // Exit:
994 
995  return result;
996 }
997 
1000 vector_space_path(bool xauto_access) const
1001 {
1002  // Preconditions:
1003 
1004  require(state_is_auto_read_accessible(xauto_access));
1005 
1006  // Body:
1007 
1008  poset_path result = host()->vector_space_path(xauto_access);
1009 
1010  // Postconditions:
1011 
1012  ensure(!result.empty());
1013 
1014  // Exit:
1015 
1016  return result;
1017 }
1018 
1019 int
1021 d() const
1022 {
1023  // Preconditions:
1024 
1025  require(state_is_read_accessible());
1026 
1027  // Body:
1028 
1029  int ln = n();
1030  int result = 2*ln*ln;
1031 
1032  // Postconditions:
1033 
1035  // ensure(invariant());
1036  ensure(result >= 0);
1037 
1038  // Exit:
1039 
1040  return result;
1041 }
1042 
1043 int
1045 d(bool xauto_access) const
1046 {
1047  // Preconditions:
1048 
1049  require(state_is_auto_read_accessible(xauto_access));
1050 
1051  // Body:
1052 
1053  if(xauto_access)
1054  {
1055  get_read_access();
1056  }
1057 
1058  int result = d();
1059 
1060  if(xauto_access)
1061  {
1062  release_access();
1063  }
1064 
1065  // Postconditions:
1066 
1068  // ensure(invariant());
1069  ensure(result >= 0);
1070 
1071  // Exit:
1072 
1073  return result;
1074 }
1075 
1078 component(int xindex) const
1079 {
1080  // Preconditions:
1081 
1082  require(state_is_read_accessible());
1083  require((0 <= xindex) &&(xindex < d()));
1084 
1085  // Body:
1086 
1087  value_type result = sheaf::row_dofs(*this)[xindex];
1088 
1089  // Postconditions:
1090 
1091  ensure(invariant());
1092 
1093  // Exit:
1094 
1095  return result;
1096 }
1097 
1100 component(int xindex, bool xauto_access) const
1101 {
1102  // Preconditions:
1103 
1104  require(state_is_auto_read_accessible(xauto_access));
1105  require((0 <= xindex) &&(xindex < d(xauto_access)));
1106 
1107  // Body:
1108 
1109  if(xauto_access)
1110  {
1111  get_read_access();
1112  }
1113 
1114  value_type result = component(xindex);
1115 
1116  if(xauto_access)
1117  {
1118  release_access();
1119  }
1120 
1121  // Postconditions:
1122 
1123  ensure(invariant());
1124 
1125  // Exit:
1126 
1127  return result;
1128 }
1129 
1130 void
1132 put_component(int xindex, value_type xcomp)
1133 {
1134  // Preconditions:
1135 
1136  require(state_is_read_write_accessible());
1137  require((0 <= xindex) && (xindex <= d()));
1138 
1139  // Body:
1140 
1141  sheaf::row_dofs(*this)[xindex] = xcomp;
1142 
1143  // Postconditions:
1144 
1145  ensure(invariant());
1146  ensure(isunordered_or_equals(component(xindex), xcomp));
1147 
1148  // Exit:
1149 
1150  return;
1151 }
1152 
1153 void
1155 put_component(int xindex, value_type xcomp, bool xauto_access)
1156 {
1157  // Preconditions:
1158 
1159  require(state_is_auto_read_write_accessible(xauto_access));
1160  require((0 <= xindex) && (xindex <= d(xauto_access)));
1161 
1162  // Body:
1163 
1164  if(xauto_access)
1165  {
1166  get_read_write_access(true);
1167  }
1168 
1169  put_component(xindex, xcomp);
1170 
1171  if(xauto_access)
1172  {
1173  release_access();
1174  }
1175 
1176  // Postconditions:
1177 
1178  ensure(invariant());
1179  ensure(isunordered_or_equals(component(xindex), xcomp));
1180 
1181  // Exit:
1182 
1183  return;
1184 }
1185 
1186 void
1188 components(dof_type xcomps[], int xcomps_dimension) const
1189 {
1190  // Preconditions:
1191 
1192  require(state_is_read_accessible());
1193  require(xcomps != 0);
1194  require(xcomps_dimension >= d());
1195 
1196  // Body:
1197 
1198  int ld = d();
1199  for(int i=0; i<ld; ++i)
1200  {
1201  xcomps[i] = component(i);
1202  }
1203 
1204  // Postconditions:
1205 
1206  // ensure(invariant());
1207 
1208  // Exit:
1209 
1210  return;
1211 }
1212 
1213 void
1215 put_components(const dof_type xcomps[], int xcomps_dimension)
1216 {
1217  // Preconditions:
1218 
1219  require(state_is_read_write_accessible());
1220  require(xcomps != 0);
1221  require(xcomps_dimension >= d());
1222 
1223  // Body:
1224 
1225  int ld = d();
1226  for(int i=0; i<ld; ++i)
1227  {
1228  put_component(i, xcomps[i]);
1229  }
1230 
1231  // Postconditions:
1232 
1233  ensure(invariant());
1234 
1235  // Exit:
1236 
1237  return;
1238 }
1239 
1242 operator[] (int xindex)
1243 {
1244  // Preconditions.
1245 
1246  require(state_is_read_write_accessible());
1247  ensure(xindex>=0 && xindex<d());
1248 
1249  // Body:
1250 
1251  dof_type& result = sheaf::row_dofs(*this)[xindex];
1252 
1253  // Postconditions:
1254 
1255  // Exit:
1256 
1257  return result;
1258 }
1259 
1262 operator[] (int xindex) const
1263 {
1264  // Preconditions.
1265 
1266  require(state_is_read_accessible());
1267  require(xindex>=0 && xindex<d());
1268 
1269  // Body:
1270 
1271  const dof_type& result = sheaf::row_dofs(*this)[xindex];
1272 
1273  // Postconditions:
1274 
1275  // Exit:
1276 
1277  return result;
1278 
1279 }
1280 
1284 lite_type() const
1285 {
1286  // Preconditions:
1287 
1288  // Body:
1289 
1291  //volatile_type* result = new volatile_type(sheaf::row_dofs(*this));
1292 
1293  volatile_type* result = new volatile_type();
1294  for(int i=0; i<d(); ++i)
1295  {
1296  value_type v = component(i);
1297  result->put_component(i, v);
1298  }
1299 
1300  // Postconditions:
1301 
1302  // Exit:
1303 
1304  return result;
1305 }
1306 
1307 // PROTECTED MEMBER FUNCTIONS
1308 
1309 // PRIVATE MEMBER FUNCTIONS
1310 
1311 
1312 //============================================================================
1313 // GROUP FACET OF CLASS GLN
1314 //============================================================================
1315 
1316 // PUBLIC MEMBER FUNCTIONS
1317 
1318 // PROTECTED MEMBER FUNCTIONS
1319 
1320 // PRIVATE MEMBER FUNCTIONS
1321 
1322 
1323 //============================================================================
1324 // ABSTRACT POSET MEMBER FACET OF CLASS GLN
1325 //============================================================================
1326 
1327 // PUBLIC MEMBER FUNCTIONS
1328 
1329 const std::string&
1331 class_name() const
1332 {
1333  // Preconditions:
1334 
1335  // Body:
1336 
1337  const string& result = static_class_name();
1338 
1339  // Postconditions:
1340 
1341  ensure(!result.empty());
1342 
1343  // Exit:
1344 
1345  return result;
1346 }
1347 
1348 const std::string&
1351 {
1352  // Preconditions:
1353 
1354  // Body:
1355 
1356  static const string result("gln");
1357 
1358  // Postconditions:
1359 
1360  ensure(!result.empty());
1361 
1362  // Exit:
1363 
1364  return result;
1365 }
1366 
1367 // PROTECTED MEMBER FUNCTIONS
1368 
1369 // PRIVATE MEMBER FUNCTIONS
1370 
1371 
1372 // ===========================================================
1373 // POSET_COMPONENT FACET
1374 // ===========================================================
1375 
1376 
1379 host() const
1380 {
1381  return reinterpret_cast<host_type*>(_host);
1382 }
1383 
1384 bool
1387 {
1388  return dynamic_cast<const host_type*>(xother) != 0;
1389 }
1390 
1391 // PROTECTED MEMBER FUNCTIONS
1392 
1393 // PRIVATE MEMBER FUNCTIONS
1394 
1395 
1396 
1397 //===========================================================================
1398 // ANY FACET OF CLASS GLN
1399 //===========================================================================
1400 
1401 // PUBLIC MEMBER FUNCTIONS
1402 
1403 bool
1405 invariant() const
1406 {
1407  bool result = true;
1408 
1409  // Preconditions:
1410 
1411  // Body:
1412 
1413  // Must satisfy base class invariant.
1414 
1415  invariance(group::invariant());
1416 
1417  if (invariant_check())
1418  {
1419  // Prevent recursive calls to invariant.
1420 
1421  disable_invariant_check();
1422 
1423  // Finished, turn invariant checking back on.
1424 
1425  enable_invariant_check();
1426  }
1427 
1428  // Postconditions:
1429 
1430  ensure(is_derived_query);
1431 
1432  // Exit:
1433 
1434  return result;
1435 }
1436 
1439 clone() const
1440 {
1441 
1442  // Preconditions:
1443 
1444  // Body:
1445 
1446  // Create new handle of the current class.
1447 
1448  gln* result = new gln();
1449 
1450  // Postconditions:
1451 
1452  ensure(result != 0);
1453 
1454  // Exit:
1455 
1456  return result;
1457 
1458 }
1459 
1460 bool
1462 is_ancestor_of(const any* xother) const
1463 {
1464 
1465  // Preconditions:
1466 
1467  require(xother != 0);
1468 
1469  // Body:
1470 
1471  // True if xother conforms to this.
1472 
1473  bool result = dynamic_cast<const gln*>(xother) != 0;
1474 
1475  // Postconditions:
1476 
1477  // Exit:
1478 
1479  return result;
1480 
1481 }
1482 
1483 // PROTECTED MEMBER FUNCTIONS
1484 
1485 // PRIVATE MEMBER FUNCTIONS
1486 
1487 
1488 //==============================================================================
1489 // NON-MEMBER FUNCTIONS
1490 //==============================================================================
1491 
1492 double
1494 rad(double degrees)
1495 {
1496  static const double RAD_PER_DEG = M_PI/180.0;
1497  return degrees*RAD_PER_DEG;
1498 };
1499 
1500 std::ostream&
1502 operator<<(std::ostream& xos, gln_lite::table_dofs_type& xt)
1503 {
1504  xos << " " << xt.n
1505  << " " << xt.scalar_space_path
1506  << " " << xt.vector_space_path;
1507 
1508  return xos;
1509 }
1510 
1511 std::ostream&
1513 operator<<(std::ostream& xos, gln_lite& xv)
1514 {
1515  int ld = xv.d();
1516  for(int i=0; i<ld; ++i)
1517  {
1518  xos << " " << xv[i];
1519  }
1520 
1521  return xos;
1522 }
1523 
1524 
static const poset_path & standard_schema_path()
The path to the standard schema for this class.
Definition: gln.cc:551
void put_components(const dof_type xcomps[], int xcomps_dimension)
Set values of all the components to the values in xcomps.
Definition: gln.cc:283
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 ...
SHEAF_DLL_SPEC double rad(double degrees)
Converts degress to radians. Convenience function for use with rotation routines. ...
Definition: gln.cc:1494
bool full() const
True if both poset name and member name are not empty.
Definition: poset_path.cc:311
void components(dof_type xcomps[], int xcomps_dimension) const
The values of all the components (pre-allocated version).
Definition: gln.cc:1188
value_type & operator[](int xindex)
The value of the component corresponding to xindex (non const version).
Definition: gln.cc:309
poset_path vector_space_path() const
The path of the underlying vector space.
Definition: gln.cc:979
virtual ~gln()
Destructor.
Definition: gln.cc:772
poset_path path(bool xauto_access=true) const
A path to this component.
The mathematical group GL(n, R). GL(n,R) is the group of general, invertible, linear transformations ...
Definition: gln.h:103
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 gln_lite * clone() const
Virtual constructor, makes a new instance of the same type as this.
Definition: gln.cc:402
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...
A client handle for a general, abstract partially order set.
poset_path vector_space_path() const
The path of the underlying vector space.
Definition: gln_space.cc:306
gln_lite & operator=(const gln_lite &xother)
Assignment operator.
Definition: gln.cc:101
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
STL namespace.
virtual value_type component(int xindex) const
The value of the xi-th component.
Definition: gln.cc:1078
virtual bool host_is_ancestor_of(const poset_state_handle *other) const
True if other conforms to host.
Definition: gln.cc:1386
The mathematical group GL(n, R). GL(n,R) is the group of general, invertible, linear transformations ...
Definition: gln.h:289
virtual ~gln_lite()
Destructor.
Definition: gln.cc:117
void put_components(const dof_type xcomps[], int xcomps_dimension)
Sets values of all the components to the values in comps.
Definition: gln.cc:1215
poset_state_handle & member_poset(pod_index_type xhub_id, bool xauto_access=true) const
The poset_state_handle object referred to by hub id xhub_id.
table_dofs_type table_dofs() const
The table dofs.
Definition: gln.cc:425
virtual bool invariant() const
Class invariant.
Definition: gln.cc:1405
vd_value_type value_type
The POD ("plain old data") type of scalar in the vector space of this.
Definition: gln.h:374
static const std::string & static_class_name()
The name of this class.
Definition: gln.cc:1350
gln_lite()
Default constructor.
Definition: gln.cc:69
virtual int d() const
Dimension of this as a vector space.
Definition: gln.cc:1021
T::row_dofs_type & row_dofs(T &x0)
The row dofs pod type for x0 (mutable version).
static const std::string & standard_schema_poset_name()
The name of the standard schema poset for this class.
Definition: gln.cc:531
virtual const std::string & class_name() const
The name of this class.
Definition: gln.cc:364
static const std::string & static_class_name()
The name of this class.
Definition: gln.cc:383
host_type * host() const
The poset this is a member of.
Definition: gln.cc:1379
virtual volatile_type * lite_type() const
Virtual conversion to the associated volatile type.
Definition: gln.cc:1284
virtual bool is_ancestor_of(const any *xother) const
Conformance test; true if other conforms to this.
Definition: gln.cc:1462
c_string scalar_space_path
The path of the underlying scalar space.
dof_type & operator[](int xindex)
The value of the row dof corresponding to xindex (non const version).
Definition: gln.cc:1242
virtual gln & operator=(const abstract_poset_member &xother)
Assignment operator; synonym for attach_to_state(&xother).
Definition: gln.cc:728
int n
Dimension of the representation space; n in GL(n, R).
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
virtual schema_poset_member & schema()
The schema for this poset (mutable version).
A client handle for a mutable partially ordered set.
Definition: poset.h:40
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...
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)
virtual bool is_ancestor_of(const any_lite &xother) const
Conformance test; true if other conforms to this.
Definition: gln.cc:468
virtual void detach_from_state()
Detach this handle from its state, if any.
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
virtual bool is_attached() const
True if this handle is attached to a non-void state.
std::string poset_name() const
The poset name part of the path.
Definition: poset_path.cc:473
vd_dof_type dof_type
The type of the degrees of freedom.
Definition: gln.h:115
bool contains_path(const poset_path &xpath, bool xauto_access=true) const
True if this contains the poset or poset member specified by xpath.
vd_value_type value_type
The type of component in the fiber; the scalar type in the fiber vector space.
Definition: gln.h:121
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. ...
bool empty() const
True if both poset name and member name are empty.
Definition: poset_path.cc:291
virtual int n() const
Dimension of the representation space; n in GL(n, R).
Definition: gln.cc:193
gln()
Default constructor.
Definition: gln.cc:677
bool contains_poset(pod_index_type xhub_id, bool xauto_access=true) const
True if this contains a poset with hub id xhub_id..
virtual int d() const
The dimension of the row dof components.
Definition: gln.cc:172
A Cartesian product space.
Definition: gln_space.h:52
virtual void put_component(int xi, value_type xvalue)
Sets the value of the xi-th component to xvalue.
Definition: gln.cc:1132
value_type component(int xindex) const
The xindex-th component.
Definition: gln.cc:214
An abstract vector space viewed as an antisymmetric tensor space of degree 1.
Definition: at1_space.h:42
bool invariant() const
Class invariant.
Definition: gln.cc:488
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
vd_dof_type dof_type
The type of the degrees of freedom. Note that although dof_type == value_type in this implementation...
Definition: gln.h:381
poset_path scalar_space_path() const
The path of the underlying scalar space.
Definition: gln.cc:937
virtual gln * clone() const
Make a new handle, no state instance of current.
Definition: gln.cc:1439
void components(dof_type xcomps[], int xcomps_dimension) const
The values of all the components (preallocated version).
Definition: gln.cc:257
An abstract client handle for a member of a poset.
void put_component(int xindex, value_type xcomp)
Set the xindex-th component to xcomp.
Definition: gln.cc:235
Row dofs type for class gln.
Definition: gln.h:54
static int d(const namespace_poset &xns, const poset_path &xvector_space_path, bool xauto_access)
The dimension of the representation space; n in GL(n, R) implied by the vector space specified by xve...
Definition: gln_space.cc:84
c_string vector_space_path
The path of the underlying vector space.
Namespace for the fiber_bundles component of the sheaf system.
virtual const std::string & class_name() const
The name of this class.
Definition: gln.cc:1331
int n() const
Dimension of the representation space; n in GL(n, R).
Definition: gln_space.cc:202
int n() const
Dimension of the representation space; n in GL(n, R).
Definition: gln.cc:895
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.
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: gln.cc:616
SHEAF_DLL_SPEC std::ostream & operator<<(std::ostream &os, const binary_index &xbi)
Insert binary_index& xbi into ostream& os.
Definition: binary_index.cc:35
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.
Definition: scoped_index.h:710
poset_path scalar_space_path() const
The path of the underlying scalar space.
Definition: gln_space.cc:254
SHEAF_DLL_SPEC bool isunordered_or_equals(float x1, float x2)
True if isunordered(x1, x2) or x1 == x2.
Definition: sheaf.cc:102
static void make_standard_schema(namespace_poset &xns)
Creates the standard schema for this class in namespace xns.
Definition: gln.cc:572