LSST Applications g063fba187b+cac8b7c890,g0f08755f38+6aee506743,g1653933729+a8ce1bb630,g168dd56ebc+a8ce1bb630,g1a2382251a+b4475c5878,g1dcb35cd9c+8f9bc1652e,g20f6ffc8e0+6aee506743,g217e2c1bcf+73dee94bd0,g28da252d5a+1f19c529b9,g2bbee38e9b+3f2625acfc,g2bc492864f+3f2625acfc,g3156d2b45e+6e55a43351,g32e5bea42b+1bb94961c2,g347aa1857d+3f2625acfc,g35bb328faa+a8ce1bb630,g3a166c0a6a+3f2625acfc,g3e281a1b8c+c5dd892a6c,g3e8969e208+a8ce1bb630,g414038480c+5927e1bc1e,g41af890bb2+8a9e676b2a,g7af13505b9+809c143d88,g80478fca09+6ef8b1810f,g82479be7b0+f568feb641,g858d7b2824+6aee506743,g89c8672015+f4add4ffd5,g9125e01d80+a8ce1bb630,ga5288a1d22+2903d499ea,gb58c049af0+d64f4d3760,gc28159a63d+3f2625acfc,gcab2d0539d+b12535109e,gcf0d15dbbd+46a3f46ba9,gda6a2b7d83+46a3f46ba9,gdaeeff99f8+1711a396fd,ge79ae78c31+3f2625acfc,gef2f8181fd+0a71e47438,gf0baf85859+c1f95f4921,gfa517265be+6aee506743,gfa999e8aa5+17cd334064,w.2024.51
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: