void printArray(const ARRAY& a, std::string indent="") { std::ostringstream out(std::ostringstream::out); StringStyle style = MatrixStyle; typedef int coordinate_type; typedef typename ARRAY::const_iterator const_iterator; if(style == MatrixStyle) { if(a.actual_dimension == 0) { // scalar out << "A = " << a(0) << std::endl; } else if(a.actual_dimension == 1) { // vector out << "A = ("; for(size_t j=0; j<a.size(); ++j) { out << a(j) << ", "; } out << "\b\b)" << std::endl; } else if(a.actual_dimension == 2) { // matrix if(true /* coordinateOrder_ == FirstMajorOrder */) { out << "A(r,c) =" << std::endl; for(size_t y=0; y<a.shape(0); ++y) { for(size_t x=0; x<a.shape(1); ++x) { out << a(y, x) << ' '; } out << std::endl; } } else { out << "A(c,r) =" << std::endl; for(size_t y=0; y<a.shape(1); ++y) { for(size_t x=0; x<a.shape(0); ++x) { out << a(x, y) << ' '; } out << std::endl; } } } else { // higher dimensional typename ARRAY::difference_type c1; unsigned short q = 2; if(true /* coordinateOrder_ == FirstMajorOrder */) { q = a.actual_dimension-3; } int i = 0; for(const_iterator it = a.begin(); it != a.end(); ++it, ++i) { typename ARRAY::difference_type c2 = a.scanOrderIndexToCoordinate(i); if(i == 0 || c2[q] != c1[q]) { if(i != 0) { out << std::endl << std::endl; } if(true /* coordinateOrder_ == FirstMajorOrder */) { out << "A("; for(size_t j=0; j<static_cast<size_t>(a.actual_dimension-2); ++j) { out << c2[j] << ","; } } else { out << "A(c,r,"; for(size_t j=2; j<a.actual_dimension; ++j) { out << c2[j] << ","; } } out << '\b'; if(true /* coordinateOrder_ == FirstMajorOrder */) { out << ",r,c"; } out << ") =" << std::endl; } else if(c2[1] != c1[1]) { out << std::endl; } out << *it << " "; c1 = c2; } out << std::endl; } out << std::endl; } else if(style == TableStyle) { if(a.actual_dimension == 0) { // scalar out << "A = " << a(0) << std::endl; } else { // non-scalar int j = 0; for(const_iterator it = a.begin(); it != a.end(); ++it, ++j) { out << "A("; typename ARRAY::difference_type c = a.scanOrderIndexToCoordinate(j); for(size_t j=0; j<c.size(); ++j) { out << c[j] << ','; } out << "\b) = " << *it << std::endl; } } out << std::endl; } std::cout << out.str() << std::endl; }
int getElementCount(void){ return center.size(); }