18 #ifndef TERNARY_INDEX_SPACE_H 19 #define TERNARY_INDEX_SPACE_H 21 #ifndef SHEAF_DLL_SPEC_H 22 #include "SheafSystem/sheaf_dll_spec.h" 25 #ifndef TERNARY_INDEX_H 26 #include "SheafSystem/ternary_index.h" 29 #ifndef RAGGED_ARRAY_H 30 #include "SheafSystem/ragged_array.h" 36 using namespace sheaf;
69 invariance(i_size >= 0);
70 invariance(j_size >= 0);
71 invariance(k_size >= 0);
72 invariance(size == i_size*j_size*k_size);
107 require(xi_size >= 0);
108 require(xj_size >= 0);
109 require(xk_size >= 0);
113 put_bounds(xi_size, xj_size, xk_size);
118 ensure(i_size == xi_size);
119 ensure(j_size == xj_size);
120 ensure(k_size == xk_size);
130 void put_bounds(unary_index xi_size, unary_index xj_size, unary_index xk_size)
139 size = i_size*j_size*k_size;
144 ensure(i_size == xi_size);
145 ensure(j_size == xj_size);
146 ensure(k_size == xk_size);
162 put_bounds(xl, xl, xl);
167 ensure(i_size == xl);
168 ensure(j_size == xl);
169 ensure(k_size == xl);
236 ((0 <= xindex.
i) && (xindex.
i < i_size) &&
237 (0 <= xindex.
j) && (xindex.
j < j_size) &&
238 (0 <= xindex.
k) && (xindex.
k < k_size));
243 ((0 <= xindex.
i) && (xindex.
i < i_size) &&
244 (0 <= xindex.
j) && (xindex.
j < j_size) &&
245 (0 <= xindex.
k) && (xindex.
k < k_size)));
261 bool result = ((0 <= xindex) && (xindex < size));
265 ensure( result == ((0 <= xindex) && (xindex < size)));
281 unary_index result = xindex.
k + k_size*(xindex.
j + j_size*xindex.
i);
285 ensure(result == (xindex.
i*j_size*k_size + xindex.
j*k_size + xindex.
k));
301 unary_index result = xk + k_size*(xj + j_size*xi);
305 ensure(result == (xi*j_size*k_size + xj*k_size + xk));
319 require((0 <= xindex) && (xindex < size));
327 ternary_index result(xindex/(k_size*j_size), (xindex/k_size)%j_size, xindex%k_size);
331 ensure(to_row_major_offset(result) == xindex );
347 unary_index result = xindex.
i + i_size*(xindex.
j + j_size*xindex.
k);
351 ensure(result == (xindex.
i + i_size*xindex.
j + i_size*j_size*xindex.
k));
367 unary_index result = xi + i_size*(xj + j_size*xk);
371 ensure(result == (xi + i_size*xj + i_size*j_size*xk));
385 require((0 <= xindex) && (xindex < size));
393 ternary_index result(xindex%i_size, (xindex/i_size)%j_size, xindex/(i_size*j_size));
397 ensure(to_row_major_offset(result) == xindex);
416 #ifndef DOXYGEN_1_5_4_SKIP_UNKNOWN 423 #endif // ifndef DOXYGEN_1_5_4_SKIP_UNKNOWN 427 #endif // ifndef TERNARY_INDEX_SPACE_H A triple of indices (i,j, k).
unary_index to_row_major_offset(const unary_index xi, const unary_index xj, const unary_index xk) const
Converts (xi, xj, xk) to a unary_index using row-major ordering.
unary_index to_row_major_offset(const ternary_index &xindex) const
Converts xindex to a unary_index using row-major ordering.
ternary_index_space(unary_index xi_size, unary_index xj_size, unary_index xk_size)
Creates an instance with bound (xi_size, xj_size, xk_size).
ternary_index_space operator+(const ternary_index_space &xother) const
Sum.
unary_index j
The second index.
void put_bounds(unary_index xi_size, unary_index xj_size, unary_index xk_size)
Sets i_size = xi_size, j_size = xj_size, k_size = xk_size and recomputes size.
unary_index i
The first index.
ternary_index_space()
Creates an instance with bound (0,0,0).
ternary_index_space(unary_index xl)
Conversion from unary_index; interpreted as cube.
bool invariant() const
Class invariant.
ternary_index_space operator*(const ternary_index_space &xother) const
Cartesian product.
A bounded domain for ternary_index objects.
bool contains(const ternary_index &xindex) const
True if xindex is in this space.
unary_index size
Number in the space.
Namespace for the sheaves component of the sheaf system.
unary_index k
The third index.
unary_index j_size
Upper bound for the second index.
unary_index k_size
Upper bound for the third index.
unary_index to_col_major_offset(const ternary_index &xindex) const
Converts xindex to a unary_index using col-major ordering.
A two index array with variable length rows.
ternary_index from_row_major_offset(const unary_index &xindex) const
Converts xindex to a ternary_index using row-major ordering.
Namespace for the fiber_bundles component of the sheaf system.
unary_index to_col_major_offset(const unary_index xi, const unary_index xj, const unary_index xk) const
Converts xindex to a unary_index using col-major ordering.
unary_index i_size
Upper bound for the first index.
ternary_index from_col_major_offset(const unary_index &xindex) const
Converts xindex to a ternary_index using col-major ordering.
bool contains(const unary_index &xindex) const
True if xindex is in this space.
SHEAF_DLL_SPEC std::ostream & operator<<(std::ostream &os, const binary_index &xbi)
Insert binary_index& xbi into ostream& os.