diff --git a/src/MultiIndices/MultiIndexSet.cpp b/src/MultiIndices/MultiIndexSet.cpp index 4f6419ce..7653ba23 100644 --- a/src/MultiIndices/MultiIndexSet.cpp +++ b/src/MultiIndices/MultiIndexSet.cpp @@ -400,7 +400,8 @@ void MultiIndexSet::AddForwardNeighbors(unsigned int globalIndex, bool addInacti void MultiIndexSet::Visualize(std::ostream &out) const -{ +{ + unsigned int max_ord = maxOrders.at(1) + 1; for(unsigned int order = 0; order <= maxOrders.at(1) + 1; order++) { unsigned int i=max_ord - order; @@ -421,8 +422,10 @@ void MultiIndexSet::Visualize(std::ostream &out) const } if(!found){ + bool found2 = false; for(auto& multi : allMultis){ if((multi.Get(0)==j)&&(multi.Get(1)==i)){ + found2 = true; if(IsAdmissible(multi)){ out << "r "; }else{ @@ -430,6 +433,9 @@ void MultiIndexSet::Visualize(std::ostream &out) const } } } + + if(!found2) + out << " "; } } out << std::endl; diff --git a/tests/MultiIndices/Test_MultiIndexSet.cpp b/tests/MultiIndices/Test_MultiIndexSet.cpp index e7c6e2d9..ece59a79 100644 --- a/tests/MultiIndices/Test_MultiIndexSet.cpp +++ b/tests/MultiIndices/Test_MultiIndexSet.cpp @@ -433,4 +433,49 @@ TEST_CASE("Testing the MultiIndexSet class", "[MultiIndexSet]" ) { REQUIRE( set.at(inds.at(2)) == MultiIndex{3,0} ); } +} + + +TEST_CASE("MultiIndexSet Visualization Test", "[MultiIndexSet_Viz]") +{ + SECTION("Floating"){ + Eigen::MatrixXi multis(1,2); + multis << 3,3; + MultiIndexSet mset = MultiIndexSet(multis); + + std::stringstream sstream; + mset.Visualize(sstream); + + std::stringstream expected; + expected << " 4 | m \n" + << " 3 | m a m \n" + << " 2 | m \n" + << " 1 | \n" + << " 0 | \n" + << " ----------------\n" + << " 0 1 2 3 4 \n"; + + CHECK(expected.str() == sstream.str()); + } + + SECTION("Fixed"){ + Eigen::MatrixXi multis(2,2); + multis << 1,3, + 3,3; + MultiIndexSet mset = MultiIndexSet(multis); + + std::stringstream sstream; + mset.Visualize(sstream); + + std::stringstream expected; + expected <<" 4 | m m \n" + << " 3 | m a m a m \n" + << " 2 | m m \n" + << " 1 | \n" + << " 0 | \n" + << " ----------------\n" + << " 0 1 2 3 4 \n"; + + CHECK(expected.str() == sstream.str()); + } } \ No newline at end of file