14 #ifndef __stir_Array_H__ 15 #define __stir_Array_H__ 45 template <
typename topleveliterT,
typename restiterT,
typename elemT,
typename _Ref,
typename _Ptr>
48 template <
int num_dimensions,
typename elemT,
typename _Ref,
typename _Ptr>
50 template <
int num_dimensions,
typename elemT,
typename _Ref,
typename _Ptr>
51 class FullArrayConstIterator;
76 template <
int num_dimensions,
typename elemT>
79 #ifdef STIR_COMPILING_SWIG_WRAPPER 93 typedef typename base_type::difference_type difference_type;
94 typedef typename base_type::size_type size_type;
105 typedef elemT full_value_type;
106 typedef full_value_type* full_pointer;
107 typedef const full_value_type* const_full_pointer;
108 typedef full_value_type& full_reference;
109 typedef const full_value_type& const_full_reference;
123 const_full_reference,
126 # else // ARRAY_FULL2 129 typedef FullArrayConstIterator<num_dimensions, elemT, const_full_reference, const_full_pointer>
const_full_iterator;
159 inline Array(
const base_type& t);
164 inline Array(
const self& t);
167 inline ~
Array()
override;
175 swap(static_cast<base_type&>(first), static_cast<base_type&>(second));
176 swap(first._allocated_full_data_ptr, second._allocated_full_data_ptr);
189 inline full_iterator begin_all();
192 inline const_full_iterator begin_all()
const;
194 inline const_full_iterator begin_all_const()
const;
196 inline full_iterator end_all();
198 inline const_full_iterator end_all()
const;
200 inline const_full_iterator end_all_const()
const;
206 inline size_t size_all()
const;
224 inline elemT
sum()
const;
227 inline elemT sum_positive()
const;
230 inline elemT find_max()
const;
233 inline elemT find_min()
const;
239 inline void fill(
const elemT& n);
241 inline void apply_lower_threshold(
const elemT& l);
244 inline void apply_upper_threshold(
const elemT& u);
253 inline bool is_regular()
const;
260 inline Array<num_dimensions - 1, elemT>& operator[](
int i);
263 inline const Array<num_dimensions - 1, elemT>& operator[](
int i)
const;
274 inline Array<num_dimensions - 1, elemT>& at(
int i);
276 inline const Array<num_dimensions - 1, elemT>& at(
int i)
const;
287 inline self& operator+=(
const self& x)
289 base_type::operator+=(x);
292 inline self& operator-=(
const self& x)
294 base_type::operator-=(x);
297 inline self& operator*=(
const self& x)
299 base_type::operator*=(x);
302 inline self& operator/=(
const self& x)
304 base_type::operator/=(x);
307 inline self& operator+=(
const elemT x)
309 base_type::operator+=(x);
312 inline self& operator-=(
const elemT x)
314 base_type::operator-=(x);
317 inline self& operator*=(
const elemT x)
319 base_type::operator*=(x);
322 inline self& operator/=(
const elemT x)
324 base_type::operator/=(x);
327 inline self operator+(
const self& x)
const 332 inline self operator+(
const elemT x)
const 337 inline self operator-(
const self& x)
const 342 inline self operator-(
const elemT x)
const 347 inline self operator*(
const self& x)
const 352 inline self operator*(
const elemT x)
const 357 inline self operator/(
const self& x)
const 362 inline self operator/(
const elemT x)
const 370 template <
typename elemT2>
374 inline void xapyb(
const Array& x,
const elemT a,
const Array& y,
const elemT b);
381 inline void sapyb(
const T& a,
const Array& y,
const T& b);
385 bool is_contiguous()
const;
389 inline elemT* get_full_data_ptr();
392 inline const elemT* get_const_full_data_ptr()
const;
395 inline void release_full_data_ptr();
398 inline void release_const_full_data_ptr()
const;
404 mutable bool _full_pointer_access;
407 shared_ptr<elemT[]> _allocated_full_data_ptr;
429 template <
int num_dimensions2,
class elemT2>
432 using base_type::grow;
433 using base_type::resize;
441 template <
class elemT>
444 #ifdef STIR_COMPILING_SWIG_WRAPPER 456 typedef typename base_type::reference reference;
457 typedef typename base_type::const_reference const_reference;
458 typedef typename base_type::difference_type difference_type;
459 typedef typename base_type::size_type size_type;
460 typedef typename base_type::iterator iterator;
461 typedef typename base_type::const_iterator const_iterator;
481 inline Array(
const int min_index,
const int max_index);
504 inline Array(
const self& t);
511 inline ~
Array()
override;
517 swap(static_cast<base_type&>(first), static_cast<base_type&>(second));
525 inline full_iterator begin_all();
528 inline const_full_iterator begin_all()
const;
530 inline const_full_iterator begin_all_const()
const;
532 inline full_iterator end_all();
534 inline const_full_iterator end_all()
const;
536 inline const_full_iterator end_all_const()
const;
543 inline size_t size_all()
const;
549 inline void grow(
const int min_index,
const int max_index)
override;
554 inline void resize(
const int min_index,
const int max_index,
bool initialise_with_0);
556 inline void resize(
const int min_index,
const int max_index)
override;
560 bool is_contiguous()
const 568 return this->get_data_ptr();
574 return this->get_const_data_ptr();
580 this->release_data_ptr();
586 this->release_const_data_ptr();
591 inline elemT
sum()
const;
594 inline elemT sum_positive()
const;
597 inline elemT find_max()
const;
600 inline elemT find_min()
const;
603 inline bool is_regular()
const;
611 inline self operator+(
const base_type& iv)
const;
614 inline self operator-(
const base_type& iv)
const;
617 inline self operator*(
const base_type& iv)
const;
620 inline self operator/(
const base_type& iv)
const;
623 inline self operator+(
const elemT a)
const;
626 inline self operator-(
const elemT a)
const;
629 inline self operator*(
const elemT a)
const;
632 inline self operator/(
const elemT a)
const;
635 inline elemT& operator[](
int i);
638 inline const elemT& operator[](
int i)
const;
648 inline elemT& at(
int i);
650 inline const elemT& at(
int i)
const;
658 template <
int num_dimensions2,
class elemT2>
665 inline void init_with_copy(
const IndexRange<1>& range, elemT
const*
const data_ptr);
670 inline void init(
const IndexRange<1>& range, elemT*
const data_ptr,
bool copy_data);
679 # include "FullArrayIterator2.h" 680 # include "FullArrayConstIterator.h" 686 #endif // __Array_H__ #define STIR_DEPRECATED
Deprecation macro.
Definition: deprecated.h:21
This file declares the stir::ByteOrder class.
forward declaration of stir::Array class for multi-dimensional (numeric) arrays
iterator full_iterator
Iterator type for going through all elements.
Definition: Array.h:468
defines the stir::NumericVectorWithOffset class
elemT * get_full_data_ptr()
member function for access to the data via a elemT*
Definition: Array.h:566
friend void swap(Array &first, Array &second)
Swap content/members of 2 objects.
Definition: Array.h:171
This class defines ranges which can be 'irregular'.
Definition: ArrayFunctionObject.h:31
This file declares a deprecation macro.
Class FullArrayIterator implements (forward) iterators that go through all elements of an Array...
Definition: Array.h:46
Import of std::shared_ptr, std::dynamic_pointer_cast and std::static_pointer_cast into the stir names...
inline implementations for the stir::Array class
like VectorWithOffset, but with changes in various numeric operators
Definition: NumericVectorWithOffset.h:47
FullArrayIterator< typename base_type::const_iterator, typename Array< num_dimensions - 1, elemT >::const_full_iterator, elemT, const_full_reference, const_full_pointer > const_full_iterator
As full_iterator, but for const objects.
Definition: Array.h:125
const elemT * get_const_full_data_ptr() const
member function for access to the data via a const elemT*
Definition: Array.h:572
FullArrayIterator< typename base_type::iterator, typename Array< num_dimensions - 1, elemT >::full_iterator, elemT, full_reference, full_pointer > full_iterator
This defines an iterator type that iterates through all elements.
Definition: Array.h:117
void release_full_data_ptr()
signal end of access to elemT*
Definition: Array.h:578
base_type::value_type value_type
typedefs such that we do not need to have typename wherever we use these types defined in the base cl...
Definition: Array.h:455
void release_const_full_data_ptr() const
signal end of access to const elemT*
Definition: Array.h:584
friend void swap(Array &first, Array &second)
Swap content/members of 2 objects.
Definition: Array.h:515
const_iterator const_full_iterator
Iterator type for going through all elements of a const object.
Definition: Array.h:471
The 1-dimensional (partial) specialisation of Array.
Definition: Array.h:442
This file defines the stir::IndexRange class.
This class defines multi-dimensional (numeric) arrays.
Definition: Array.h:77
The (simple) 1 dimensional specialisation of IndexRange.
Definition: IndexRange.h:131
This file declares the stir::FullArrayIterator class.
elemT sum(IterT start, IterT end, elemT init)
Compute the sum of a sequence using operator+=(), using an initial value.
Definition: more_algorithms.inl:52