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;
72 template <
int num_dimensions,
typename elemT>
91 typedef typename base_type::difference_type difference_type;
92 typedef typename base_type::size_type size_type;
103 typedef elemT full_value_type;
104 typedef full_value_type* full_pointer;
105 typedef const full_value_type* const_full_pointer;
106 typedef full_value_type& full_reference;
107 typedef const full_value_type& const_full_reference;
121 const_full_reference,
124 # else // ARRAY_FULL2 127 typedef FullArrayConstIterator<num_dimensions, elemT, const_full_reference, const_full_pointer>
const_full_iterator;
157 inline Array(
const base_type& t);
162 inline Array(
const self& t);
165 inline ~
Array()
override;
173 swap(static_cast<base_type&>(first), static_cast<base_type&>(second));
174 swap(first._allocated_full_data_ptr, second._allocated_full_data_ptr);
187 inline full_iterator begin_all();
190 inline const_full_iterator begin_all()
const;
192 inline const_full_iterator begin_all_const()
const;
194 inline full_iterator end_all();
196 inline const_full_iterator end_all()
const;
198 inline const_full_iterator end_all_const()
const;
204 inline size_t size_all()
const;
221 inline elemT
sum()
const;
224 inline elemT sum_positive()
const;
227 inline elemT find_max()
const;
230 inline elemT find_min()
const;
236 inline void fill(
const elemT& n);
238 inline void apply_lower_threshold(
const elemT& l);
241 inline void apply_upper_threshold(
const elemT& u);
250 inline bool is_regular()
const;
257 inline Array<num_dimensions - 1, elemT>& operator[](
int i);
260 inline const Array<num_dimensions - 1, elemT>& operator[](
int i)
const;
271 inline Array<num_dimensions - 1, elemT>& at(
int i);
273 inline const Array<num_dimensions - 1, elemT>& at(
int i)
const;
281 template <
typename elemT2>
285 inline void xapyb(
const Array& x,
const elemT a,
const Array& y,
const elemT b);
292 inline void sapyb(
const T& a,
const Array& y,
const T& b);
296 bool is_contiguous()
const;
300 inline elemT* get_full_data_ptr();
303 inline const elemT* get_const_full_data_ptr()
const;
306 inline void release_full_data_ptr();
309 inline void release_const_full_data_ptr()
const;
315 mutable bool _full_pointer_access;
318 shared_ptr<elemT[]> _allocated_full_data_ptr;
329 template <
int num_dimensions2,
class elemT2>
338 template <
class elemT>
340 #ifdef STIR_USE_BOOST 342 boost::operators<Array<1, elemT>, NumericVectorWithOffset<elemT, elemT>>,
343 boost::operators<Array<1, elemT>>,
344 boost::operators<Array<1, elemT>, elemT>
361 typedef typename base_type::reference reference;
362 typedef typename base_type::const_reference const_reference;
363 typedef typename base_type::difference_type difference_type;
364 typedef typename base_type::size_type size_type;
365 typedef typename base_type::iterator iterator;
366 typedef typename base_type::const_iterator const_iterator;
386 inline Array(
const int min_index,
const int max_index);
409 inline Array(
const self& t);
416 inline ~
Array()
override;
422 swap(static_cast<base_type&>(first), static_cast<base_type&>(second));
430 inline full_iterator begin_all();
433 inline const_full_iterator begin_all()
const;
435 inline const_full_iterator begin_all_const()
const;
437 inline full_iterator end_all();
439 inline const_full_iterator end_all()
const;
441 inline const_full_iterator end_all_const()
const;
448 inline size_t size_all()
const;
454 inline void grow(
const int min_index,
const int max_index)
override;
460 inline void resize(
const int min_index,
const int max_index)
override;
464 bool is_contiguous()
const 472 return this->get_data_ptr();
478 return this->get_const_data_ptr();
484 this->release_data_ptr();
490 this->release_const_data_ptr();
495 inline elemT
sum()
const;
498 inline elemT sum_positive()
const;
501 inline elemT find_max()
const;
504 inline elemT find_min()
const;
507 inline bool is_regular()
const;
512 #ifndef STIR_USE_BOOST 524 inline self operator+(
const base_type& iv)
const;
527 inline self operator-(
const base_type& iv)
const;
530 inline self operator*(
const base_type& iv)
const;
533 inline self operator/(
const base_type& iv)
const;
536 inline self operator+(
const elemT a)
const;
539 inline self operator-(
const elemT a)
const;
542 inline self operator*(
const elemT a)
const;
545 inline self operator/(
const elemT a)
const;
550 inline elemT& operator[](
int i);
553 inline const elemT& operator[](
int i)
const;
563 inline elemT& at(
int i);
565 inline const elemT& at(
int i)
const;
574 template <
int num_dimensions2,
class elemT2>
581 inline void init(
const IndexRange<1>& range, elemT*
const data_ptr,
bool copy_data);
590 # include "FullArrayIterator2.h" 591 # include "FullArrayConstIterator.h" 597 #endif // __Array_H__ #define STIR_DEPRECATED
Deprecation macro.
Definition: deprecated.h:19
This file declares the stir::ByteOrder class.
iterator full_iterator
Iterator type for going through all elements.
Definition: Array.h:373
defines the stir::NumericVectorWithOffset class
elemT * get_full_data_ptr()
member function for access to the data via a elemT*
Definition: Array.h:470
friend void swap(Array &first, Array &second)
Swap content/members of 2 objects.
Definition: Array.h:169
This class defines ranges which can be 'irregular'.
Definition: ArrayFunctionObject.h:32
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 (or corresponding b...
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:123
const elemT * get_const_full_data_ptr() const
member function for access to the data via a const elemT*
Definition: Array.h:476
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:115
void release_full_data_ptr()
signal end of access to elemT*
Definition: Array.h:482
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:360
void release_const_full_data_ptr() const
signal end of access to const elemT*
Definition: Array.h:488
friend void swap(Array &first, Array &second)
Swap content/members of 2 objects.
Definition: Array.h:420
const_iterator const_full_iterator
Iterator type for going through all elements of a const object.
Definition: Array.h:376
The 1-dimensional (partial) specialisation of Array.
Definition: Array.h:339
This file defines the stir::IndexRange class.
This class defines multi-dimensional (numeric) arrays.
Definition: Array.h:73
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