//Purpose: // Show affect of storage order. // #define INDENT_OUTPUT #ifdef INDENT_OUTPUT #include #endif #include #include #include template < typename T > std::ostream& operator<< ( std::ostream& sout , std::vector const& a_container ) { sout<<"{ "; unsigned const size=a_container.size(); for(unsigned i=0; i bool mono_tonic_print ( Permut const& a_permut , Strides const& a_strides ) { std::cout<<":monotonically increasing={ "; unsigned const n=a_permut.size(); bool ok=true; for(unsigned i=0; i Permut invert_permut ( Permut const& a_permut ) { unsigned const n=a_permut.size(); Permut result(n); for( unsigned i=0; i std::vector extents2lengths ( boost::detail::multi_array::extent_gen const& a_extents ) { unsigned const n=a_extents.ranges_.size(); std::vector result(n); for( unsigned i=0; i std::vector expected_strides ( Permut const& a_permut , std::vector const& a_lengths ) { unsigned const n=a_permut.size(); std::vector strides(n); #define NO_INVERT_PERMUT #ifdef NO_INVERT_PERMUT Permut permut_i=a_permut; #else Permut permut_i=invert_permut(a_permut); #endif strides[permut_i[0]]=1; for( unsigned i=1; i array_t; void strides_print( array_t const& a_array) { std::cout<<"strides()={ "; for(unsigned i=0; i axes_permutation_t; axes_permutation_t mk_permut( unsigned rank) { axes_permutation_t result(rank); std::iota( result.begin(), result.end(), 0); return result; } template < std::size_t NumDims > bool operator== ( axes_permutation_t const& a_permut , boost::general_storage_orderconst& a_so ) { unsigned const n=a_permut.size(); bool result=n==NumDims; for( unsigned i=0; result && i indent_outbuf(std::cout,2); #endif std::vector const directions(rank,true); auto const extents=array_t::extent_gen()[2][3][4]; auto const lengths=extents2lengths(extents); std::cout<<":lengths="< is; #endif std::cout<<":permut_v="< store_order ( permut_v.begin() , directions.begin() ); array_t ma ( extents , store_order ); std::cout<<":ma.ordering(*)==permut_v="<<(permut_v==ma.storage_order())<<"\n"; std::cout<<":multi_array_strides:"; { #ifdef INDENT_OUTPUT ::boost::indent_scope<> is; #endif strides_print(ma); bool ok=mono_tonic_print( permut_v, ma.strides()); std::cout<<":is_mono_tonic="< is; #endif auto const strides_e=expected_strides( permut_v, lengths); std::cout<