From 3f97399decacad0cc5a4330ca4b46e65527485ed Mon Sep 17 00:00:00 2001 From: Matthias Wittgen Date: Tue, 6 Jun 2023 17:59:48 -0700 Subject: [PATCH] Add enable if clauses to operator templates, clean up code --- include/lsst/afw/image/Pixel.h | 99 +++++++++------------------------- 1 file changed, 26 insertions(+), 73 deletions(-) diff --git a/include/lsst/afw/image/Pixel.h b/include/lsst/afw/image/Pixel.h index 2ec0e6867..7e46e1f50 100644 --- a/include/lsst/afw/image/Pixel.h +++ b/include/lsst/afw/image/Pixel.h @@ -88,7 +88,7 @@ class SinglePixel : public detail::MaskedImagePixel_tag { SinglePixel(rhsExpr const& rhs, // ensure this ctor isn't invoked for simple numeric types, which should use // the overload above. - typename std::enable_if::value, void*>::type dummy = nullptr) + typename std::enable_if_t, void*> = nullptr) : _image(rhs.image()), _mask(rhs.mask()), _variance(rhs.variance()) {} ImagePixelT image() const { return _image; } @@ -123,14 +123,7 @@ struct PixelTypeTraits { } }; -/// Specialization for a %pixel of a MaskedImage -template -struct PixelTypeTraits > { - using PixelT = SinglePixel<_ImagePixelT, _MaskPixelT, _VariancePixelT>; - /// The quantity to use when a pixel value is undefined - static inline const PixelT padValue() { return PixelT(); } -}; /** Return a SinglePixel * @@ -152,10 +145,6 @@ class Pixel : public detail::MaskedImagePixel_tag { using VariancePixelT = _VariancePixelT; /// Construct a Pixel from references to its image/mask/variance components -#if 0 - Pixel(ImagePixelT& image, MaskPixelT& mask, VariancePixelT& variance) : - _image(image), _mask(mask), _variance(variance) {} -#else // // This constructor casts away const. This should be fixed by making const Pixels. // @@ -163,7 +152,6 @@ class Pixel : public detail::MaskedImagePixel_tag { : _image(const_cast(image)), _mask(const_cast(mask)), _variance(const_cast(variance)) {} -#endif Pixel(SinglePixel& rhs) : _image(rhs._image), _mask(rhs._mask), _variance(rhs._variance) {} @@ -400,26 +388,6 @@ struct variance_plus { T1 operator()(T1 const&, T1 const&, T1 const& vx) const { return vx; } }; -/** The variance of the sum of a pair of correlated pixels - * - * The covariance is modelled as alpha*sqrt(var_x*var_y) - * - * @note We provide a single-operand version for when the right-hand-side of an expression is a scalar, not a - * masked pixel, - */ -template -struct variance_plus_covar { - variance_plus_covar(double alpha = 0) : _alpha(alpha) {} - - T1 operator()(T1 const&, T1 const&, T1 const& vx, T1 const& vy) const { - return vx + vy + 2 * _alpha * sqrt(vx * vy); - } - T1 operator()(T1 const&, T1 const&, T1 const& vx) const { return vx; } - -private: - double _alpha; -}; - /// Class for representing Unary operations template class UnaryExpr { @@ -523,9 +491,7 @@ class BinaryExpr final { /// Template for -e1 template -UnaryExpr::ImagePixelT>, - noop::MaskPixelT>, noop::VariancePixelT> > -operator-(ExprT1 e1) { +auto operator-(ExprT1 e1) { return UnaryExpr::ImagePixelT>, noop::MaskPixelT>, noop::VariancePixelT> >(e1); @@ -539,31 +505,28 @@ struct is_specialization : std::false_type {}; template