STIR  6.2.0
Public Member Functions | List of all members
stir::BasicCoordinate< num_dimensions, coordT > Class Template Reference

class BasicCoordinate<int num_dimensions, typename coordT> defines num_dimensions -dimensional coordinates. More...

#include "stir/BasicCoordinate.h"

Inheritance diagram for stir::BasicCoordinate< num_dimensions, coordT >:
Inheritance graph
[legend]

Public Types

typedefs for iterator support
typedef std::random_access_iterator_tag iterator_category
 
typedef coordT value_type
 
typedef value_type & reference
 
typedef const value_type & const_reference
 
typedef value_type * iterator
 
typedef value_type * pointer
 
typedef const value_type * const_iterator
 
typedef std::ptrdiff_t difference_type
 
typedef std::size_t size_type
 

Public Member Functions

 BasicCoordinate ()
 default constructor. NO initialisation
 
 BasicCoordinate (const coordT &)
 constructor that sets all elements equal to value.
 
template<typename coordT2 >
 BasicCoordinate (const BasicCoordinate< num_dimensions, coordT2 > &c)
 constructor from different type of coordT More...
 
BasicCoordinateoperator= (const BasicCoordinate &c)
 assignment
 
bool operator== (const BasicCoordinate &c) const
 comparison
 
bool operator< (const BasicCoordinate &c) const
 less-than (using lexical ordering)
 
coordT & operator[] (const int d)
 Return value at index t (which is 1-based)
 
coordT const & operator[] (const int d) const
 Return value at index t (which is 1-based) if the BasicCoordinate object is const. More...
 
coordT & at (const int d)
 Return value at index t (which is 1-based), but with range checking (throws std::out_of_range)
 
coordT const & at (const int d) const
 Return value at index t (which is 1-based) if the BasicCoordinate object is const, but with range checking (throws std::out_of_range)
 
bool empty () const
 
arithmetic assignment operators
BasicCoordinateoperator+= (const BasicCoordinate &c)
 
BasicCoordinateoperator-= (const BasicCoordinate &c)
 
BasicCoordinateoperator*= (const BasicCoordinate &c)
 
BasicCoordinateoperator/= (const BasicCoordinate &c)
 
BasicCoordinateoperator+= (const coordT &a)
 
BasicCoordinateoperator-= (const coordT &a)
 
BasicCoordinateoperator*= (const coordT &a)
 
BasicCoordinateoperator/= (const coordT &a)
 
arithmetic operations with a BasicCoordinate, combining element by element
BasicCoordinate operator+ (const BasicCoordinate &c) const
 
BasicCoordinate operator- (const BasicCoordinate &c) const
 
BasicCoordinate operator* (const BasicCoordinate &c) const
 
BasicCoordinate operator/ (const BasicCoordinate &c) const
 
arithmetic operations with a coordT
BasicCoordinate operator+ (const coordT &a) const
 
BasicCoordinate operator- (const coordT &a) const
 
BasicCoordinate operator* (const coordT &a) const
 
BasicCoordinate operator/ (const coordT &a) const
 
BasicCoordinate operator- () const
 
basic iterator support
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 

Functions as in VectorWithOffset

void fill (const coordT &)
 fill elements with value
 
static int get_min_index ()
 
static int get_max_index ()
 
static unsigned size ()
 

Detailed Description

template<int num_dimensions, typename coordT>
class stir::BasicCoordinate< num_dimensions, coordT >

class BasicCoordinate<int num_dimensions, typename coordT> defines num_dimensions -dimensional coordinates.

A BasicCoordinate<num_dimensions, coordT> is essentially a vector of size num_dimensions, but as the dimension is templated, it has better performance.

Access to the individual coordinates is through operator[].

Warning
Indices run from 1 to num_dimensions

Constructor & Destructor Documentation

◆ BasicCoordinate()

template<int num_dimensions, typename coordT>
template<typename coordT2 >
stir::BasicCoordinate< num_dimensions, coordT >::BasicCoordinate ( const BasicCoordinate< num_dimensions, coordT2 > &  c)
inlineexplicit

constructor from different type of coordT

Uses assignment after

static_cast<coordT>

Member Function Documentation

◆ operator[]()

template<int num_dimensions, class coordT >
coordT const & stir::BasicCoordinate< num_dimensions, coordT >::operator[] ( const int  d) const
inline

Return value at index t (which is 1-based) if the BasicCoordinate object is const.

Note that the return type is not simply coordT. This mimics the design of std::vector. One can argue about this (see e.g. http://groups.google.com/group/comp.lang.c%2B%2B.moderated/browse_thread/thread/e5c4898a5c259cc1/434f5a25df51781f%23434f5a25df51781f?sa=X&oi=groupsr&start=2&num=3), However, this alternative can have severe performance penalties if coordT is a type for large objects.


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