LSSTApplications  12.1-5-gbdcc3ab+2,15.0+13,15.0+26,15.0-1-g19261fa+17,15.0-1-g60afb23+26,15.0-1-g615e0bb+18,15.0-1-g788a293+26,15.0-1-ga91101e+26,15.0-1-gae1598d+12,15.0-1-gd076f1f+24,15.0-1-gdf18595+5,15.0-1-gf4f1c34+12,15.0-11-g7db6e543+4,15.0-12-g3681e7a+4,15.0-15-gc15de322,15.0-16-g83b84f4,15.0-2-g100d730+19,15.0-2-g1f9c9cf+4,15.0-2-g8aea5f4+1,15.0-2-gf38729e+21,15.0-29-ga12a2b06e,15.0-3-g11fe1a0+14,15.0-3-g707930d+3,15.0-3-g9103c06+12,15.0-3-gd3cbb57+3,15.0-4-g2d82b59,15.0-4-g535e784+10,15.0-4-g92ca6c3+4,15.0-4-gf906033+2,15.0-5-g23e394c+14,15.0-5-g4be42a9,15.0-6-g69628aa,15.0-6-g86e3f3d+1,15.0-6-gfa9b38f+4,15.0-7-g949993c+3,15.0-8-g67a62d3+1,15.0-8-gcf05001+1,15.0-9-g1e7c341+1,w.2018.21
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Related Functions | List of all members
lsst::afw::geom::CoordinateExpr< N > Class Template Reference

A boolean coordinate. More...

#include <CoordinateExpr.h>

Inheritance diagram for lsst::afw::geom::CoordinateExpr< N >:
lsst::afw::geom::CoordinateBase< CoordinateExpr< N >, bool, N >

Public Types

typedef bool Element
 
typedef Eigen::Matrix< bool, N, 1, Eigen::DontAlign > EigenVector
 

Public Member Functions

 CoordinateExpr (bool val=false)
 Construct a CoordinateExpr with all elements set to the same scalar value. More...
 
template<typename Vector >
 CoordinateExpr (Eigen::MatrixBase< Vector > const &vector)
 Construct a CoordinateExpr from an Eigen vector. More...
 
 CoordinateExpr (CoordinateExpr const &)=default
 
 CoordinateExpr (CoordinateExpr &&)=default
 
CoordinateExproperator= (CoordinateExpr const &)=default
 
CoordinateExproperator= (CoordinateExpr &&)=default
 
 ~CoordinateExpr ()=default
 
bool & operator[] (int n)
 
bool const & operator[] (int n) const
 
bool & coeffRef (int n)
 
bool const & coeffRef (int n) const
 
EigenVector const & asEigen () const
 Return a fixed-size Eigen representation of the coordinate object. More...
 
Logical operators

These operators do not provide interoperability with scalars.

CoordinateExpr and_ (CoordinateExpr const &rhs) const
 
CoordinateExpr or_ (CoordinateExpr const &rhs) const
 
CoordinateExpr not_ () const
 

Static Public Attributes

static int const dimensions
 

Protected Member Functions

void _swap (CoordinateBase &other)
 

Protected Attributes

EigenVector _vector
 

Related Functions

(Note that these are not member functions.)

bool allclose (CoordinateBase< CoordinateExpr< N >, bool, N > const &a, CoordinateBase< CoordinateExpr< N >, bool, N > const &b, bool rtol=static_cast< bool >(1E-5), bool atol=static_cast< bool >(1E-8))
 Floating-point comparison with tolerance. More...
 

Detailed Description

template<int N>
class lsst::afw::geom::CoordinateExpr< N >

A boolean coordinate.

CoordinateExpr is intended to be used as a temporary in coordinate comparisons:

Point2D a(3.5,1.2);
Point2D b(-1.5,4.3);
std::cout << all(a.lt(b)) << std::endl;  // false
std::cout << any(a.lt(b)) << std::endl;  // true

CoordinateExpr is not a true lazy-evaluation expression template, as that seems unnecessary when the object is typically only two bools large (smaller than the raw pointers necessary to implement a lazy solution). The consequence is that there's no short-circuiting of logical operators, but I don't think that will even remotely matter for most use cases. The any() and all() functions do support short-circuiting.

Definition at line 54 of file CoordinateExpr.h.

Member Typedef Documentation

◆ EigenVector

typedef Eigen::Matrix<bool , N, 1, Eigen::DontAlign> lsst::afw::geom::CoordinateBase< CoordinateExpr< N > , bool , N >::EigenVector
inherited

Definition at line 56 of file CoordinateBase.h.

◆ Element

typedef bool lsst::afw::geom::CoordinateBase< CoordinateExpr< N > , bool , N >::Element
inherited

Definition at line 54 of file CoordinateBase.h.

Constructor & Destructor Documentation

◆ CoordinateExpr() [1/4]

template<int N>
lsst::afw::geom::CoordinateExpr< N >::CoordinateExpr ( bool  val = false)
inlineexplicit

Construct a CoordinateExpr with all elements set to the same scalar value.

Definition at line 59 of file CoordinateExpr.h.

59 : Super(val) {}
ImageT val
Definition: CR.cc:158

◆ CoordinateExpr() [2/4]

template<int N>
template<typename Vector >
lsst::afw::geom::CoordinateExpr< N >::CoordinateExpr ( Eigen::MatrixBase< Vector > const &  vector)
inlineexplicit

Construct a CoordinateExpr from an Eigen vector.

Definition at line 63 of file CoordinateExpr.h.

63 : Super(vector) {}

◆ CoordinateExpr() [3/4]

