LSST Applications g0f08755f38+9c285cab97,g1635faa6d4+13f3999e92,g1653933729+a8ce1bb630,g1a0ca8cf93+bf6eb00ceb,g28da252d5a+0829b12dee,g29321ee8c0+5700dc9eac,g2bbee38e9b+9634bc57db,g2bc492864f+9634bc57db,g2cdde0e794+c2c89b37c4,g3156d2b45e+41e33cbcdc,g347aa1857d+9634bc57db,g35bb328faa+a8ce1bb630,g3a166c0a6a+9634bc57db,g3e281a1b8c+9f2c4e2fc3,g414038480c+077ccc18e7,g41af890bb2+fde0dd39b6,g5fbc88fb19+17cd334064,g781aacb6e4+a8ce1bb630,g80478fca09+55a9465950,g82479be7b0+d730eedb7d,g858d7b2824+9c285cab97,g9125e01d80+a8ce1bb630,g9726552aa6+10f999ec6a,ga5288a1d22+2a84bb7594,gacf8899fa4+c69c5206e8,gae0086650b+a8ce1bb630,gb58c049af0+d64f4d3760,gc28159a63d+9634bc57db,gcf0d15dbbd+4b7d09cae4,gda3e153d99+9c285cab97,gda6a2b7d83+4b7d09cae4,gdaeeff99f8+1711a396fd,ge2409df99d+5e831397f4,ge79ae78c31+9634bc57db,gf0baf85859+147a0692ba,gf3967379c6+41c94011de,gf3fb38a9a8+8f07a9901b,gfb92a5be7c+9c285cab97,w.2024.46
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
lsst::gauss2d::Image< T, C > Class Template Reference

A 2D image with scalar numeric values, using CRTP. More...

#include <image.h>

Inheritance diagram for lsst::gauss2d::Image< T, C >:
lsst::gauss2d::Object

Public Member Functions

 Image (size_t n_rows, size_t n_cols, const T *value_init=_value_default_ptr(), std::shared_ptr< const CoordinateSystem > coordsys=nullptr)=delete
 
 Image (std::shared_ptr< const CoordinateSystem > coordsys=nullptr)
 
 ~Image ()=default
 
T & _get_value (size_t row, size_t col)
 
T & _get_value_impl (size_t row, size_t col)
 
T & _get_value_unchecked (size_t row, size_t col)
 
T & _get_value_unchecked_impl (size_t row, size_t col)=delete
 
void _check_row_col (size_t row, size_t col) const
 
void _check_row_col_impl (size_t row, size_t col) const
 
const CoordinateSystemget_coordsys () const
 
std::shared_ptr< const CoordinateSystemget_coordsys_ptr_const () const
 
size_t get_n_cols () const
 
size_t get_n_cols_impl () const =delete
 
size_t get_n_rows () const
 
size_t get_n_rows_impl ()=delete
 
void add_value (size_t row, size_t col, T value)
 
void add_value_impl (size_t row, size_t col, T value)
 
void add_value_unchecked (size_t row, size_t col, T value)
 
void add_value_unchecked_impl (size_t row, size_t col, T value)
 
void fill (T value)
 
void fill_impl (T value)
 
get_value (size_t row, size_t col) const
 
get_value_impl (size_t row, size_t col) const
 
get_value_unchecked (size_t row, size_t col) const
 
get_value_unchecked_impl (size_t row, size_t col) const =delete
 
void set_value (size_t row, size_t col, T value)
 
void set_value_impl (size_t row, size_t col, T value)
 
void set_value_unchecked (size_t row, size_t col, T value)
 
void set_value_unchecked_impl (size_t row, size_t col, T value)
 
std::array< size_t, 2 > shape () const
 
size_t size () const
 
std::string repr (bool name_keywords, std::string_view namespace_separator) const override
 Return a full, callable string representation of this.
 
std::string str () const override
 Return a brief, human-readable string representation of this.
 
Image< T, C > & operator+= (T value)
 
Image< T, C > & operator*= (T value)
 
