OGS 6.2.1-97-g73d1aeda3
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
Tthe coordinate type

Definition at line 19 of file GeometricBasics.h.

#include <GeometricBasics.h>

Inheritance diagram for MathLib::TemplatePoint< T, DIM >:

Public Types

using FP_T = T
 

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
 const access operator The access to the point coordinates is like the access to a field. Code example: More...
 
T & operator[] (std::size_t idx)
 access operator (see book Effektiv C++ programmieren - subsection 1.3.2 ). More...
 
const T * getCoords () const
 
virtual void write (std::ostream &os) const
 
virtual void read (std::istream &is)
 

Protected Attributes

std::array< T, DIM > _x
 

Member Typedef Documentation

◆ FP_T

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

Definition at line 39 of file TemplatePoint.h.

Constructor & Destructor Documentation

◆ TemplatePoint() [1/3]

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

default constructor with zero coordinates

Definition at line 101 of file TemplatePoint.h.

101  :
102  _x({{0}})
103 {}
std::array< T, DIM > _x
Definition: TemplatePoint.h:97

◆ 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
xstd::array containing the coordinates of the point

Definition at line 106 of file TemplatePoint.h.

106  : _x(std::move(x))
107 {}
std::array< T, DIM > _x
Definition: TemplatePoint.h:97

◆ ~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

Member Function Documentation

◆ getCoords()

◆ 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>
const T& MathLib::TemplatePoint< T, DIM >::operator[] ( std::size_t  idx) const
inline

const access operator The access to the point coordinates is like the access to a field. Code example:

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 63 of file TemplatePoint.h.

64  {
65  assert (idx < DIM);
66  return _x[idx];
67  }
std::array< T, DIM > _x
Definition: TemplatePoint.h:97

◆ operator[]() [2/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 ).

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

Definition at line 71 of file TemplatePoint.h.

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

◆ read()

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 91 of file TemplatePoint.h.

92  {
93  std::copy(std::istream_iterator<T>(is), std::istream_iterator<T>(), _x.begin());
94  }
std::array< T, DIM > _x
Definition: TemplatePoint.h:97
void copy(MatrixOrVector const &x, MatrixOrVector &y)
Copies x to y.
Definition: LinAlg.h:36

◆ 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
osa standard output stream

Reimplemented in FileIO::GMSH::GMSHPoint.

Definition at line 85 of file TemplatePoint.h.

86  {
87  std::copy(_x.cbegin(), _x.cend(), std::ostream_iterator<T>(os, " "));
88  }
std::array< T, DIM > _x
Definition: TemplatePoint.h:97
void copy(MatrixOrVector const &x, MatrixOrVector &y)
Copies x to y.
Definition: LinAlg.h:36

Member Data Documentation

◆ _x


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