SheafSystem  0.0.0.0
ed.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/ed.h"
22 
23 #include "SheafSystem/abstract_poset_member.impl.h"
24 #include "SheafSystem/assert_contract.h"
25 #include "SheafSystem/at0.h"
26 #include "SheafSystem/at1_space.h"
27 #include "SheafSystem/fiber_bundles_namespace.h"
28 #include "SheafSystem/schema_poset_member.h"
29 #include "SheafSystem/wsv_block.h"
30 
31 using namespace std;
32 using namespace fiber_bundle; // Workaround for MS C++ bug.
33 
34 
35 //==============================================================================
36 // CLASS ED_LITE
37 //==============================================================================
38 
39 //==============================================================================
40 // EUCLIDEAN VECTOR ALGEBRA (ED) FACET
41 //==============================================================================
42 
43 // PUBLIC MEMBER FUNCTIONS
44 
47 {
48 
49  // Preconditions:
50 
51  // Body:
52 
53  // Postconditions:
54 
55  ensure(invariant());
56 
57  // Exit:
58 }
59 
61 ed_lite(const ed_lite& xother)
62 {
63  // Preconditions:
64 
65  // Body:
66 
67  *this = xother;
68 
69  // Postconditions:
70 
71  ensure(invariant());
72 
73  // Exit:
74 }
75 
78 operator=(const ed_lite& xother)
79 {
80 
81  // Preconditions:
82 
83 
84  // Body:
85 
86 
87  // Postconditions:
88 
89  ensure(invariant());
90 
91  // Exit:
92 
93  return *this;
94 }
95 
98 {
99  // Preconditions:
100 
101  // Body:
102 
103  // Postconditions:
104 
105  // Exit:
106 
107 }
108 
110 ed_lite(const row_dofs_type& xrow_dofs)
111 {
112  // Preconditions:
113 
114  // Body:
115 
116  *this = xrow_dofs;
117 
118  // Postconditions:
119 
120  ensure(invariant());
121 
122  // Exit:
123 }
124 
127 operator=(const row_dofs_type& xrow_dofs)
128 {
129  // Preconditions:
130 
131  // Body:
132 
133  vd_lite::operator=(xrow_dofs);
134 
135  // Postconditions:
136 
137  postcondition_of(vd_lite::operator=(xrow_dofs));
138 
139  // Exit:
140 
141  return *this;
142 
143 }
144 
145 // PROTECTED MEMBER FUNCTIONS
146 
147 // PRIVATE MEMBER FUNCTIONS
148 
149 
150 //==============================================================================
151 // AT1 FACET
152 //==============================================================================
153 
154 // PUBLIC MEMBER FUNCTIONS
155 
156 // PROTECTED MEMBER FUNCTIONS
157 
158 // PRIVATE MEMBER FUNCTIONS
159 
160 
161 //==============================================================================
162 // EXTERIOR ALGEBRA (ATP) FACET
163 //==============================================================================
164 
165 // PUBLIC MEMBER FUNCTIONS
166 
167 // PROTECTED MEMBER FUNCTIONS
168 
169 // PRIVATE MEMBER FUNCTIONS
170 
171 
172 //==============================================================================
173 // TENSOR ALGEBRA (TP) FACET
174 //==============================================================================
175 
176 // PUBLIC MEMBER FUNCTIONS
177 
178 // PROTECTED MEMBER FUNCTIONS
179 
180 // PRIVATE MEMBER FUNCTIONS
181 
182 
183 //==============================================================================
184 // VECTOR ALGEBRA (VD) FACET
185 //==============================================================================
186 
187 // PUBLIC MEMBER FUNCTIONS
188 
189 // PROTECTED MEMBER FUNCTIONS
190 
191 // PRIVATE MEMBER FUNCTIONS
192 
193 
194 //==============================================================================
195 // CARTESIAN ALGEBRA (TUPLE) FACET
196 //==============================================================================
197 
198 // PUBLIC MEMBER FUNCTIONS
199 
200 // PROTECTED MEMBER FUNCTIONS
201 
202 // PRIVATE MEMBER FUNCTIONS
203 
204 
205 //==============================================================================
206 // ABSTRACT POSET MEMBER FACET
207 //==============================================================================
208 
209 // PUBLIC MEMBER FUNCTIONS
210 
211 const std::string&
213 class_name() const
214 {
215  // Preconditions:
216 
217  // Body:
218 
219  const string& result = static_class_name();
220 
221  // Postconditions:
222 
223  ensure(!result.empty());
224 
225  // Exit:
226 
227  return result;
228 }
229 
230 const std::string&
233 {
234  // Preconditions:
235 
236  // Body:
237 
238  static const string result("ed_lite");
239 
240  // Postconditions:
241 
242  ensure(!result.empty());
243 
244  // Exit:
245 
246  return result;
247 }
248 
251 clone() const
252 {
253  ed_lite* result = 0;
254 
255  // Preconditions:
256 
257  // Body:
258 
259  result = new ed_lite();
260 
261  // Postconditions:
262 
263  ensure(result != 0);
264  ensure(is_same_type(*result));
265 
266  // Exit:
267 
268  return result;
269 }
270 
271 // PROTECTED MEMBER FUNCTIONS
272 
273 // PRIVATE MEMBER FUNCTIONS
274 
275 
276 //==============================================================================
277 // ANY FACET
278 //==============================================================================
279 
280 // PUBLIC MEMBER FUNCTIONS
281 
282 bool
284 is_ancestor_of(const any_lite& xother) const
285 {
286  // Preconditions:
287 
288  require(&xother != 0);
289 
290  // Body:
291 
292  // True if other conforms to this.
293 
294  bool result = dynamic_cast<const ed_lite*>(&xother) != 0;
295 
296  // Postconditions:
297 
298  return result;
299 }
300 
301 bool
303 invariant() const
304 {
305  bool result = true;
306 
307  if(invariant_check())
308  {
309  // Prevent recursive calls to invariant.
310 
311  disable_invariant_check();
312 
313  // Must satisfy base class invariant.
314 
315  invariance(at1_lite::invariant());
316 
317  // Invariances for this class:
318 
319  // Finished, turn invariant checking back on.
320 
321  enable_invariant_check();
322  }
323 
324  // Exit
325 
326  return result;
327 }
328 
329 // PROTECTED MEMBER FUNCTIONS
330 
331 // PRIVATE MEMBER FUNCTIONS
332 
333 
334 //==============================================================================
335 // CLASS ED
336 //==============================================================================
337 
338 // ===========================================================
339 // HOST FACTORY FACET OF CLASS ED
340 // ===========================================================
341 
342 // PUBLIC MEMBER FUNCTIONS
343 
344 const sheaf::poset_path&
347 {
348  // Preconditions:
349 
350 
351  // Body:
352 
353  static const poset_path result(standard_schema_poset_name(), "ed_schema");
354 
355  // Postconditions:
356 
357  // Exit:
358 
359  return result;
360 }
361 
362 void
365 {
366  // Preconditions:
367 
368  require(xns.state_is_read_write_accessible());
369  require(xns.contains_poset(standard_schema_poset_name()));
370  require(!xns.contains_poset_member(standard_schema_path()));
371 
372  // Body:
373 
374  schema_poset_member lschema(xns,
375  standard_schema_path().member_name(),
376  at1::standard_schema_path(),
377  "",
378  false);
379 
380  lschema.detach_from_state();
381 
382  // Postconditions:
383 
384  ensure(xns.contains_poset_member(standard_schema_path()));
385 
386  // Exit:
387 
388  return;
389 }
390 
394  const poset_path& xhost_path,
395  const poset_path& xschema_path,
396  const poset_path& xscalar_space_path,
397  bool xauto_access)
398 {
399  // cout << endl << "Entering ed::new_host." << endl;
400 
401  // Preconditions:
402 
403  require(xns.state_is_auto_read_write_accessible(xauto_access));
404 
405  require(!xhost_path.empty());
406  require(!xns.contains_path(xhost_path, xauto_access));
407 
408  require(xschema_path.full());
409  require(xns.path_is_auto_read_accessible(xschema_path, xauto_access));
410  require(schema_poset_member::conforms_to(xns, xschema_path, standard_schema_path()));
411 
412  require(xns.path_is_auto_read_accessible(xscalar_space_path, xauto_access));
413  require(xns.contains_poset<scalar_type::host_type>(xscalar_space_path, xauto_access));
414 
415  // Body:
416 
417  host_type& result =
418  host_type::new_table(xns, xhost_path, xschema_path, xscalar_space_path, xauto_access);
419 
420  // Postconditions:
421 
422  ensure(xns.owns(result, xauto_access));
423  ensure(result.path(true) == xhost_path);
424  ensure(result.state_is_not_read_accessible());
425  ensure(result.schema(true).path(xauto_access) == xschema_path);
426 
427  ensure(result.factor_ct(true) == result.d(true));
428  ensure(result.d(true) == schema_poset_member::row_dof_ct(xns, xschema_path, xauto_access));
429  ensure(result.scalar_space_path(true) == xscalar_space_path );
430  ensure(result.p(true) == 1);
431  ensure(result.dd(true) == result.d(true));
432  ensure(result.vector_space_path(true) == xhost_path );
433 
434  // Exit:
435 
436  // cout << "Leaving ed::new_host." << endl;
437  return result;
438 }
439 
440 // PROTECTED MEMBER FUNCTIONS
441 
442 // PRIVATE MEMBER FUNCTIONS
443 
444 
445 //==============================================================================
446 // EUCLIDEAN VECTOR ALGEBRA (ED) FACET
447 //==============================================================================
448 
449 // PUBLIC MEMBER FUNCTIONS
450 
452 ed()
453 {
454 
455  // Preconditions:
456 
457  // Body:
458 
459  // Postconditions:
460 
461  ensure(invariant());
462 }
463 
465 ed(const poset_state_handle* xhost, pod_index_type xhub_id)
466 {
467  // Preconditions:
468 
469  require(xhost != 0);
470  require(xhost->state_is_read_accessible());
471  require(xhost->contains_member(xhub_id));
472 
473  // Body:
474 
475  attach_to_state(xhost, xhub_id);
476 
477  // Postconditions:
478 
479  ensure(invariant());
480  // ensure(host() == xhost);
481  ensure(index() == xhub_id);
482  ensure(is_attached());
483 }
484 
486 ed(const poset_state_handle* xhost, const scoped_index& xid)
487 {
488  // Preconditions:
489 
490  require(xhost != 0);
491  require(xhost->state_is_read_accessible());
492  require(xhost->contains_member(xid));
493 
494  // Body:
495 
496  attach_to_state(xhost, xid.hub_pod());
497 
498  // Postconditions:
499 
500  ensure(invariant());
501  // ensure(host() == xhost);
502  ensure(index() ==~ xid);
503  ensure(is_attached());
504 }
505 
507 ed(const poset_state_handle* xhost, const std::string& xname)
508 {
509 
510  // Preconditions:
511 
512  require(xhost != 0);
513  require(xhost->state_is_read_accessible());
514  require(!xname.empty());
515  require(xhost->contains_member(xname));
516 
517  // Body:
518 
519  attach_to_state(xhost, xname);
520 
521  // Postconditions:
522 
523  ensure(invariant());
524  // ensure(host() == xhost);
525  ensure(name() == xname);
526  ensure(is_attached());
527 
528 }
529 
532 {
533 
534  // Preconditions:
535 
536  require(xother != 0);
537 
538  // Body:
539 
540  attach_to_state(xother);
541 
542  // Postconditions:
543 
544  ensure(invariant());
545  ensure(is_attached());
546  ensure(is_same_state(xother));
547 
548 }
549 
551 ed(poset_state_handle* xhost, bool xauto_access)
552 {
553 
554  // Preconditions:
555 
556  require(precondition_of(new_jim_state(xhost, 0, false, xauto_access)));
557 
558  // Body:
559 
560  new_jim_state(xhost, 0, false, xauto_access);
561 
562  // Postconditions:
563 
564  ensure(postcondition_of(new_jim_state(xhost, 0, false, xauto_access)));
565 
566  // Exit:
567 
568  return;
569 }
570 
575 {
576  // Preconditions:
577 
578  require(is_ancestor_of(&xother));
579  require(precondition_of(attach_to_state(&xother)));
580 
581  // Body:
582 
583  attach_to_state(&xother);
584 
585  // Postconditions:
586 
587  ensure(postcondition_of(attach_to_state(&xother)));
588 
589  // Exit:
590 
591  return *this;
592 }
593 
597 operator=(const ed& xother)
598 {
599  // Preconditions:
600 
601  require(precondition_of(attach_to_state(&xother)));
602 
603  // Body:
604 
605  attach_to_state(&xother);
606 
607  // Postconditions:
608 
609  ensure(postcondition_of(attach_to_state(&xother)));
610 
611  // Exit:
612 
613  return *this;
614 }
615 
618 {
619 
620  // Preconditions:
621 
622  // Body:
623 
624  // Postconditions:
625 
626 }
627 
631 {
632  // Preconditions:
633 
634  // Body:
635 
636  static const volatile_type result;
637 
638  // Postconditions:
639 
640  // Exit:
641 
642  return result;
643 }
644 
648 lite_type() const
649 {
650  // Preconditions:
651 
652  // Body:
653 
654  volatile_type* result = new volatile_type(sheaf::row_dofs(*this));
655 
656  // Postconditions:
657 
658  // Exit:
659 
660  return result;
661 }
662 
663 
664 // PROTECTED MEMBER FUNCTIONS
665 
666 // PRIVATE MEMBER FUNCTIONS
667 
668 
669 //==============================================================================
670 // EXTERIOR ALGEBRA (ATP) FACET
671 //==============================================================================
672 
673 // PUBLIC MEMBER FUNCTIONS
674 
675 // PROTECTED MEMBER FUNCTIONS
676 
677 // PRIVATE MEMBER FUNCTIONS
678 
679 
680 //==============================================================================
681 // TENSOR ALGEBRA (TP) FACET
682 //==============================================================================
683 
684 // PUBLIC MEMBER FUNCTIONS
685 
686 // PROTECTED MEMBER FUNCTIONS
687 
688 // PRIVATE MEMBER FUNCTIONS
689 
690 
691 //==============================================================================
692 // VECTOR ALGEBRA (VD) FACET
693 //==============================================================================
694 
695 // PUBLIC MEMBER FUNCTIONS
696 
697 // PROTECTED MEMBER FUNCTIONS
698 
699 // PRIVATE MEMBER FUNCTIONS
700 
701 
702 //==============================================================================
703 // CARTESIAN ALGEBRA (TUPLE) FACET
704 //==============================================================================
705 
706 // PUBLIC MEMBER FUNCTIONS
707 
708 // PROTECTED MEMBER FUNCTIONS
709 
710 // PRIVATE MEMBER FUNCTIONS
711 
712 
713 //==============================================================================
714 // ABSTRACT POSET MEMBER FACET
715 //==============================================================================
716 
717 // PUBLIC MEMBER FUNCTIONS
718 
719 const std::string&
721 class_name() const
722 {
723  // Preconditions:
724 
725  // Body:
726 
727  const string& result = static_class_name();
728 
729  // Postconditions:
730 
731  ensure(!result.empty());
732 
733  // Exit:
734 
735  return result;
736 }
737 
738 const std::string&
741 {
742  // Preconditions:
743 
744  // Body:
745 
746  static const string result("ed");
747 
748  // Postconditions:
749 
750  ensure(!result.empty());
751 
752  // Exit:
753 
754  return result;
755 }
756 
759 clone() const
760 {
761 
762  // Preconditions:
763 
764  // Body:
765 
766  // Create new handle of the current class.
767 
768  ed* result = new ed();
769 
770  // Postconditions:
771 
772  ensure(result != 0);
773  ensure(result->invariant());
774 
775  // Exit:
776 
777  return result;
778 
779 }
780 
781 // PROTECTED MEMBER FUNCTIONS
782 
783 // PRIVATE MEMBER FUNCTIONS
784 
785 
786 //==============================================================================
787 // ANY FACET
788 //==============================================================================
789 
790 // PUBLIC MEMBER FUNCTIONS
791 
792 bool
794 is_ancestor_of(const any* xother) const
795 {
796 
797  // Preconditions:
798 
799  require(xother != 0);
800 
801  // Body:
802 
803  // If other may be dynamically cast to the type of this then this is an
804  // ancestor of other.
805 
806  bool result = dynamic_cast<const ed*>(xother) != 0;
807 
808  // Postconditions:
809 
810  // ensure(invariant());
811 
812  // Exit:
813 
814  return result;
815 
816 }
817 
818 bool
820 invariant() const
821 {
822  bool result = true;
823 
824  // Preconditions:
825 
826  // Body:
827 
828  // Must satisfy base class invariant.
829 
830  invariance(at1::invariant());
831 
832  if(invariant_check())
833  {
834  // Prevent recursive calls to invariant.
835 
836  disable_invariant_check();
837 
838  // Finished, turn invariant checking back on.
839 
840  enable_invariant_check();
841  }
842 
843  // Postconditions:
844 
845  ensure(is_derived_query);
846 
847  // Exit:
848 
849  return result;
850 }
851 
852 // PROTECTED MEMBER FUNCTIONS
853 
854 // PRIVATE MEMBER FUNCTIONS
855 
856 
857 //==============================================================================
858 // NON-MEMBER FUNCTIONS
859 //==============================================================================
860 
863 dot(const ed& x0, const ed& x1, bool xauto_access)
864 {
865  // Preconditions:
866 
867  require(x0.state_is_auto_read_accessible(xauto_access));
868  require(x1.state_is_auto_read_accessible(xauto_access));
869  require(x0.is_same_type(&x1));
870  require(x0.is_p_form(xauto_access) == x1.is_p_form(xauto_access));
871 
872  // Body:
873 
874  if(xauto_access)
875  {
876  x0.get_read_access();
877  x1.get_read_access();
878  }
879 
880  vd_value_type result = 0;
881 
882  int ld = x0.d();
883  for(int i=0; i<ld; ++i)
884  {
885  result += x0.component(i) * x1.component(i);
886  }
887 
888  if(xauto_access)
889  {
890  x0.release_access();
891  x1.release_access();
892  }
893 
894  // Postconditions:
895 
896  ensure(unexecutable(\
897  "result == sum(i, 0, x0.d(), x0.component(i) * x1.component(i)"));
898 
899  // Exit:
900 
901  return result;
902 }
903 
906 length(const ed& x0, bool xauto_access)
907 {
908  // Preconditions:
909 
910  require(x0.state_is_auto_read_accessible(xauto_access));
911 
912  // Body:
913 
914  if(xauto_access)
915  {
916  x0.get_read_access();
917  }
918 
919  vd_value_type result = 0;
920 
921  int ld = x0.d();
922  for(int i=0; i<ld; ++i)
923  {
924  vd_value_type x = x0.component(i);
925  result += x * x;
926  }
927 
928  result = sqrt(result);
929 
930  if(xauto_access)
931  {
932  x0.release_access();
933  }
934 
935  // Postconditions:
936 
937  ensure(result >= 0.0);
938  ensure(unexecutable("result == sqrt(sum(i, 0, x0.d(), x0.component(i)**2)"));
939 
940  // Exit:
941 
942  return result;
943 }
944 
945 void
947 put_length(ed& x0, const vd_value_type& xlength, bool xauto_access)
948 {
949  // Preconditions:
950 
951  require(x0.state_is_auto_read_write_accessible(xauto_access));
952  ensure(xlength >= 0.0);
953 
954  // Body:
955 
956  if(xauto_access)
957  {
958  x0.get_read_write_access(true);
959  }
960 
963 
964  vd_value_type len = length(x0, false);
965 
966  vd_value_type lscale = (len != 0.0) ? (xlength / len) : 0.0;
967 
968  // We could call vd::scale_by here but this is more efficient.
969 
970  int ld = x0.d();
971  for(int i=0; i<ld; ++i)
972  {
973  x0.put_component(i, lscale*x0.component(i));
974  }
975 
976  if(xauto_access)
977  {
978  x0.release_access();
979  }
980 
981  // Postconditions:
982 
983  ensure(unexecutable("length(x0, xauto_access) == xlength"));
984 
985  // Exit:
986 
987  return;
988 }
989 
990 void
992 normalize(const ed& x0, ed& xresult, bool xauto_access)
993 {
994  // Preconditions:
995 
996  require(x0.state_is_auto_read_accessible(xauto_access));
997  require(xresult.state_is_auto_read_write_accessible(xauto_access));
998  require(x0.is_same_type(&xresult));
999  require(x0.is_p_form(xauto_access) == xresult.is_p_form(xauto_access));
1000 
1001  // Body:
1002 
1003  if(xauto_access)
1004  {
1005  x0.get_read_access();
1006  xresult.get_read_write_access(true);
1007  }
1008 
1011 
1012  vd_value_type len = length(x0, false);
1013 
1014  vd_value_type lscale = (len != 0.0) ? (1.0 / len) : 0.0;
1015 
1016  int ld = xresult.d();
1017  for(int i=0; i<ld; ++i)
1018  {
1019  xresult.put_component(i, lscale*x0.component(i));
1020  }
1021 
1022  if(x0.is_p_form(false))
1023  {
1024  xresult.put_is_p_form(false);
1025  }
1026  else
1027  {
1028  xresult.put_is_p_vector(false);
1029  }
1030 
1031  if(xauto_access)
1032  {
1033  x0.release_access();
1034  xresult.release_access();
1035  }
1036 
1037  // Postconditions:
1038 
1039  ensure(xresult.is_p_form(false) == x0.is_p_form(false));
1040  ensure(unexecutable("length(xresult, xauto_access) == 1.0"));
1041 
1042  // Exit:
1043 
1044  return;
1045 }
1046 
1049 dot(const ed_lite& x0, const ed_lite& x1)
1050 {
1051  // Preconditions:
1052 
1053  require(x0.d() == x1.d());
1054 
1055  // Body:
1056 
1057  vd_value_type result = 0;
1058 
1059  int ld = x0.d();
1060  for(int i=0; i<ld; ++i)
1061  {
1062  result += x0.component(i) * x1.component(i);
1063  }
1064 
1065  // Postconditions:
1066 
1067  ensure(unexecutable("result == sum(i, 0, x0.d(), x0.component(i)*x1.component(i)"));
1068 
1069  // Exit:
1070 
1071  return result;
1072 }
1073 
1076 length(const ed_lite& x0)
1077 {
1078  // Preconditions:
1079 
1080  // Body:
1081 
1082  vd_value_type result = 0;
1083 
1084  int ld = x0.d();
1085  for(int i=0; i<ld; ++i)
1086  {
1087  vd_value_type x = x0.component(i);
1088  result += x * x;
1089  }
1090 
1091  result = sqrt(result);
1092 
1093  // Postconditions:
1094 
1095  ensure(result >= 0.0);
1096  ensure(unexecutable("result == sqrt(sum(i, 0, x0.d(), x0.component(i)**2)"));
1097 
1098  // Exit:
1099 
1100  return result;
1101 }
1102 
1103 void
1105 put_length(ed_lite& x0, const vd_value_type& xlength)
1106 {
1107  // Preconditions:
1108 
1109  require(xlength >= 0.0);
1110 
1111  // Body:
1112 
1115 
1116  vd_value_type len = length(x0);
1117 
1118  vd_value_type lscale = (len != 0.0) ? (xlength / len) : 0.0;
1119 
1120  //$$SCRIBBLE: We could call vd_lite::scale_by here but this
1121  // is more efficient.
1122 
1123  int ld = x0.d();
1124  for(int i=0; i<ld; ++i)
1125  {
1126  x0.put_component(i, lscale*x0.component(i));
1127  }
1128 
1129  // Postconditions:
1130 
1131  ensure(unexecutable("length(x0) == xlength"));
1132 
1133  // Exit:
1134 
1135  return;
1136 }
1137 
1138 void
1140 normalize(const ed_lite& x0, ed_lite& xresult)
1141 {
1142  // Preconditions:
1143 
1144  require(x0.is_same_type(xresult));
1145 
1146  // Body:
1147 
1150 
1151  vd_value_type len = length(x0);
1152 
1153  vd_value_type lscale = (len != 0.0) ? (1.0 / len) : 0.0;
1154 
1155 
1156  int ld = xresult.d();
1157  for(int i=0; i<ld; ++i)
1158  {
1159  xresult.put_component(i, lscale*x0.component(i));
1160  }
1161 
1162  // Postconditions:
1163 
1164  ensure(unexecutable("length(xresult) == 1.0"));
1165 
1166  // Exit:
1167 
1168  return;
1169 }
1170 
SHEAF_DLL_SPEC void sqrt(const sec_at0 &x0, sec_at0 &xresult, bool xauto_access)
Compute sqrt of x0 (sqrt(x0)) (pre-allocated version).
Definition: sec_at0.cc:1556
virtual poset_path path(bool xauto_access=true) const
The path of this poset.
virtual const std::string & class_name() const
The name of this class.
Definition: ed.cc:721
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 ...
bool full() const
True if both poset name and member name are not empty.
Definition: poset_path.cc:311
void put_is_p_vector(bool xauto_access)
Sets is_p_vector to true; synonym for put_is_contravariant(xauto_access).
Definition: atp.cc:743
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: atp_space.cc:86
static void make_standard_schema(namespace_poset &xns)
Creates the standard schema for this class in namespace xns.
Definition: ed.cc:364
poset_path path(bool xauto_access=true) const
A path to this component.
bool is_same_type(const any_lite &xother) const
True if other is the same type as this.
Definition: any_lite.cc:142
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...
poset_path vector_space_path() const
The path of the underlying vector space.
Definition: tp_space.cc:365
A general antisymmetric tensor of degree 1 over an abstract vector space (volatile version)...
Definition: at1.h:44
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.
static const poset_path & standard_schema_path()
The path to the standard schema for this class.
Definition: ed.cc:346
ed_lite()
Default constructor.
Definition: ed.cc:46
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.
value_type component(int xindex) const
The xindex-th component.
Definition: vd.cc:209
virtual void get_read_access() const
Get read access to the state associated with this.
static const std::string & static_class_name()
The name of this class.
Definition: ed.cc:232
T::row_dofs_type & row_dofs(T &x0)
The row dofs pod type for x0 (mutable version).
virtual volatile_type * lite_type() const
Virtual conversion to the associated volatile type.
Definition: ed.cc:648
SHEAF_DLL_SPEC vd_value_type dot(const ed &x0, const ed &x1, bool xauto_access)
The Euclidean "dot" product of x0 with x1 (version for persistent types).
Definition: ed.cc:863
SHEAF_DLL_SPEC vd_value_type length(const ed &x0, bool xauto_access)
The Euclidean length (magnitude) of x0 (version for persistent types).
Definition: ed.cc:906
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...
ed()
Default constructor.
Definition: ed.cc:452
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
static const std::string & static_class_name()
The name of this class.
Definition: ed.cc:740
virtual schema_poset_member & schema()
The schema for this poset (mutable version).
SHEAF_DLL_SPEC void put_length(ed &x0, const vd_value_type &xlength, bool xauto_access)
Set the Euclidean length (magnitude) of x0 to xlength. (version for persistent types).
Definition: ed.cc:947
bool invariant() const
Class invariant.
Definition: ed.cc:303
Euclidean vector space of dimension d (volatile version).
Definition: ed.h:44
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...
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 std::string & class_name() const
The name of this class.
Definition: ed.cc:213
bool contains_path(const poset_path &xpath, bool xauto_access=true) const
True if this contains the poset or poset member specified by xpath.
bool is_p_form(bool xauto_access) const
True if this is a p-form; synonym for is_covariant(xauto_access).
Definition: atp.cc:677
virtual ed & operator=(const abstract_poset_member &xother)
Assignment operator; synonym for attach_to_state(&xother).
Definition: ed.cc:574
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 value_type component(int xindex) const
The value of the xi-th component.
Definition: vd.cc:1115
virtual ~ed_lite()
Destructor.
Definition: ed.cc:97
virtual int d() const
Dimension of this as a vector space.
Definition: atp.cc:161
bool empty() const
True if both poset name and member name are empty.
Definition: poset_path.cc:291
virtual bool is_ancestor_of(const any_lite &xother) const
Conformance test; true if other conforms to this.
Definition: ed.cc:284
bool invariant() const
Class invariant.
Definition: ed.cc:820
SHEAF_DLL_SPEC void normalize(const ed &x0, ed &xresult, bool xauto_access)
Normalize x0 (convert to a unit vector) (pre_allocated version for persistent types).
Definition: ed.cc:992
virtual ed * clone() const
Make a new handle, no state instance of current.
Definition: ed.cc:759
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 const volatile_type & lite_prototype() const
Virtual constructor for the associated volatile type.
Definition: ed.cc:630
poset_path scalar_space_path() const
The path of the underlying space of scalars.
Definition: vd_space.cc:250
virtual void get_read_write_access(bool xrelease_read_only_access=false)
Get read write access to the state associated with this. If release_read_only_access is requested...
void put_component(int xindex, value_type xcomp)
Set the xindex-th component to xcomp.
Definition: vd.cc:230
An abstract vector space viewed as an antisymmetric tensor space of degree 1.
Definition: at1_space.h:42
static host_type & new_host(namespace_type &xns, const poset_path &xhost_path, const poset_path &xschema_path, const poset_path &xscalar_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: ed.cc:393
Euclidean vector space of dimension d (peresistent version).
Definition: ed.h:210
static int factor_ct(int xd)
Factor_ct() as a function of dimension xd.
Definition: vd_space.cc:167
virtual ed_lite * clone() const
Virtual constructor, makes a new instance of the same type as this.
Definition: ed.cc:251
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
~ed()
Destructor.
Definition: ed.cc:617
int dd() const
The dimension of the underlying ("domain") vector space.
Definition: tp_space.cc:317
virtual int d() const
Dimension of this as a vector space.
Definition: vd.cc:1017
An abstract client handle for a member of a poset.
ed_lite & operator=(const ed_lite &xother)
Assignment operator.
Definition: ed.cc:78
virtual void put_component(int xindex, value_type xvalue)
Sets the value of the xindex-th component to xvalue.
Definition: vd.cc:1169
void put_is_p_form(bool xauto_access)
Sets is_p_form to true; synonym for put_is_covariant(xauto_access).
Definition: atp.cc:699
Namespace for the fiber_bundles component of the sheaf system.
bool is_same_type(const any *other) const
True if other is the same type as this.
Definition: any.cc:79
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
bool is_ancestor_of(const any *xother) const
True if other conforms to current.
Definition: ed.cc:794
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.
Definition: scoped_index.h:710