bool operator== (const Image &other) const
 
const bool operator!= (const Image &other) const
 

Static Public Member Functions

static const T * _value_default_ptr ()
 
static std::string_view null_str (const std::string_view &namespace_separator)
 

Static Public Attributes

static constexpr T _value_default = 0
 
static constexpr std::string_view CC_NAMESPACE_SEPARATOR = "::"
 The C++ namespace separator.
 
static constexpr std::string_view NULL_STR_GENERAL = "None"
 
static constexpr std::string_view PY_NAMESPACE_SEPARATOR = "."
 

Detailed Description

template<typename T, class C>
class lsst::gauss2d::Image< T, C >

A 2D image with scalar numeric values, using CRTP.

Basic implementations of most functions are provided. Derived classes should override any and all if the default implementations are not efficient enough.

Template Parameters
tThe numeric type.
CThe specialized class.

Definition at line 107 of file image.h.

Constructor & Destructor Documentation

◆ Image() [1/2]

template<typename T , class C >
lsst::gauss2d::Image< T, C >::Image ( size_t n_rows,
size_t n_cols,
const T * value_init = _value_default_ptr(),
std::shared_ptr< const CoordinateSystem > coordsys = nullptr )
explicitdelete

◆ Image() [2/2]

template<typename T , class C >
lsst::gauss2d::Image< T, C >::Image ( std::shared_ptr< const CoordinateSystem > coordsys = nullptr)
inlineexplicit

Definition at line 115 of file image.h.

116 : _coordsys_ptr(coordsys == nullptr ? nullptr : std::move(coordsys)),
117 _coordsys(_coordsys_ptr == nullptr ? COORDS_DEFAULT : *_coordsys_ptr) {}
T move(T... args)
STL namespace.

◆ ~Image()

template<typename T , class C >
lsst::gauss2d::Image< T, C >::~Image ( )
default

Member Function Documentation

◆ _check_row_col()

template<typename T , class C >
void lsst::gauss2d::Image< T, C >::_check_row_col ( size_t row,
size_t col ) const
inline

Definition at line 133 of file image.h.

133{ return self_const()._check_row_col_impl(row, col); }
int row
Definition CR.cc:145
int col
Definition CR.cc:144

◆ _check_row_col_impl()

template<typename T , class C >
void lsst::gauss2d::Image< T, C >::_check_row_col_impl ( size_t row,
size_t col ) const
inline

Definition at line 134 of file image.h.

134 {
135 if (!((row < this->get_n_rows()) && (col < this->get_n_cols()))) {
136 throw std::out_of_range("row,col = " + std::to_string(row) + "," + std::to_string(col)
137 + " n_rows,n_cols = " + std::to_string(this->get_n_rows()) + ","
138 + std::to_string(this->get_n_cols()));
139 }
140 }
size_t get_n_rows() const
Definition image.h:147
size_t get_n_cols() const
Definition image.h:145
T to_string(T... args)

◆ _get_value()

template<typename T , class C >
T & lsst::gauss2d::Image< T, C >::_get_value ( size_t row,
size_t col )
inline

Definition at line 123 of file image.h.

123{ return static_cast<C&>(*this)._get_value_impl(row, col); }

◆ _get_value_impl()

template<typename T , class C >
T & lsst::gauss2d::Image< T, C >::_get_value_impl ( size_t row,
size_t col )
inline

Definition at line 124 of file image.h.

124 {
126 return this->_get_value_unchecked(row, col);
127 }
void _check_row_col(size_t row, size_t col) const
Definition image.h:133
T & _get_value_unchecked(size_t row, size_t col)
Definition image.h:128

◆ _get_value_unchecked()

template<typename T , class C >
T & lsst::gauss2d::Image< T, C >::_get_value_unchecked ( size_t row,
size_t col )
inline

Definition at line 128 of file image.h.

128 {
129 return self()._get_value_unchecked_impl(row, col);
130 }

◆ _get_value_unchecked_impl()

