OGS
MathLib::TemplatePoint< T, DIM > Class Template Reference

Detailed Description

template<typename T, std::size_t DIM = 3> class MathLib::TemplatePoint< T, DIM >

class-template for points can be instantiated by a numeric type.

Template Parameters
 T the coordinate type

Definition at line 36 of file TemplatePoint.h.

#include <TemplatePoint.h>

Public Member Functions

TemplatePoint ()

TemplatePoint (std::array< T, DIM > x)

virtual ~TemplatePoint ()=default

TemplatePoint (TemplatePoint const &)=default

TemplatePointoperator= (TemplatePoint const &)=default

const T & operator[] (std::size_t idx) const

T & operator[] (std::size_t idx)
access operator (see book Effektiv C++ programmieren - subsection 1.3.2 ). More...

const T * getCoords () const

T * getCoords ()

virtual void write (std::ostream &os) const

Private Attributes

std::array< T, DIM > x_

◆ TemplatePoint() [1/3]

template<typename T , std::size_t DIM>
 MathLib::TemplatePoint< T, DIM >::TemplatePoint

default constructor with zero coordinates

Definition at line 99 of file TemplatePoint.h.

99  : x_({{0}})
100 {}
std::array< T, DIM > x_
Definition: TemplatePoint.h:95

◆ TemplatePoint() [2/3]

template<typename T , std::size_t DIM>
 MathLib::TemplatePoint< T, DIM >::TemplatePoint ( std::array< T, DIM > x )
explicit

constructor - constructs a TemplatePoint object

Parameters
 x std::array containing the coordinates of the point

Definition at line 103 of file TemplatePoint.h.

103  : x_(std::move(x))
104 {}

◆ ~TemplatePoint()

template<typename T , std::size_t DIM = 3>
 virtual MathLib::TemplatePoint< T, DIM >::~TemplatePoint ( )
virtualdefault

virtual destructor

◆ TemplatePoint() [3/3]

template<typename T , std::size_t DIM = 3>
 MathLib::TemplatePoint< T, DIM >::TemplatePoint ( TemplatePoint< T, DIM > const & )
default

◆ getCoords() [1/2]

template<typename T , std::size_t DIM = 3>
 T* MathLib::TemplatePoint< T, DIM >::getCoords ( )
inline

Definition at line 77 of file TemplatePoint.h.

77 { return x_.data(); }

References MathLib::TemplatePoint< T, DIM >::x_.

◆ operator=()

template<typename T , std::size_t DIM = 3>
 TemplatePoint& MathLib::TemplatePoint< T, DIM >::operator= ( TemplatePoint< T, DIM > const & )
default

◆ operator[]() [1/2]

template<typename T , std::size_t DIM = 3>
 T& MathLib::TemplatePoint< T, DIM >::operator[] ( std::size_t idx )
inline

access operator (see book Effektiv C++ programmieren - subsection 1.3.2 ).

const T& operator[] (std::size_t idx) const

Definition at line 69 of file TemplatePoint.h.

70  {
71  return const_cast<T&> (static_cast<const TemplatePoint&> (*this)[idx]);
72  }

◆ operator[]() [2/2]

template<typename T , std::size_t DIM = 3>
 const T& MathLib::TemplatePoint< T, DIM >::operator[] ( std::size_t idx ) const
inline

Point<double> point (1.0, 2.0, 3.0);
double sqrNrm2 = point[0] * point[0] + point[1] * point[1] + point[2] + point[2];

Definition at line 61 of file TemplatePoint.h.

62  {
63  assert (idx < DIM);
64  return x_[idx];
65  }

References MathLib::TemplatePoint< T, DIM >::x_.

template<typename T , std::size_t DIM = 3>
 virtual void MathLib::TemplatePoint< T, DIM >::read ( std::istream & is )
inlinevirtual

read point coordinates into stream (used from operator>>)

Definition at line 88 of file TemplatePoint.h.

89  {
90  std::copy(std::istream_iterator<T>(is), std::istream_iterator<T>(),
91  x_.begin());
92  }
void copy(PETScVector const &x, PETScVector &y)
Definition: LinAlg.cpp:37

References MathLib::LinAlg::copy(), and MathLib::TemplatePoint< T, DIM >::x_.

◆ write()

template<typename T , std::size_t DIM = 3>
 virtual void MathLib::TemplatePoint< T, DIM >::write ( std::ostream & os ) const
inlinevirtual

write point coordinates into stream (used from operator<<)

Parameters
 os a standard output stream

Reimplemented in FileIO::GMSH::GMSHPoint.

Definition at line 82 of file TemplatePoint.h.

83  {
84  std::copy(x_.cbegin(), x_.cend(), std::ostream_iterator<T>(os, " "));
85  }

References MathLib::LinAlg::copy(), and MathLib::TemplatePoint< T, DIM >::x_.

◆ x_

template<typename T , std::size_t DIM = 3>
 std::array MathLib::TemplatePoint< T, DIM >::x_
private

Definition at line 95 of file TemplatePoint.h.

The documentation for this class was generated from the following files: