21 #include "SheafSystem/t3.h" 23 #include "SheafSystem/abstract_poset_member.impl.h" 24 #include "SheafSystem/assert_contract.h" 25 #include "SheafSystem/at1.h" 26 #include "SheafSystem/at1_space.h" 27 #include "SheafSystem/fiber_bundles_namespace.h" 28 #include "SheafSystem/schema_poset_member.h" 29 #include "SheafSystem/tp_space.h" 30 #include "SheafSystem/wsv_block.h" 147 vd_lite::operator=(xrow_dofs);
151 postcondition_of(vd_lite::operator=(xrow_dofs));
209 int result =
static_cast<int>(dd()*dd()*dd());
214 ensure(result == static_cast<int>(dd()*dd()*dd()));
227 require((0 <= xi) && (xi < dd()));
228 require((0 <= xj) && (xj < dd()));
229 require((0 <= xk) && (xk < dd()));
233 value_type result = component(index_for_ijk(xi, xj, xk));
250 require((0 <= xi) && (xi < dd()));
251 require((0 <= xj) && (xj < dd()));
252 require((0 <= xk) && (xk < dd()));
256 put_component(index_for_ijk(xi, xj, xk), xvalue);
274 require((0 <= xi) && (xi < dd()));
275 require((0 <= xj) && (xj < dd()));
276 require((0 <= xk) && (xk < dd()));
281 int result = (xi*ldd + xj)*ldd + xk;
286 ensure(result < d());
323 const string& result = static_class_name();
327 ensure(!result.empty());
342 static const string result(
"t3_lite");
346 ensure(!result.empty());
368 ensure(is_same_type(*result));
392 require(&xother != 0);
398 bool result =
dynamic_cast<const t3_lite*
>(&xother) != 0;
411 if(invariant_check())
415 disable_invariant_check();
419 invariance(tp_lite::invariant());
425 enable_invariant_check();
457 static const poset_path result(standard_schema_poset_name(),
"t3_schema");
479 standard_schema_path().member_name(),
480 tp::standard_schema_path(),
484 lschema.detach_from_state();
509 require(!xhost_path.
empty());
512 require(xschema_path.
full());
514 require(schema_poset_member::conforms_to(xns, xschema_path, standard_schema_path()));
519 require(host_type::d(xns, xschema_path, xauto_access) == host_type::d(xns, 3, xvector_space_path, xauto_access));
524 host_type::new_table(xns, xhost_path, xschema_path, 3, xvector_space_path, xauto_access);
528 ensure(xns.
owns(result, xauto_access));
529 ensure(result.
path(
true) == xhost_path);
531 ensure(result.
schema(
true).
path(xauto_access) == xschema_path);
533 ensure(result.
factor_ct(
true) == result.
d(
true));
534 ensure(result.
d(
true) == schema_poset_member::row_dof_ct(xns, xschema_path, xauto_access));
536 ensure(result.
p(
true) == 3);
584 attach_to_state(&xother);
602 require(is_ancestor_of(&xother));
603 require(precondition_of(attach_to_state(&xother)));
607 attach_to_state(&xother);
611 ensure(postcondition_of(attach_to_state(&xother)));
625 require(precondition_of(attach_to_state(&xother)));
629 attach_to_state(&xother);
633 ensure(postcondition_of(attach_to_state(&xother)));
698 require(precondition_of(new_jim_state(xhost, 0,
false, xauto_access)));
702 new_jim_state(xhost, 0,
false, xauto_access);
706 ensure(postcondition_of(new_jim_state(xhost, 0,
false, xauto_access)));
726 attach_to_state(xhost, xhub_id);
731 ensure(is_attached());
733 ensure(index() == xhub_id);
747 attach_to_state(xhost, xid.
hub_pod());
752 ensure(is_attached());
754 ensure(index() ==~ xid);
758 t3(
const poset* xhost,
const std::string& xname)
765 require(!xname.empty());
770 attach_to_state(xhost, xname);
775 ensure(is_attached());
777 ensure(name() == xname);
809 require(state_is_read_accessible());
810 require((0 <= xi) && (xi < dd()));
811 require((0 <= xj) && (xj < dd()));
812 require((0 <= xk) && (xk < dd()));
816 value_type result = component(index_for_ijk(xi, xj, xk));
829 component(
int xi,
int xj,
int xk,
bool xauto_access)
const 833 require(state_is_auto_read_accessible(xauto_access));
834 require((0 <= xi) && (xi < dd(xauto_access)));
835 require((0 <= xj) && (xj < dd(xauto_access)));
836 require((0 <= xk) && (xk < dd(xauto_access)));
845 value_type result = component(index_for_ijk(xi, xj, xk));
869 require(state_is_read_write_accessible());
870 require((0 <= xi) && (xi < dd()));
871 require((0 <= xj) && (xj < dd()));
872 require((0 <= xk) && (xk < dd()));
876 put_component(index_for_ijk(xi, xj, xk), xvalue);
893 require(state_is_auto_read_write_accessible(xauto_access));
894 require((0 <= xi) && (xi < dd()));
895 require((0 <= xj) && (xj < dd()));
896 require((0 <= xk) && (xk < dd()));
902 get_read_write_access(
true);
905 put_component(index_for_ijk(xi, xj, xk), xvalue);
927 require(state_is_read_write_accessible());
928 require((0 <= xi) && (xi < dd()));
929 require((0 <= xj) && (xj < dd()));
930 require((0 <= xk) && (xk < dd()));
935 int result = (xi*ldd + xj)*ldd + xk;
940 ensure(result < d());
977 const string& result = static_class_name();
981 ensure(!result.empty());
996 static const string result(
"t3");
1000 ensure(!result.empty());
1018 t3 *result =
new t3();
1022 ensure(result != 0);
1050 if(invariant_check())
1054 disable_invariant_check();
1058 invariance(tp::invariant());
1062 invariance(state_is_read_accessible() ? p() == 3 :
true);
1063 invariance(state_is_read_accessible() ? d() == dd()*dd()*dd() :
true);
1067 enable_invariant_check();
1081 require(xother != 0);
1087 bool result =
dynamic_cast<const t3*
>(xother) != 0;
1091 ensure(invariant());
1108 #include "SheafSystem/at1.h" 1109 #include "SheafSystem/at2.h" 1110 #include "SheafSystem/at3.h" 1111 #include "SheafSystem/st2.h" 1112 #include "SheafSystem/st3.h" 1113 #include "SheafSystem/t2.h" 1126 require(xp >= 0 && xp < x0.
p());
1127 require(xq >= 0 && xq < x0.
p());
1128 require(xresult.
p() == x0.
p() - 2);
1137 for(
int n=0; n<ldd; ++n)
1140 for(
int i=0; i<ldd; ++i)
1163 ensure(unexecutable(
"xresult is the contraction of x0 on indices xp and xq"));
1179 require(xp >= 0 && xp < x0.
p(xauto_access));
1180 require(xq >= 0 && xq < x0.
p(xauto_access));
1182 x0.is_contravariant(xq, xauto_access));
1195 int lsum_pq = xp+xq;
1197 for(
int n=0; n<ldd; ++n)
1200 for(
int i=0; i<ldd; ++i)
1207 else if(lsum_pq == 2)
1211 else if(lsum_pq == 3)
1233 ensure(unexecutable(
"xresult is the contraction of x0 on indices xp and xq"));
1247 require(x0.
dd() == xresult.
dd());
1253 for(
int i=0; i<ldd; ++i)
1255 for(
int j=0; j<ldd; ++j)
1257 for(
int k=0; k<ldd; ++k)
1274 ensure(unexecutable(
"xresult is equal to the antisymmetric part of x0"));
1287 require(x0.
dd() == xresult.
dd());
1293 for(
int i=0; i<ldd; ++i)
1295 for(
int j=0; j<ldd; ++j)
1297 for(
int k=0; k<ldd; ++k)
1314 ensure(unexecutable(
"xresult is equal to the antisymmetric part of x0"));
1329 require(x0.
dd(xauto_access) == xresult.
dd(xauto_access));
1342 for(
int i=0; i<ldd; ++i)
1344 for(
int j=0; j<ldd; ++j)
1346 for(
int k=0; k<ldd; ++k)
1374 ensure(unexecutable(
"xresult is equal to the antisymmetric part of x0"));
1387 require(x0.
dd() == xresult.
dd());
1393 for(
int i=0; i<ldd; ++i)
1395 for(
int j=0; j<ldd; ++j)
1397 for(
int k=0; k<ldd; ++k)
1413 ensure(unexecutable(
"xresult is equal to the symmetric part of x0"));
1426 require(x0.
dd() == xresult.
dd());
1432 for(
int i=0; i<ldd; ++i)
1434 for(
int j=0; j<ldd; ++j)
1436 for(
int k=0; k<ldd; ++k)
1452 ensure(unexecutable(
"xresult is equal to the symmetric part of x0"));
1467 require(x0.
dd(xauto_access) == xresult.
dd(xauto_access));
1480 for(
int i=0; i<ldd; ++i)
1482 for(
int j=0; j<ldd; ++j)
1484 for(
int k=0; k<ldd; ++k)
1512 ensure(unexecutable(
"xresult is equal to the antisymmetric part of x0"));
1525 require(x1.
dd() == x0.
dd());
1526 require(xresult.
dd() == x0.
dd());
1532 for(
int i=0; i<ldd; ++i)
1534 for(
int j=0; j<ldd; ++j)
1538 for(
int k=0; k<ldd; ++k)
1565 require(x1.
dd(xauto_access) == x0.
dd(xauto_access));
1566 require(xresult.
dd(xauto_access) == x0.
dd(xauto_access));
1579 for(
int i=0; i<ldd; ++i)
1581 for(
int j=0; j<ldd; ++j)
1585 for(
int k=0; k<ldd; ++k)
1609 ensure(xresult.
variance(xauto_access) == \
1623 require(x1.
dd() == x0.
dd());
1624 require(xresult.
dd() == x0.
dd());
1630 for(
int i=0; i<ldd; ++i)
1634 for(
int j=0; j<ldd; ++j)
1636 for(
int k=0; k<ldd; ++k)
1663 require(x1.
dd(xauto_access) == x0.
dd(xauto_access));
1664 require(xresult.
dd(xauto_access) == x0.
dd(xauto_access));
1677 for(
int i=0; i<ldd; ++i)
1681 for(
int j=0; j<ldd; ++j)
1683 for(
int k=0; k<ldd; ++k)
1707 ensure(xresult.
variance(xauto_access) == \
1726 require(x1.
dd() == x0.
dd());
1727 require(xresult.
dd() == x0.
dd());
1733 for(
int i=0; i<ldd; ++i)
1735 for(
int j=0; j<ldd; ++j)
1739 for(
int k=0; k<ldd; ++k)
1765 require(x1.
dd(xauto_access) == x0.
dd(xauto_access));
1766 require(xresult.
dd(xauto_access) == x0.
dd(xauto_access));
1779 for(
int i=0; i<ldd; ++i)
1781 for(
int j=0; j<ldd; ++j)
1785 for(
int k=0; k<ldd; ++k)
1809 ensure(xresult.
variance(xauto_access) == \
1824 require(x1.
dd() == x0.
dd());
1825 require(xresult.
dd() == x0.
dd());
1831 for(
int i=0; i<ldd; ++i)
1835 for(
int j=0; j<ldd; ++j)
1837 for(
int k=0; k<ldd; ++k)
1866 require(x1.
dd(xauto_access) == x0.
dd(xauto_access));
1867 require(xresult.
dd(xauto_access) == x0.
dd(xauto_access));
1880 for(
int i=0; i<ldd; ++i)
1884 for(
int j=0; j<ldd; ++j)
1886 for(
int k=0; k<ldd; ++k)
1910 ensure(xresult.
variance(xauto_access) == \
1929 require(x1.
dd() == x0.
dd());
1930 require(xresult.
dd() == x0.
dd());
1936 for(
int i=0; i<ldd; ++i)
1938 for(
int j=0; j<ldd; ++j)
1942 for(
int k=0; k<ldd; ++k)
1970 require(x1.
dd(xauto_access) == x0.
dd(xauto_access));
1971 require(xresult.
dd(xauto_access) == x0.
dd(xauto_access));
1984 for(
int i=0; i<ldd; ++i)
1986 for(
int j=0; j<ldd; ++j)
1990 for(
int k=0; k<ldd; ++k)
2013 ensure(xresult.
variance(xauto_access) == \
2028 require(x1.
dd() == x0.
dd());
2029 require(xresult.
dd() == x0.
dd());
2035 for(
int i=0; i<ldd; ++i)
2039 for(
int j=0; j<ldd; ++j)
2041 for(
int k=0; k<ldd; ++k)
2070 require(x1.
dd(xauto_access) == x0.
dd(xauto_access));
2071 require(xresult.
dd(xauto_access) == x0.
dd(xauto_access));
2072 require(xresult.
p(xauto_access) == x0.
p(xauto_access) + x1.
p(xauto_access));
2085 for(
int i=0; i<ldd; ++i)
2089 for(
int j=0; j<ldd; ++j)
2091 for(
int k=0; k<ldd; ++k)
2114 ensure(xresult.
variance(xauto_access) == \
A tensor of degree 3 over an abstract vector space (volatile version).
virtual int dd() const
Dimension of the underlying vector space.
virtual bool is_contravariant(bool xauto_access) const
True if and only if all tensor index positions are contravariant.
virtual int index_for_ijk(int xi, int xj, int xk) const
The index into linear storage of the component for specified indices xi, xj, xk.
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 ...
An antisymmetric rank 3 tensor over an abstract vector space (volatile version).
virtual const std::string & class_name() const
The name of this class.
SHEAF_DLL_SPEC void alt(const t2_lite &x0, at2_lite &xresult)
The alternating (antisymmetric) part of tensor x0 (pre-allocated version for volatile types)...
vd_value_type value_type
The type of component in the fiber; the scalar type in the fiber vector space.
virtual int dd() const
Dimension of the underlying vector space.
bool full() const
True if both poset name and member name are not empty.
void put_variance(const tensor_variance &xvariance, bool xauto_access)
Sets the variance to xvariance.
virtual int p() const
The degree of the tensors in host(); the sum of the contravariant and covariant degrees.
virtual bool is_ancestor_of(const any *other) const
Conformance test; true if other conforms to this.
virtual const std::string & class_name() const
The name of this class.
virtual int d() const
Dimension of this as a vector space.
static const std::string & static_class_name()
The name of this class.
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.
A general antisymmetric tensor of degree 1 over an abstract vector space (persistent version)...
The standard fiber bundles name space; extends the standard sheaves namespace by defining base space...
virtual volatile_type * lite_type() const
Virtual conversion to the associated volatile type.
A tensor of degree 3 over an abstract vector space (persistent version).
poset_path vector_space_path() const
The path of the underlying vector space.
virtual value_type component(int xi, int xj, int xk) const
The component with indices xi, xj, xk.
bool invariant() const
Class invariant.
A general antisymmetric tensor of degree 1 over an abstract vector space (volatile version)...
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...
SHEAF_DLL_SPEC void sym(const t2_lite &x0, st2_lite &xresult)
The symmetric part of tensor x0 (pre-allocated version for volatile types).
A path defined by a poset name and a member name separated by a forward slash ('/'). For example: "cell_definitions/triangle".
virtual bool invariant() const
Class invariant.
static const std::string & static_class_name()
The name of this class.
value_type component(int xrow, int xcolumn) const
The value of the component in a specified row and column.
value_type component(int xindex) const
The xindex-th component.
virtual void put_component(int xi, int xj, int xk, value_type xvalue)
Sets the component with indices xi, xj, xk to xvalue.
virtual value_type component(int xrow, int xcolumn) const
The value of the component in a specified row and column.
virtual void put_component(int xi, int xj, int xk, value_type xvalue)
Sets the component with indices xi, xj, xk to xvalue.
virtual void get_read_access() const
Get read access to the state associated with this.
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.
SHEAF_DLL_SPEC tensor_variance tensor_product(const tensor_variance &x0, const tensor_variance &x1)
The variance of the tensor product of tensors with variance x0 and x1.
T::row_dofs_type & row_dofs(T &x0)
The row dofs pod type for x0 (mutable version).
bool is_mixed() const
True if and only if there exists at least one index that is covariant and at least one that is contra...
A tensor of degree 2 over an abstract vector space (volatile version).
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.
Abstract base class with useful features for all objects.
A general symmetric tensor of degree 2 over an abstract vector space (volatile version).
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...
virtual int index_for_ijk(int xi, int xj, int xk) const
The index into linear storage of the component for specified indices xi, xj, xk.
virtual schema_poset_member & schema()
The schema for this poset (mutable version).
A client handle for a mutable partially ordered set.
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...
virtual void put_component(int xi, int xj, int xk, value_type xvalue)
Sets the component with indices xi, xj, xk to xvalue.
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.
An index within the external ("client") scope of a given id space.
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 void put_component(int xi, int xj, int xk, value_type xvalue)
Sets the component with indices xi, xj, xk to xvalue.
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.
A symmetric rank 3 tensor over an abstract vector space (persistent version).
virtual t3 & operator=(const abstract_poset_member &xother)
Assignment operator; synonym for attach_to_state(&xother).
virtual value_type component(int xindex) const
The value of the xi-th component.
virtual t3 * clone() const
Make a new handle, no state instance of current.
A symmetric rank 3 tensor over an abstract vector space. (volatile version).
An antisymmetric rank 3 tensor over an abstract vector space (volatile version).
virtual const volatile_type & lite_prototype() const
Virtual constructor for the associated volatile type.
bool empty() const
True if both poset name and member name are empty.
value_type component(int xrow, int xcolumn) const
The component with row index xrow and column index xcolumn.
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 p() const
The degree of the tensor; the sum of the contravariant and covariant degrees.
poset_path scalar_space_path() const
The path of the underlying space of scalars.
virtual void put_component(int xi, int xj, int xk, value_type xvalue)
Sets the component with indices xi, xj, xk to xvalue.
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.
An abstract vector space viewed as an antisymmetric tensor space of degree 1.
t3_lite()
Default constructor.
static int d(const namespace_poset &xns, const poset_path &xschema_path, bool xauto_access)
The tensor dimension implied by the schema specified by xschema_path.
static int factor_ct(int xd)
Factor_ct() as a function of dimension xd.
int_type pod_index_type
The plain old data index type.
vd_value_type value_type
The POD ("plain old data") type of scalar in the vector space of this.
int dd() const
The dimension of the underlying ("domain") vector space.
static const poset_path & standard_schema_path()
The path to the standard schema for this class.
virtual ~t3_lite()
Destructor.
virtual value_type component(int xi, int xj, int xk) const
The component with indices xi, xj, xk.
t3_lite & operator=(const t3_lite &xother)
Assignment operator.
virtual tensor_variance variance(bool xauto_access) const
The variance.
virtual void put_component(int xi, int xj, int xk, value_type xvalue)
Sets the component with indices xi, xj, xk to xvalue.
A general antisymmetric tensor of degree 2 over an abstract vector space (volatile version)...
virtual value_type component(int xrow, int xcolumn) const
The value of the component in a specified row and column.
An abstract client handle for a member of a poset.
static void make_standard_schema(namespace_poset &xns)
Creates the standard schema for this class in namespace xns.
value_type component(int xrow, int xcolumn) const
The component with row index xrow and column index xcolumn.
virtual void put_component(int xindex, value_type xvalue)
Sets the value of the xindex-th component to xvalue.
An abstract tensor space of degree p.
SHEAF_DLL_SPEC void tensor(const at1_lite &x0, const at1_lite &x1, t2_lite &xresult)
Tensor product (pre-allocated version for volatile types).
Namespace for the fiber_bundles component of the sheaf system.
A general symmetric tensor of degree 2 over an abstract vector space (persistent version).
value_type component(int xrow, int xcolumn) const
The component with row index xrow and column index xcolumn.
virtual t3_lite * clone() const
Virtual constructor, makes a new instance of the same type as this.
Row dofs type for class vd.
A general antisymmetric tensor of degree 2 over an abstract vector space.
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.
SHEAF_DLL_SPEC void contract(const t2_lite &x0, int xp, int xq, at0_lite &xresult)
Contraction on contravariant index xp and covariant index xq (pre-allocated version for volatime type...
A tensor of degree 2 over an abstract vector space (persistent version).
virtual int p() const
Degree of this as an antisymmetric tensor space.
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.
SHEAF_DLL_SPEC bool isunordered_or_equals(float x1, float x2)
True if isunordered(x1, x2) or x1 == x2.