template<typename T , class C >
T & lsst::gauss2d::Image< T, C >::_get_value_unchecked_impl ( size_t row,
size_t col )
inlinedelete

◆ _value_default_ptr()

template<typename T , class C >
static const T * lsst::gauss2d::Image< T, C >::_value_default_ptr ( )
inlinestatic

Definition at line 121 of file image.h.

121{ return &_value_default; };
static constexpr T _value_default
Definition image.h:120

◆ add_value()

template<typename T , class C >
void lsst::gauss2d::Image< T, C >::add_value ( size_t row,
size_t col,
T value )
inline

Definition at line 150 of file image.h.

150{ self().add_value_impl(row, col, value); }

◆ add_value_impl()

template<typename T , class C >
void lsst::gauss2d::Image< T, C >::add_value_impl ( size_t row,
size_t col,
T value )
inline

Definition at line 151 of file image.h.

151{ this->_get_value(row, col) += value; }
T & _get_value(size_t row, size_t col)
Definition image.h:123

◆ add_value_unchecked()

template<typename T , class C >
void lsst::gauss2d::Image< T, C >::add_value_unchecked ( size_t row,
size_t col,
T value )
inline

Definition at line 152 of file image.h.

152 {
153 self().add_value_unchecked_impl(row, col, value);
154 }

◆ add_value_unchecked_impl()

template<typename T , class C >
void lsst::gauss2d::Image< T, C >::add_value_unchecked_impl ( size_t row,
size_t col,
T value )
inline

Definition at line 155 of file image.h.

155 {
156 self()._get_value_unchecked(row, col) += value;
157 }

◆ fill()

template<typename T , class C >
void lsst::gauss2d::Image< T, C >::fill ( T value)
inline

Definition at line 158 of file image.h.

158{ self().fill_impl(value); }

◆ fill_impl()

template<typename T , class C >
void lsst::gauss2d::Image< T, C >::fill_impl ( T value)
inline

Definition at line 159 of file image.h.

159 {
160 const size_t n_rows = get_n_rows();
161 const size_t n_cols = get_n_cols();
162 for (size_t row = 0; row < n_rows; ++row) {
163 for (size_t col = 0; col < n_cols; ++col) {
164 this->set_value_unchecked(row, col, value);
165 }
166 }
167 }
void set_value_unchecked(size_t row, size_t col, T value)
Definition image.h:179

◆ get_coordsys()

template<typename T , class C >
const CoordinateSystem & lsst::gauss2d::Image< T, C >::get_coordsys ( ) const
inline

Definition at line 142 of file image.h.

142{ return _coordsys; };

◆ get_coordsys_ptr_const()

template<typename T , class C >
std::shared_ptr< const CoordinateSystem > lsst::gauss2d::Image< T, C >::get_coordsys_ptr_const ( ) const
inline

Definition at line 143 of file image.h.

143{ return _coordsys_ptr; };

◆ get_n_cols()

template<typename T , class C >
size_t lsst::gauss2d::Image< T, C >::get_n_cols ( ) const
inline

Definition at line 145 of file image.h.

145{ return static_cast<const C&>(*this).get_n_cols_impl(); }

◆ get_n_cols_impl()

template<typename T , class C >
size_t lsst::gauss2d::Image< T, C >::get_n_cols_impl ( ) const
delete

◆ get_n_rows()

template<typename T , class C >
size_t lsst::gauss2d::Image< T, C >::get_n_rows ( ) const
inline

Definition at line 147 of file image.h.

147{ return static_cast<const C&>(*this).get_n_rows_impl(); }

◆ get_n_rows_impl()

template<typename T , class C >
size_t lsst::gauss2d::Image< T, C >::get_n_rows_impl ( )
delete

◆ get_value()

template<typename T , class C >
T lsst::gauss2d::Image< T, C >::get_value ( size_t row,
size_t col ) const
inline

Definition at line 168 of file image.h.

168{ return self_const().get_value_impl(row, col); }

◆ get_value_impl()

