STIR 6.4.0
NumericVectorWithOffset.h
Go to the documentation of this file.
1//
2//
3/*
4 Copyright (C) 2000 PARAPET partners
5 Copyright (C) 2000 - 2005-06-03, Hammersmith Imanet Ltd
6 Copyright (C) 2011-07-01 - 2012, Kris Thielemans
7 Copyright (C) 2020, 2023 University College London
8 This file is part of STIR.
9
10 SPDX-License-Identifier: Apache-2.0 AND License-ref-PARAPET-license
11
12 See STIR/LICENSE.txt for details
13*/
14
15#ifndef __NumericVectorWithOffset_H__
16#define __NumericVectorWithOffset_H__
27
29#include "stir/deprecated.h"
30
31START_NAMESPACE_STIR
45
46template <class T, class elemT>
48{
49#ifdef SWIG
50public: // needs to be public for SWIG to be able to parse the "using" statement below
51#endif
52
53 typedef VectorWithOffset<T> base_type;
54
55public:
56 using base_type::base_type;
57
60
63 : NumericVectorWithOffset(static_cast<const base_type&>(t))
64 {}
65
67 // implementation in .h because of templates/friends/whatever, see https://stackoverflow.com/a/61020224
68 friend inline void swap(NumericVectorWithOffset& first, NumericVectorWithOffset& second) // nothrow
69 {
70 swap(static_cast<base_type&>(first), static_cast<base_type&>(second));
71 }
72
74
76
79
80 // arithmetic operations with a vector, combining element by element
81
84
87
90
93
94 // arithmetic operations with a elemT
95 // TODO??? use member templates
96
98 inline NumericVectorWithOffset operator+(const elemT& v) const;
99
101 inline NumericVectorWithOffset operator-(const elemT& v) const;
102
104 inline NumericVectorWithOffset operator*(const elemT& v) const;
105
107 inline NumericVectorWithOffset operator/(const elemT& v) const;
108
109 // corresponding assignment operators
110
113
116
119
122
124 inline NumericVectorWithOffset& operator+=(const elemT& v);
125
127 inline NumericVectorWithOffset& operator-=(const elemT& v);
128
130 inline NumericVectorWithOffset& operator*=(const elemT& v);
131
133 inline NumericVectorWithOffset& operator/=(const elemT& v);
134
136 template <typename elemT2>
137 STIR_DEPRECATED inline void
138 axpby(const elemT2 a, const NumericVectorWithOffset& x, const elemT2 b, const NumericVectorWithOffset& y);
139
141 inline void xapyb(const NumericVectorWithOffset& x, const elemT a, const NumericVectorWithOffset& y, const elemT b);
142
144 inline void xapyb(const NumericVectorWithOffset& x,
147 const NumericVectorWithOffset& b);
148
150 template <class T2>
151 inline void sapyb(const T2& a, const NumericVectorWithOffset& y, const T2& b);
152};
153
154END_NAMESPACE_STIR
155
157
158#endif // __NumericVectorWithOffset_H__
inline implementations for stir::NumericVectorWithOffset
defines the stir::VectorWithOffset class
NumericVectorWithOffset(const NumericVectorWithOffset &t)
Constructor from an object of this class' base_type.
Definition NumericVectorWithOffset.h:62
NumericVectorWithOffset & operator=(const NumericVectorWithOffset &other)
assignment
Definition NumericVectorWithOffset.inl:46
NumericVectorWithOffset & operator*=(const elemT &v)
multiplying the elements of the current vector with an elemT
NumericVectorWithOffset operator+(const NumericVectorWithOffset &v) const
adding vectors, element by element
Definition NumericVectorWithOffset.inl:55
NumericVectorWithOffset operator-(const elemT &v) const
return a new vector with elements equal to the difference of the elements in the original and the ele...
NumericVectorWithOffset operator/(const NumericVectorWithOffset &v) const
dividing vectors, element by element
Definition NumericVectorWithOffset.inl:85
NumericVectorWithOffset operator*(const elemT &v) const
return a new vector with elements equal to the multiplication of the elements in the original and the...
NumericVectorWithOffset & operator-=(const elemT &v)
subtracting an elemT from the elements of the current vector
void xapyb(const NumericVectorWithOffset &x, const elemT a, const NumericVectorWithOffset &y, const elemT b)
set values of the array to x*a+y*b, where a and b are scalar
NumericVectorWithOffset operator*(const NumericVectorWithOffset &v) const
multiplying vectors, element by element
Definition NumericVectorWithOffset.inl:75
void xapyb(const NumericVectorWithOffset &x, const NumericVectorWithOffset &a, const NumericVectorWithOffset &y, const NumericVectorWithOffset &b)
set the values of the array to x*a+y*b, where a and b are vectors
Definition NumericVectorWithOffset.inl:301
NumericVectorWithOffset & operator+=(const NumericVectorWithOffset &v)
adding elements of v to the current vector
Definition NumericVectorWithOffset.inl:137
NumericVectorWithOffset operator/(const elemT &v) const
return a new vector with elements equal to the division of the elements in the original and the elemT
NumericVectorWithOffset operator-(const NumericVectorWithOffset &v) const
subtracting vectors, element by element
Definition NumericVectorWithOffset.inl:65
NumericVectorWithOffset & operator+=(const elemT &v)
adding an elemT to the elements of the current vector
NumericVectorWithOffset & operator/=(const NumericVectorWithOffset &v)
dividing all elements of the current vector by elements of v
Definition NumericVectorWithOffset.inl:202
void sapyb(const T2 &a, const NumericVectorWithOffset &y, const T2 &b)
set the values of the array to self*a+y*b, where a and b are scalar or vectors
Definition NumericVectorWithOffset.inl:328
NumericVectorWithOffset(const VectorWithOffset< T > &t)
Constructor from an object of this class' base_type.
Definition NumericVectorWithOffset.inl:32
NumericVectorWithOffset & operator/=(const elemT &v)
dividing the elements of the current vector by an elemT
NumericVectorWithOffset(NumericVectorWithOffset &&other) noexcept
move constructor
NumericVectorWithOffset operator+(const elemT &v) const
return a new vector with elements equal to the sum of the elements in the original and the elemT
NumericVectorWithOffset & operator-=(const NumericVectorWithOffset &v)
subtracting elements of v from the current vector
Definition NumericVectorWithOffset.inl:155
friend void swap(NumericVectorWithOffset &first, NumericVectorWithOffset &second)
Swap content/members of 2 objects.
Definition NumericVectorWithOffset.h:68
STIR_DEPRECATED void axpby(const elemT2 a, const NumericVectorWithOffset &x, const elemT2 b, const NumericVectorWithOffset &y)
NumericVectorWithOffset & operator*=(const NumericVectorWithOffset &v)
multiplying elements of the current vector with elements of v
Definition NumericVectorWithOffset.inl:178
VectorWithOffset()
Default constructor: creates a vector of length 0.
Definition VectorWithOffset.inl:253
This file declares a deprecation macro.
#define STIR_DEPRECATED
Deprecation macro.
Definition deprecated.h:21