template<int N>
lsst::afw::geom::CoordinateExpr< N >::CoordinateExpr ( CoordinateExpr< N > const &  )
default

◆ CoordinateExpr() [4/4]

template<int N>
lsst::afw::geom::CoordinateExpr< N >::CoordinateExpr ( CoordinateExpr< N > &&  )
default

◆ ~CoordinateExpr()

template<int N>
lsst::afw::geom::CoordinateExpr< N >::~CoordinateExpr ( )
default

Member Function Documentation

◆ _swap()

void lsst::afw::geom::CoordinateBase< CoordinateExpr< N > , bool , N >::_swap ( CoordinateBase< CoordinateExpr< N >, bool, N > &  other)
inlineprotectedinherited

Definition at line 93 of file CoordinateBase.h.

93 { _vector.swap(other._vector); }
ItemVariant const * other
Definition: Schema.cc:55

◆ and_()

template<int N>
CoordinateExpr< N > lsst::afw::geom::CoordinateExpr< N >::and_ ( CoordinateExpr< N > const &  rhs) const

Definition at line 32 of file CoordinateExpr.cc.

32  {
33  CoordinateExpr r(*this);
34  for (int n = 0; n < N; ++n) {
35  if (!other[n]) r[n] = false;
36  }
37  return r;
38 }
CoordinateExpr(bool val=false)
Construct a CoordinateExpr with all elements set to the same scalar value.
ItemVariant const * other
Definition: Schema.cc:55

◆ asEigen()

EigenVector const& lsst::afw::geom::CoordinateBase< CoordinateExpr< N > , bool , N >::asEigen ( ) const
inlineinherited

Return a fixed-size Eigen representation of the coordinate object.

The fact that this returns by const reference rather than by value should not be considered part of the API; this is merely an optimization enabled by the implementation.

Definition at line 75 of file CoordinateBase.h.

◆ coeffRef() [1/2]

bool & lsst::afw::geom::CoordinateBase< CoordinateExpr< N > , bool , N >::coeffRef ( int  n)
inlineinherited

Definition at line 66 of file CoordinateBase.h.

◆ coeffRef() [2/2]

bool const& lsst::afw::geom::CoordinateBase< CoordinateExpr< N > , bool , N >::coeffRef ( int  n) const
inlineinherited

◆ not_()

template<int N>
CoordinateExpr< N > lsst::afw::geom::CoordinateExpr< N >::not_ ( ) const

Definition at line 50 of file CoordinateExpr.cc.

50  {
52  for (int n = 0; n < N; ++n) {
53  if (!this->operator[](n)) r[n] = true;
54  }
55  return r;
56 }
CoordinateExpr(bool val=false)
Construct a CoordinateExpr with all elements set to the same scalar value.

◆ operator=() [1/2]

template<int N>
CoordinateExpr& lsst::afw::geom::CoordinateExpr< N >::operator= ( CoordinateExpr< N > const &  )
default

◆ operator=() [2/2]

template<int N>
CoordinateExpr& lsst::afw::geom::CoordinateExpr< N >::operator= ( CoordinateExpr< N > &&  )
default

◆ operator[]() [1/2]

bool & lsst::afw::geom::CoordinateBase< CoordinateExpr< N > , bool , N >::operator[] ( int  n)
inlineinherited

Definition at line 64 of file CoordinateBase.h.

◆ operator[]() [2/2]

bool const& lsst::afw::geom::CoordinateBase< CoordinateExpr< N > , bool , N >::operator[] ( int  n) const
inlineinherited

Definition at line 65 of file CoordinateBase.h.

65 { return const_cast<EigenVector&>(_vector)[n]; }
Eigen::Matrix< bool, N, 1, Eigen::DontAlign > EigenVector

◆ or_()

template<int N>
CoordinateExpr< N > lsst::afw::geom::CoordinateExpr< N >::or_ ( CoordinateExpr< N > const &  rhs) const

Definition at line 41 of file CoordinateExpr.cc.

41  {
42  CoordinateExpr r(*this);
43  for (int n = 0; n < N; ++n) {
44  if (other[n]) r[n] = true;
45  }
46  return r;
47 }
CoordinateExpr(bool val=false)
Construct a CoordinateExpr with all elements set to the same scalar value.
ItemVariant const * other
Definition: Schema.cc:55

Friends And Related Function Documentation

◆ allclose()

bool allclose ( CoordinateBase< CoordinateExpr< N > , bool , N > const &  a,
CoordinateBase< CoordinateExpr< N > , bool , N > const &  b,
bool  rtol = static_cast<T>(1E-5),
bool  atol = static_cast<T>(1E-8) 
)
related

Floating-point comparison with tolerance.

Interface, naming, and default tolerances matches Numpy.

Definition at line 32 of file CoordinateBase.cc.

33  {
34  Eigen::Array<T, N, 1> diff = (a.asEigen().array() - b.asEigen().array()).abs();
35  Eigen::Array<T, N, 1> rhs = (0.5 * (a.asEigen().array() + b.asEigen().array())).abs();
36  rhs *= rtol;
37  rhs += atol;
38  return (diff <= rhs).all();
39 }
T atol(T... args)
Angle abs(Angle const &a)
Definition: Angle.h:106
table::Key< int > b
table::Key< int > a

Member Data Documentation

◆ _vector

EigenVector lsst::afw::geom::CoordinateBase< CoordinateExpr< N > , bool , N >::_vector
protectedinherited

Definition at line 94 of file CoordinateBase.h.

◆ dimensions

int const lsst::afw::geom::CoordinateBase< CoordinateExpr< N > , bool , N >::dimensions
staticinherited

Definition at line 55 of file CoordinateBase.h.


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