75 #ifndef SLIP_DPOINT_HPP
76 #define SLIP_DPOINT_HPP
83 #include <boost/serialization/access.hpp>
84 #include <boost/serialization/split_member.hpp>
85 #include <boost/serialization/complex.hpp>
86 #include <boost/serialization/version.hpp>
91 template <
typename CoordType, std::
size_t DIM>
94 template <
typename CoordType, std::
size_t DIM>
95 std::ostream& operator<<(std::ostream & out, const DPoint<CoordType,DIM>& p);
108 template <
typename CoordType, std::
size_t DIM>
133 DPoint(
const self& other);
140 DPoint(
const CoordType* array);
152 friend std::ostream& operator<< <>(std::ostream & out,
const self& p);
270 std::size_t
dim()
const;
276 std::size_t
size()
const;
299 void swap(
self& other);
324 friend class boost::serialization::access;
325 template<
class Archive>
326 void save(Archive & ar,
const unsigned int version)
const
330 template<
class Archive>
331 void load(Archive & ar,
const unsigned int version)
335 BOOST_SERIALIZATION_SPLIT_MEMBER()
344 template<
typename CoordType,std::
size_t DIM>
349 template<
typename CoordType,std::
size_t DIM>
355 template<
typename CoordType,std::
size_t DIM>
359 std::copy(array,array+DIM,coord_.begin());
362 template<
typename CoordType,std::
size_t DIM>
368 this->coord_ = other.coord_;
374 template<
typename CoordType,std::
size_t DIM>
379 return this->coord_[i];
382 template<
typename CoordType,std::
size_t DIM>
387 return this->coord_[i];
390 template<
typename CoordType,std::
size_t DIM>
394 template<
typename CoordType,std::
size_t DIM>
398 template<
typename CoordType,std::
size_t DIM>
402 template<
typename CoordType,std::
size_t DIM>
406 template<
typename CoordType,std::
size_t DIM>
413 template<
typename CoordType,std::
size_t DIM>
417 (this->coord_).swap(other.coord_);
420 template<
typename CoordType,std::
size_t DIM>
429 template<
typename CoordType,std::
size_t DIM>
433 return this->coord_ == other.coord_;
436 template<
typename CoordType,std::
size_t DIM>
440 return this->coord_ != other.coord_;
443 template<
typename CoordType,std::
size_t DIM>
448 std::transform(coord_.begin(),coord_.end(),(tmp.coord_).begin(),std::negate<CoordType>());
453 template<
typename CoordType,std::
size_t DIM>
457 for(std::size_t i = 0; i < DIM; ++i)
459 (this->coord_)[i] += (other.coord_)[i];
464 template<
typename CoordType,std::
size_t DIM>
473 template<
typename CoordType,std::
size_t DIM>
477 for(std::size_t i = 0; i < DIM; ++i)
479 (this->coord_)[i] -= (other.coord_)[i];
484 template<
typename CoordType,std::
size_t DIM>
496 #endif //SLIP_DPOINT_HPP
std::size_t size() const
Returns the dimension of the DPoint.
std::size_t max_size() const
Returns the maximal size of the DPoint.
reference operator[](const std::size_t i)
Returns the i'th coordinate of the DPoint.
const block< value_type, DIM > & coord() const
Return the coordinates of the DPoint.
DPoint()
Default constructor (protected to avoid default construction)
const value_type * const_dpointer
void save(Archive &ar, const unsigned int version) const
self operator+(const self &other) const
add the coordinates of a two DPoint
Provides a class to manipulate 1d static and generic arrays.
bool empty() const
Returns true if dimension of the DPoint is 0.
std::random_access_iterator_tag iterator_category
std::size_t dim() const
Returns the dimension of the DPoint.
bool operator!=(const self &other) const
compare two DPoint.
Define an abstract DPoint structure.
void copy(_II first, _II last, _OI output_first)
Copy algorithm optimized for slip iterators.
void swap(self &other)
Swaps two DPoint.
std::ostream & operator<<(std::ostream &out, const Array< T > &a)
const value_type & const_reference
block< value_type, DIM > coord_
The coordinates of the dpoint are stored in this block.
self & operator+=(const self &other)
add the coordinates of a DPoint to the DPoint
void load(Archive &ar, const unsigned int version)
self & operator=(const self &other)
Assign a DPoint.
self operator-() const
negate all the coordinates of a DPoint
bool operator==(const self &other) const
compare two DPoint.
self & operator-=(const self &other)
substract the coordinates of a DPoint to the DPoint