OGS 6.2.0-244-g47b8a9a9d
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 19 of file GeometricBasics.h.

`#include <GeometricBasics.h>`

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

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

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

## Protected Attributes

std::array< T, DIM > _x

## ◆ 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.

## ◆ 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
 x std::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

## ◆ getCoords()

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

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

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 ).

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  }

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
 os a 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

## ◆ _x

template<typename T, std::size_t DIM = 3>
 std::array MathLib::TemplatePoint< T, DIM >::_x
protected

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