9 MultiIndex::MultiIndex(
unsigned lengthIn) : length(lengthIn),
 
   14 MultiIndex::MultiIndex(
unsigned lengthIn, 
unsigned val) : MultiIndex(lengthIn)
 
   16   for(
int i=0; i<length; ++i){
 
   21 MultiIndex::MultiIndex(Eigen::RowVectorXi 
const& indIn) : MultiIndex(indIn.size())
 
   26   for(
int i=0; i<indIn.size(); ++i){
 
   29       maxValue = std::max<int>(maxValue, indIn[i]);
 
   30       totalOrder += indIn[i];
 
   35 MultiIndex::MultiIndex(std::initializer_list<unsigned> 
const& indIn) : MultiIndex(indIn.size())
 
   41   for(
auto it = indIn.begin(); it != indIn.end(); ++it){
 
   45       maxValue = std::max<int>(maxValue, *it);
 
   53 Eigen::RowVectorXi MultiIndex::GetVector()
 const 
   55   Eigen::RowVectorXi output = Eigen::RowVectorXi::Zero(length);
 
   57   for(
auto it = nzInds.begin(); it!=nzInds.end(); ++it)
 
   58     output(it->first) = it->second;
 
   63 bool MultiIndex::SetValue(
unsigned ind, 
unsigned val)
 
   66     throw std::out_of_range(
"Tried to set the value of index " + 
std::to_string(ind) + 
" on an multiindex with only " + 
std::to_string(length) + 
" components.");
 
   71       auto it = nzInds.find(ind);
 
   72       foundIndex = it!=nzInds.end();
 
   73       if(it != nzInds.end()){
 
   79       foundIndex = nzInds.erase(ind) > 0;
 
   87     for (
const auto& 
value : nzInds){
 
   88       totalOrder += 
value.second;
 
   89       maxValue = std::max(maxValue, 
value.second);
 
   96 unsigned int MultiIndex::NumNz()
 const 
   98     unsigned int numNz = 0;
 
   99     for(
auto& part : nzInds)
 
  100       numNz += int(part.second > 0);
 
  106 unsigned MultiIndex::MultiIndex::GetValue(
unsigned ind)
 const 
  109     throw std::out_of_range(
"Tried to access index " + 
std::to_string(ind) + 
" of a multiindex with only " + 
std::to_string(length) + 
" components.");
 
  111     auto searchIter = nzInds.find(ind);
 
  112     if(searchIter != nzInds.end()){
 
  113       return searchIter->second;
 
  121 void MultiIndex::SetLength(
unsigned newLength)
 
  123   if(newLength > length){
 
  127     auto it = nzInds.begin();
 
  128     while(it!= nzInds.end()){
 
  129       if (it->first >= newLength) {
 
  130           it = nzInds.erase(it);
 
  140     for(
auto it = nzInds.begin(); it!=nzInds.end(); ++it){
 
  141       maxValue = std::max(maxValue, it->second);
 
  142       totalOrder += it->second;
 
  148 bool MultiIndex::operator!=(
const MultiIndex &b)
 const{
 
  150   if( (b.length != length) || (b.maxValue != maxValue) || (b.totalOrder != totalOrder))
 
  153   if(b.nzInds.size() != nzInds.size())
 
  157   auto bit = b.nzInds.begin();
 
  158   auto it = nzInds.begin();
 
  159   for(; it!=nzInds.end(); ++it){
 
  160     if(it->first != bit->first)
 
  162     if(it->second != bit->second)
 
  170 bool MultiIndex::operator==(
const MultiIndex &b)
 const{
 
  171   return !( *
this != b);
 
  174 bool MultiIndex::operator>(
const MultiIndex &b)
 const{
 
  180   if(totalOrder<b.totalOrder){
 
  182   }
else if(totalOrder>b.totalOrder){
 
  184   }
else if(maxValue<b.maxValue){
 
  186   }
else if(maxValue>b.maxValue){
 
  190     for(
int i=0; i<std::min<unsigned>(length, b.length); ++i){
 
  191       if(GetValue(i)<b.GetValue(i)){
 
  193       }
else if(GetValue(i)>b.GetValue(i)){
 
  204 bool MultiIndex::operator>=(
const MultiIndex &b)
 const{
 
  208 bool MultiIndex::operator<=(
const MultiIndex &b)
 const{
 
  213   for(
int i=0; i<length; ++i){
 
  214     SetValue(i, GetValue(i) + b.GetValue(i));
 
  219 MultiIndex& MultiIndex::operator++() {
 
  220   MultiIndex ones (this->GetLength(), 1);
 
  221   return (*
this)+=ones;
 
  225   MultiIndex ret(*
this);
 
  229 MultiIndex& MultiIndex::operator-=(
const MultiIndex &b) {
 
  230   for(
int i=0; i<length; ++i){
 
  232     if (GetValue(i) > b.GetValue(i)) 
 
  233       diff = GetValue(i) - b.GetValue(i);
 
  239 MultiIndex& MultiIndex::operator--() {
 
  240   MultiIndex ones (this->GetLength(), 1);
 
  241   return (*
this)-=ones;
 
  244 MultiIndex MultiIndex::operator-(
const MultiIndex &b)
 const{
 
  245   MultiIndex ret(*
this);
 
  249 std::string MultiIndex::ToString()
 const {
 
  251   for(
int i=0; i<GetLength(); ++i){
 
  259 std::ostream& muq::Utilities::operator<< (std::ostream &out, 
const MultiIndex &ind)
 
  261   out << ind.GetVector().transpose();
 
SumMean operator+(MeanType1 const &mu1, MeanType2 const &mu2)
 
std::shared_ptr< MultiIndexSet > operator+=(std::shared_ptr< MultiIndexSet > x, std::shared_ptr< MultiIndexSet > y)
 
bool operator<(const value_t lhs, const value_t rhs) noexcept
comparison operator for JSON types
 
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values