21 #include "SheafSystem/tensor_variance.h" 22 #include "SheafSystem/assert_contract.h" 23 #include "SheafSystem/std_iostream.h" 73 require((0 <= xp) && (xp < capacity()));
82 ensure_for_all(i, 0, xp, is_contravariant(i));
116 _variance = xother._variance;
120 ensure((*
this) == xother);
136 bool result = (_p == xother._p) && (_variance == xother._variance);
150 return numeric_limits<unsigned long int>::digits;
168 require((0 <= xi) && (xi < p()));
172 result = _variance[xi];
188 require((0 <= xi) && (xi < p()));
192 _variance[xi] = xvalue;
196 ensure(variance(xi) == xvalue);
211 for(
int i=0; i< _p; ++i)
213 _variance[i] = xvalue;
219 ensure_for_all(i, 0, p(), variance(i) == xvalue);
234 require((0 <= xi) && (xi < p()));
238 result = _variance[xi];
242 ensure(result == variance(xi));
257 bool result = (_p == 0) || (_variance.count() == _p);
275 require((0 <= xi) && (xi < p()));
279 result = !_variance[xi];
283 ensure(result == !variance(xi));
300 result = (_p == 0) || (_variance.count() == 0);
326 size_t lct = _variance.count();
327 result = ((0 < lct) && (lct < _p));
353 for(
int i=1; i< _p; ++i)
355 _variance[i] = _variance[0];
362 ensure_for_all(i, 0, p(), variance(i) == variance(0));
385 require((0 <= xp) && (xp < x0.
p()));
386 require((0 <= xq) && (xq < x0.
p()));
395 for(
int j=0; j<p; ++j)
397 if((j!=xp) && (j!=xq))
405 ensure(result.
p() == x0.
p() - 2);
428 for(
int i=0; i<p0; ++i)
433 for(
int i=0; i<p1; ++i)
440 ensure(result.
p() == x0.
p() + x1.
p());
456 require(x0.
p() >= 1);
468 ensure(result.
p() == x0.
p() - 1);
486 require(x0.
p() <= xdd);
498 ensure(result.
p() == xdd - x0.
p());
530 ensure(result.
p() == x0.
p() + x1.
p());
545 require((0 <= xi) && (xi < x0.
p()));
555 ensure(result.
p() == x0.
p());
570 require((0 <= xi) && (xi < x0.
p()));
580 ensure(result.
p() == x0.
p());
SHEAF_DLL_SPEC tensor_variance lower(const tensor_variance &x0, int xi)
The variance of the lower of a tensor with variance x0 on index xi.
bool is_pure() const
True if and only if all indices are covariant or all indices are contravariant.
bool is_contravariant() const
True if and only if all indices are contravariant.
~tensor_variance()
Destructor; not virtual, this can not be a base class.
bool operator==(const tensor_variance &xother) const
Equality comparison operator.
int p() const
The tensor degree.
The "type" of a tensor; specifies the degree and the co- or contra-variance for each index of a tenso...
void put_variance(int xi, bool xvalue)
Sets the variance of the xi-th index to xvalue.
tensor_variance & operator=(const tensor_variance &xother)
Assignment operator.
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.
static int capacity()
The largest value of p this implementation will support.
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...
SHEAF_DLL_SPEC tensor_variance raise(const tensor_variance &x0, int xi)
The variance of the raise of a tensor with variance x0 on index xi.
SHEAF_DLL_SPEC tensor_variance hook(const tensor_variance &x0)
The variance of the hook of a tensor with variance x0.
bool is_contravariant(int xi) const
True if and only if the xi-th index is covariant; synonym for !variance(xi).
SHEAF_DLL_SPEC tensor_variance contract(const tensor_variance &x0, int xp, int xq)
The variance of the contration of a tensor with variance x0 on indices xp and xq. ...
tensor_variance()
Default constructor.
bool variance(int xi) const
The variance of the xi-th index; covariant if true, contravariant if false.
void purify()
Sets all indices the same as index 0.
SHEAF_DLL_SPEC tensor_variance wedge(const tensor_variance &x0, const tensor_variance &x1)
The variance of the wedge of a tensor with variance x0 with a tnesor with variance x1...
SHEAF_DLL_SPEC tensor_variance star(const tensor_variance &x0, int xdd)
The variance of the Hodge star of a tensor with variance x0 over a vector space of dimension xdd...
bool is_covariant(int xi) const
True if and only if the xi-th index is covariant; synonym for variance(xi).
Namespace for the fiber_bundles component of the sheaf system.
bool is_covariant() const
True if and only if all indices are covariant.