14 #include "tbci/vector.h"
17 #if !defined(NO_GD) && !defined(AUTO_DECL)
18 # include "index_gd.h"
23 #ifndef TBCI_DISABLE_EXCEPT
28 :
NumErr(
"Error in Index class") {}
40 #if defined(PRAGMA_I) && defined (PRAGMA_I_IDX) && ! defined(_NO_IDX_PRAGMA)
41 # pragma interface "index.h"
56 Index (
const unsigned value,
const unsigned dim) :
Vector<unsigned> (value, dim) {}
65 for (
unsigned i = 0;
i < (unsigned)va; ++
i)
66 (*
this) (
i) = va_arg (vl,
unsigned);
75 for (
unsigned i = 0;
i < (unsigned)va; ++
i)
76 (*
this) (
i) = va_arg (vl,
unsigned);
90 for (
unsigned r = dim-1; r; r--)
91 if ((*
this)(r) >=
max(r)) { (*this)(r-1)++; (*this)(r) = 0; }
98 for (
unsigned r = dim-1; r; r--)
99 if ((
signed)(*this)(r) < 0) { (*this)(r-1)--; (*this)(r) =
max(r); }
109 const unsigned,
const unsigned)
const;
134 ix.
set (what, where);
136 for (
unsigned j = 0; j <
size(); j++)
139 ix.
set ((*
this)(j), i++);
151 const unsigned where2,
const unsigned what2)
const
156 ix.
set (what1, where1); ix.
set (what2, where2);
158 for (
unsigned j = 0; j <
size(); j++)
160 while (i == where1 || i == where2) i++;
161 ix.
set ((*
this)(j), i++);
169 const unsigned where2,
const unsigned what2)
170 {
return idx.
idx_fill_in2 (where1, what1, where2, what2); }
179 for (
unsigned j = 0; j <
size(); j++)
180 if (which != j) ix.
set ((*
this)(j), i++);
194 BCHK (which1 >=
size(),
IdxErr, Tried to
remove non-existing index1, which1, *
this);
195 BCHK (which2 >=
size(),
IdxErr, Tried to
remove non-existing index2, which2, *
this);
198 for (
unsigned j = 0; j <
size(); j++)
199 if (which1 != j && which2 != j) ix.
set ((*
this)(j), i++);
213 ix.
set (what, which);
220 {
return idx.
idx_set1 (which, what); }
TVector< unsigned > idx_remove1(const Index &idx, const unsigned which)
TVector< unsigned > idx_remove1(const unsigned) const
TVector< unsigned > idx_remove2(const unsigned, const unsigned) const
exception base class for the TBCI NumLib
#define BCHK(cond, exc, txt, ind, rtval)
Index prev_idx(const Index &max)
TVector< unsigned > idx_remove2(const Index &idx, const unsigned which1, const unsigned which2)
T & set(const T &val, const unsigned long i) const
Index(const unsigned value, const unsigned dim)
TVector< unsigned > idx_set1(const Index &idx, const unsigned which, const unsigned what)
Index(const Vector< unsigned > &vec)
Note that this #pragma interface might create problems as the class index is not templated! ...
long int Vector< T > & index
TVector< unsigned > idx_fill_in2(const unsigned, const unsigned, const unsigned, const unsigned) const
Index next_idx(const Index &max)
void lin_read(vararg va,...)
TVector< unsigned > idx_set1(const unsigned, const unsigned) const
unsigned long size() const
Index(const TVector< unsigned > &tv)
Temporary Base Class Idiom: Class TVector is used for temporary variables.
IdxErr(const char *t, const long i=0)
const unsigned TMatrix< T > const Matrix< T > * a
Index(const unsigned dim)
TVector< unsigned > idx_fill_in2(const Index &idx, const unsigned where1, const unsigned what1, const unsigned where2, const unsigned what2)
TVector< unsigned > idx_fill_in1(const Index &idx, const unsigned where, const unsigned what)
TVector< unsigned > idx_fill_in1(const unsigned, const unsigned) const