TMB Documentation  v1.9.11
Public Member Functions | List of all members
TMBad::multivariate_index Struct Reference

Utilility class for sequential_reduction. More...

#include <graph_transform.hpp>

Public Member Functions

size_t count ()
 Number of elements indexed by this multivariate_index More...
 
void flip ()
 Flip the mask of active dimensions.
 
size_t index (size_t i)
 Get given component of this multivariate_index
 
std::vector< size_t > index ()
 Get multivariate_index as a vector.
 
std::vector< bool >::reference mask (size_t i)
 Get / set active dimensions of this multivariate_index
 
 multivariate_index (size_t bound_, size_t dim, bool flag=true)
 CTOR of multivariate_index representing {0,..,B-1}^D More...
 
 multivariate_index (std::vector< size_t > bound, bool flag=true)
 CTOR of multivariate_index representing the product set Prod_i {0,..,B[i]-1} More...
 
 operator size_t ()
 Get univariate pointer.
 
multivariate_indexoperator++ ()
 Advance to next element of this sub slice.
 
void set_mask (const std::vector< bool > &mask)
 Set all active dimensions of this multivariate_index
 

Detailed Description

Utilility class for sequential_reduction.

Helps looping through a multivariate index along any possible sub slice.

Example: Loop through {0,1}^5 with middle index (2) slowest running and remaining indices (0,1,3,4) fastest running.

#include <TMBad.hpp> using
namespace TMBad; int main() { multivariate_index x(2, 5, false); x.mask(2) =
true; for (int j=0; j<x.count(); ++j, ++x) { x.flip(); for (int i=0;
i<x.count(); ++i, ++x) { Rcout << x.index() << " pointer=" << x << "\n";
}
x.flip();
}
}

Definition at line 435 of file graph_transform.hpp.

Constructor & Destructor Documentation

§ multivariate_index() [1/2]

TMBad::multivariate_index::multivariate_index ( size_t  bound_,
size_t  dim,
bool  flag = true 
)

CTOR of multivariate_index representing {0,..,B-1}^D

Parameters
boundB
dimD
flagFill mask of active dimensions with this value

Definition at line 3709 of file TMBad.cpp.

§ multivariate_index() [2/2]

TMBad::multivariate_index::multivariate_index ( std::vector< size_t >  bound,
bool  flag = true 
)

CTOR of multivariate_index representing the product set Prod_i {0,..,B[i]-1}

Parameters
Boundvector B containing the number of indices for each dimension
flagFill mask of active dimensions with this value

Definition at line 3716 of file TMBad.cpp.

Member Function Documentation

§ count()

size_t TMBad::multivariate_index::count ( )

Number of elements indexed by this multivariate_index

Note
It is generally recommended to avoid re-calculating the count inside a loop such as for(i=0; i<x.count(); i++, ++x).

Definition at line 3702 of file TMBad.cpp.

Referenced by TMBad::clique::get_stride(), and TMBad::sequential_reduction::tabulate().


The documentation for this struct was generated from the following files:
License: GPL v2