template<typename T , class C >
T lsst::gauss2d::Image< T, C >::get_value_impl ( size_t row,
size_t col ) const
inline

Definition at line 169 of file image.h.

169 {
171 return self_const().get_value_unchecked(row, col);
172 }

◆ get_value_unchecked()

template<typename T , class C >
T lsst::gauss2d::Image< T, C >::get_value_unchecked ( size_t row,
size_t col ) const
inline

Definition at line 173 of file image.h.

173 {
174 return self_const().get_value_unchecked_impl(row, col);
175 }

◆ get_value_unchecked_impl()

template<typename T , class C >
T lsst::gauss2d::Image< T, C >::get_value_unchecked_impl ( size_t row,
size_t col ) const
inlinedelete

◆ null_str()

static std::string_view lsst::gauss2d::Object::null_str ( const std::string_view & namespace_separator)
inlinestaticinherited

Definition at line 49 of file object.h.

49 {
50 return namespace_separator == CC_NAMESPACE_SEPARATOR ? "nullptr" : NULL_STR_GENERAL;
51 }
static constexpr std::string_view CC_NAMESPACE_SEPARATOR
The C++ namespace separator.
Definition object.h:45
static constexpr std::string_view NULL_STR_GENERAL
Definition object.h:46

◆ operator!=()

template<typename T , class C >
const bool lsst::gauss2d::Image< T, C >::operator!= ( const Image< T, C > & other) const
inline

Definition at line 248 of file image.h.

248{ return !(*this == other); }

◆ operator*=()

template<typename T , class C >
Image< T, C > & lsst::gauss2d::Image< T, C >::operator*= ( T value)
inline

Definition at line 213 of file image.h.

213 {
214 const size_t n_rows = get_n_rows();
215 const size_t n_cols = get_n_cols();
216 for (size_t row = 0; row < n_rows; ++row) {
217 for (size_t col = 0; col < n_cols; ++col) {
218 // Avoid annoying warning for bool case
219 if constexpr (std::is_same_v<T, bool>) {
220 this->set_value_unchecked(row, col, value && this->get_value_unchecked(row, col));
221 } else {
222 this->set_value_unchecked(row, col, value * this->get_value_unchecked(row, col));
223 }
224 }
225 }
226 return *this;
227 }
T get_value_unchecked(size_t row, size_t col) const
Definition image.h:173

◆ operator+=()

template<typename T , class C >
Image< T, C > & lsst::gauss2d::Image< T, C >::operator+= ( T value)
inline

Definition at line 202 of file image.h.

202 {
203 const size_t n_rows = get_n_rows();
204 const size_t n_cols = get_n_cols();
205 for (size_t row = 0; row < n_rows; ++row) {
206 for (size_t col = 0; col < n_cols; ++col) {
207 this->add_value_unchecked(row, col, value);
208 }
209 }
210 return *this;
211 }
void add_value_unchecked(size_t row, size_t col, T value)
Definition image.h:152

◆ operator==()

template<typename T , class C >
bool lsst::gauss2d::Image< T, C >::operator== ( const Image< T, C > & other) const
inline

Definition at line 232 of file image.h.

232 {
233 if (images_compatible<T, C, T, C>(*this, other)) {
234 const size_t n_rows = get_n_rows();
235 const size_t n_cols = get_n_cols();
236 for (size_t row = 0; row < n_rows; ++row) {
237 for (size_t col = 0; col < n_cols; ++col) {
238 if (this->get_value_unchecked(row, col) != other.get_value_unchecked(row, col)) {
239 return false;
240 }
241 }
242 }
243 return true;
244 }
245 return false;
246 }

◆ repr()

template<typename T , class C >
std::string lsst::gauss2d::Image< T, C >::repr ( bool name_keywords,
std::string_view namespace_separator ) const
inlineoverridevirtual

Return a full, callable string representation of this.

