75 #ifndef SLIP_BLOCK3D_HPP
76 #define SLIP_BLOCK3D_HPP
86 #include <boost/serialization/access.hpp>
87 #include <boost/serialization/split_member.hpp>
88 #include <boost/serialization/string.hpp>
89 #include <boost/serialization/complex.hpp>
90 #include <boost/serialization/version.hpp>
95 template <
typename T, std::
size_t NP, std::
size_t NR, std::
size_t NC>
98 template <
typename T, std::
size_t NP, std::
size_t NR, std::
size_t NC>
99 std::ostream& operator<<(std::ostream & out,const slip::block3d<T,NP,NR,NC>& b);
101 template <
typename T, std::
size_t NP, std::
size_t NR, std::
size_t NC>
104 template <
typename T, std::
size_t NP, std::
size_t NR, std::
size_t NC>
107 template <
typename T, std::
size_t NP, std::
size_t NR, std::
size_t NC>
110 template <
typename T, std::
size_t NP, std::
size_t NR, std::
size_t NC>
113 template <
typename T, std::
size_t NP, std::
size_t NR, std::
size_t NC>
116 template <
typename T, std::
size_t NP, std::
size_t NR, std::
size_t NC>
138 template <
typename T, std::
size_t NP, std::
size_t NR, std::
size_t NC>
160 static const std::size_t
SIZE = NP * NR * NC;
161 static const std::size_t
DIM = 3;
180 void fill(
const T& val);
186 void fill(
const T* val);
283 const std::size_t j);
295 const std::size_t j)
const;
311 const std::size_t k);
326 const std::size_t k)
const;
335 std::string
name()
const {
return "block3d";}
340 static std::size_t
dim1() {
return NP;}
342 static std::size_t
dim2() {
return NR;}
344 static std::size_t
dim3() {
return NC;}
366 template<
class Archive>
367 void save(Archive & ar,
const unsigned int version)
const
371 template<
class Archive>
372 void load(Archive & ar,
const unsigned int version)
377 BOOST_SERIALIZATION_SPLIT_MEMBER()
383 template<
typename T,std::
size_t NP, std::
size_t NR, std::
size_t NC>
387 return data[0].begin();
390 template<
typename T,std::
size_t NP, std::
size_t NR, std::
size_t NC>
394 return data[NP-1].end();
397 template<
typename T,std::
size_t NP, std::
size_t NR, std::
size_t NC>
401 return data[0].begin();
404 template<
typename T,std::
size_t NP, std::
size_t NR, std::
size_t NC>
408 return data[NP-1].end();
412 template<
typename T,std::
size_t NP, std::
size_t NR, std::
size_t NC>
416 return std::reverse_iterator<T*>(end());
419 template<
typename T,std::
size_t NP, std::
size_t NR, std::
size_t NC>
423 return std::reverse_iterator<T*>(begin());
426 template<
typename T,std::
size_t NP, std::
size_t NR, std::
size_t NC>
430 return std::reverse_iterator<const T*>(end());
433 template<
typename T,std::
size_t NP, std::
size_t NR, std::
size_t NC>
437 return std::reverse_iterator<const T*>(begin());
440 template<
typename T,std::
size_t NP, std::
size_t NR, std::
size_t NC>
448 template<
typename T,std::
size_t NP, std::
size_t NR, std::
size_t NC>
457 template<
typename T,std::
size_t NP, std::
size_t NR, std::
size_t NC>
459 std::ostream& operator<<(std::ostream & out,const block3d<T,NP,NR,NC>& b)
462 for(std::size_t i = 0; i < NP; ++i)
464 out << std::endl <<
"------------PLAN "<<i<<
" ---------------" << std::endl<<b.data[i];
472 template<
typename T,std::
size_t NP, std::
size_t NR, std::
size_t NC>
477 for(std::size_t n = 0; n < NP; ++n)
486 template<
typename T,std::
size_t NP, std::
size_t NR, std::
size_t NC>
491 for(std::size_t n = 0; n < NP; ++n)
501 template<
typename T,std::
size_t NP, std::
size_t NR, std::
size_t NC>
505 assert(x.dim()==y.dim());
506 for(std::size_t n = 0; n < NP; ++n)
515 template<
typename T,std::
size_t NP, std::
size_t NR, std::
size_t NC>
520 for(std::size_t n = 0; n < NP; ++n)
529 template<
typename T,std::
size_t NP, std::
size_t NR, std::
size_t NC>
533 assert(x.dim()==y.dim());
534 for(std::size_t n = 0; n < NP; ++n)
543 template<
typename T,std::
size_t NP, std::
size_t NR, std::
size_t NC>
548 for(std::size_t n = 0; n < NP; ++n)
556 template<
typename T,std::
size_t NP, std::
size_t NR, std::
size_t NC>
566 template<
typename T,std::
size_t NP, std::
size_t NR, std::
size_t NC>
569 const std::size_t j)
const
577 template<
typename T,std::
size_t NP, std::
size_t NR, std::
size_t NC>
586 return data[i][j][k];
589 template<
typename T,std::
size_t NP, std::
size_t NR, std::
size_t NC>
593 const std::size_t k)
const
598 return data[i * NC * NR + j * NC + k];
601 template<
typename T,std::
size_t NP, std::
size_t NR, std::
size_t NC>
605 for(std::size_t i = 0; i < NP; ++i){
611 template<
typename T,std::
size_t NP, std::
size_t NR, std::
size_t NC>
615 for(std::size_t i = 0; i < NP; ++i){
616 data[i].fill(&val[i*NR*NC]);
621 template<
typename T,std::
size_t NP, std::
size_t NR, std::
size_t NC>
625 std::swap_ranges(begin(),end(),M.
begin());
642 #endif //SLIP_BLOCK3D_HPP
bool operator!=(const Array< T > &x, const Array< T > &y)
const value_type * const_pointer
slip::block2d< T, NR, NC > data[NP]
Prints the elements of the block3d on the standard output.
static std::size_t size_max()
Returns the maximal size (number of elements) of the block3d.
static const std::size_t DIM
static std::size_t dim3()
Returns the third dimension of the block3d (number of columns)
This is a two-dimensional static and generic container. This container statisfies the BidirectionnalC...
Provides a class to manipulate 2d static and generic arrays.
reverse_iterator rbegin()
std::reverse_iterator< const_iterator > const_reverse_iterator
void swap(block3d< T, NP, NR, NC > &M)
Swaps the contents of two block3d.
const_pointer const_iterator
std::string name() const
Returns the name of the class.
bool operator>(const Array< T > &x, const Array< T > &y)
T * operator()(const std::size_t i, const std::size_t j)
Returns a reference to the element at the i'th plan, the j'th row and the k'th column.
void fill(const T &val)
Init the block3d filled it with val value.
friend class boost::serialization::access
slip::block2d< T, NR, NC > & operator[](const std::size_t i)
Returns a pointer to the i'th plan of the block3d.
std::random_access_iterator3d_tag iterator_category
static std::size_t dim2()
Returns the second dimension of the block3d (number of rows)
std::reverse_iterator< iterator > reverse_iterator
This a three-dimensional static and generic container. This container statisfies the BidirectionnalCo...
static bool empty()
Returns true if the block3d size is 0.
static std::size_t size()
Returns the size (number of elements) of the block3d.
ptrdiff_t difference_type
static std::size_t dim1()
Returns the first dimension of the block3d (number of plans)
const value_type & const_reference
static const std::size_t SIZE
static std::size_t dim()
Returns the dimension of the block3d.
bool operator==(const Array< T > &x, const Array< T > &y)
bool operator>=(const Array< T > &x, const Array< T > &y)