Parameters
name_keywordsWhether to prefix arguments with "{name}=", where name is the arg name in the header (as with keyword arguments in Python).
namespace_separatorThe string to use to delimit namespaces, i.e. :: in C++ and . in Python.
Returns
A callable string representation of this, which should return an an identical object to this.
Note
The representation with name_keywords=false must be callable in C++. The representation with name_keywords=true should be callable in Python, if there are any bindings.

Implements lsst::gauss2d::Object.

Definition at line 190 of file image.h.

190 {
191 return type_name_str<C>(false, namespace_separator) + "(" + (name_keywords ? "coordsys=" : "")
192 + _coordsys.repr(name_keywords, namespace_separator) + ", " + (name_keywords ? "n_rows=" : "")
193 + std::to_string(this->get_n_rows()) + ", " + (name_keywords ? "n_cols=" : "")
194 + std::to_string(this->get_n_cols()) + ")";
195 }
std::string repr(bool name_keywords=false, std::string_view namespace_separator=Object::CC_NAMESPACE_SEPARATOR) const override
Return a full, callable string representation of this.

◆ set_value()

template<typename T , class C >
void lsst::gauss2d::Image< T, C >::set_value ( size_t row,
size_t col,
T value )
inline

Definition at line 177 of file image.h.

177{ return self().set_value_impl(row, col, value); }

◆ set_value_impl()

template<typename T , class C >
void lsst::gauss2d::Image< T, C >::set_value_impl ( size_t row,
size_t col,
T value )
inline

Definition at line 178 of file image.h.

178{ self()._get_value(row, col) = value; }

◆ set_value_unchecked()

template<typename T , class C >
void lsst::gauss2d::Image< T, C >::set_value_unchecked ( size_t row,
size_t col,
T value )
inline

Definition at line 179 of file image.h.

179 {
180 self().set_value_unchecked_impl(row, col, value);
181 }

◆ set_value_unchecked_impl()

template<typename T , class C >
void lsst::gauss2d::Image< T, C >::set_value_unchecked_impl ( size_t row,
size_t col,
T value )
inline

Definition at line 182 of file image.h.

182 {
183 self()._get_value_unchecked(row, col) = value;
184 }

◆ shape()

template<typename T , class C >
std::array< size_t, 2 > lsst::gauss2d::Image< T, C >::shape ( ) const
inline

Definition at line 186 of file image.h.

186{ return {this->get_n_rows(), this->get_n_cols()}; }

◆ size()

template<typename T , class C >
size_t lsst::gauss2d::Image< T, C >::size ( ) const
inline

Definition at line 188 of file image.h.

188{ return this->get_n_rows() * this->get_n_cols(); };

◆ str()

template<typename T , class C >
std::string lsst::gauss2d::Image< T, C >::str ( ) const
inlineoverridevirtual

Return a brief, human-readable string representation of this.

Implements lsst::gauss2d::Object.

Definition at line 197 of file image.h.

197 {
198 return type_name_str<C>(true) + "(coordsys=" + _coordsys.str() + ", n_rows="
199 + std::to_string(this->get_n_rows()) + ", n_cols=" + std::to_string(this->get_n_cols()) + ")";
200 }
std::string str() const override
Return a brief, human-readable string representation of this.

Member Data Documentation

◆ _value_default

template<typename T , class C >
constexpr T lsst::gauss2d::Image< T, C >::_value_default = 0
staticconstexpr

Definition at line 120 of file image.h.

◆ CC_NAMESPACE_SEPARATOR

constexpr std::string_view lsst::gauss2d::Object::CC_NAMESPACE_SEPARATOR = "::"
staticconstexprinherited

The C++ namespace separator.

Definition at line 45 of file object.h.

◆ NULL_STR_GENERAL

constexpr std::string_view lsst::gauss2d::Object::NULL_STR_GENERAL = "None"
staticconstexprinherited

Definition at line 46 of file object.h.

◆ PY_NAMESPACE_SEPARATOR

constexpr std::string_view lsst::gauss2d::Object::PY_NAMESPACE_SEPARATOR = "."
staticconstexprinherited

Definition at line 47 of file object.h.


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