Classes | Typedefs | Functions
CommonCwiseUnaryOps.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  CastXpr< NewType >
 

Typedefs

typedef internal::conditional< NumTraits< Scalar >::IsComplex, const CwiseUnaryOp< internal::scalar_conjugate_op< Scalar >, const Derived >, const Derived & >::type ConjugateReturnType
 
typedef CwiseUnaryOp< internal::scalar_imag_op< Scalar >, const Derived > ImagReturnType
 
typedef CwiseUnaryOp< internal::scalar_opposite_op< Scalar >, const Derived > NegativeReturnType
 
typedef CwiseUnaryView< internal::scalar_imag_ref_op< Scalar >, Derived > NonConstImagReturnType
 
typedef internal::conditional< NumTraits< Scalar >::IsComplex, CwiseUnaryView< internal::scalar_real_ref_op< Scalar >, Derived >, Derived & >::type NonConstRealReturnType
 
typedef internal::conditional< NumTraits< Scalar >::IsComplex, const CwiseUnaryOp< internal::scalar_real_op< Scalar >, const Derived >, const Derived & >::type RealReturnType
 

Functions

template<typename NewType >
EIGEN_DEVICE_FUNC CastXpr< NewType >::Type cast () const
 
EIGEN_DEVICE_FUNC ConjugateReturnType conjugate () const
 
template<bool Cond>
EIGEN_DEVICE_FUNC internal::conditional< Cond, ConjugateReturnType, const Derived & >::type conjugateIf () const
 
const EIGEN_DEVICE_FUNC ImagReturnType imag () const
 
const EIGEN_DEVICE_FUNC NegativeReturnType operator- () const
 
EIGEN_DEVICE_FUNC RealReturnType real () const
 
template<typename CustomUnaryOp >
const EIGEN_DEVICE_FUNC CwiseUnaryOp< CustomUnaryOp, const Derived > unaryExpr (const CustomUnaryOp &func=CustomUnaryOp()) const
 Apply a unary operator coefficient-wise. More...
 
template<typename CustomViewOp >
const EIGEN_DEVICE_FUNC CwiseUnaryView< CustomViewOp, const Derived > unaryViewExpr (const CustomViewOp &func=CustomViewOp()) const
 

Typedef Documentation

◆ ConjugateReturnType

typedef internal::conditional<NumTraits<Scalar>::IsComplex, const CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>, const Derived>, const Derived& >::type ConjugateReturnType

Definition at line 19 of file CommonCwiseUnaryOps.h.

◆ ImagReturnType

typedef CwiseUnaryOp<internal::scalar_imag_op<Scalar>, const Derived> ImagReturnType

Definition at line 31 of file CommonCwiseUnaryOps.h.

◆ NegativeReturnType

typedef CwiseUnaryOp<internal::scalar_opposite_op<Scalar>, const Derived> NegativeReturnType

Definition at line 35 of file CommonCwiseUnaryOps.h.

◆ NonConstImagReturnType

typedef CwiseUnaryView<internal::scalar_imag_ref_op<Scalar>, Derived> NonConstImagReturnType

Definition at line 33 of file CommonCwiseUnaryOps.h.

◆ NonConstRealReturnType

typedef internal::conditional<NumTraits<Scalar>::IsComplex, CwiseUnaryView<internal::scalar_real_ref_op<Scalar>, Derived>, Derived& >::type NonConstRealReturnType

Definition at line 29 of file CommonCwiseUnaryOps.h.

◆ RealReturnType

typedef internal::conditional<NumTraits<Scalar>::IsComplex, const CwiseUnaryOp<internal::scalar_real_op<Scalar>, const Derived>, const Derived& >::type RealReturnType

Definition at line 24 of file CommonCwiseUnaryOps.h.

Function Documentation

◆ cast()

template<typename NewType >
EIGEN_DEVICE_FUNC CastXpr<NewType>::Type cast ( ) const
Returns
an expression of *this with the Scalar type casted to NewScalar.

The template parameter NewScalar is the type we are casting the scalars to.

See also
class CwiseUnaryOp

Definition at line 62 of file CommonCwiseUnaryOps.h.

◆ conjugate()

EIGEN_DEVICE_FUNC ConjugateReturnType conjugate ( ) const
inline
Returns
an expression of the complex conjugate of *this.
See also
Math functions, MatrixBase::adjoint()

Definition at line 74 of file CommonCwiseUnaryOps.h.

◆ conjugateIf()

template<bool Cond>
EIGEN_DEVICE_FUNC internal::conditional<Cond,ConjugateReturnType,const Derived&>::type conjugateIf ( ) const
inline
Returns
an expression of the complex conjugate of *this if Cond==true, returns derived() otherwise.
See also
conjugate()

Definition at line 87 of file CommonCwiseUnaryOps.h.

◆ imag()

Returns
an read-only expression of the imaginary part of *this.
See also
real()
Returns
a non const expression of the imaginary part of *this.
See also
real()

Definition at line 109 of file CommonCwiseUnaryOps.h.

◆ operator-()

const EIGEN_DEVICE_FUNC NegativeReturnType operator- ( ) const
inline
Returns
an expression of the opposite of *this

Definition at line 45 of file CommonCwiseUnaryOps.h.

◆ real()

Returns
a read-only expression of the real part of *this.
See also
imag()
Returns
a non const expression of the real part of *this.
See also
imag()

Definition at line 100 of file CommonCwiseUnaryOps.h.

◆ unaryExpr()

template<typename CustomUnaryOp >
const EIGEN_DEVICE_FUNC CwiseUnaryOp<CustomUnaryOp, const Derived> unaryExpr ( const CustomUnaryOp &  func = CustomUnaryOp()) const
inline

Apply a unary operator coefficient-wise.

Parameters
[in]funcFunctor implementing the unary operator
Template Parameters
CustomUnaryOpType of func
Returns
An expression of a custom coefficient-wise unary operator func of *this

The function ptr_fun() from the C++ standard library can be used to make functors out of normal functions.

Example:

#include <Eigen/Core>
#include <iostream>
using namespace Eigen;
using namespace std;
// define function to be applied coefficient-wise
double ramp(double x)
{
if (x > 0)
return x;
else
return 0;
}
int main(int, char**)
{
Matrix4d m1 = Matrix4d::Random();
cout << m1 << endl << "becomes: " << endl << m1.unaryExpr(ptr_fun(ramp)) << endl;
return 0;
}

Output:

Genuine functors allow for more possibilities, for instance it may contain a state.

Example:

#include <Eigen/Core>
#include <iostream>
using namespace Eigen;
using namespace std;
// define a custom template unary functor
template<typename Scalar>
struct CwiseClampOp {
CwiseClampOp(const Scalar& inf, const Scalar& sup) : m_inf(inf), m_sup(sup) {}
const Scalar operator()(const Scalar& x) const { return x<m_inf ? m_inf : (x>m_sup ? m_sup : x); }
Scalar m_inf, m_sup;
};
int main(int, char**)
{
Matrix4d m1 = Matrix4d::Random();
cout << m1 << endl << "becomes: " << endl << m1.unaryExpr(CwiseClampOp<double>(-0.5,0.5)) << endl;
return 0;
}

Output:

 
See also
unaryViewExpr, binaryExpr, class CwiseUnaryOp

Definition at line 135 of file CommonCwiseUnaryOps.h.

◆ unaryViewExpr()

template<typename CustomViewOp >
const EIGEN_DEVICE_FUNC CwiseUnaryView<CustomViewOp, const Derived> unaryViewExpr ( const CustomViewOp &  func = CustomViewOp()) const
inline
Returns
an expression of a custom coefficient-wise unary operator func of *this

The template parameter CustomUnaryOp is the type of the functor of the custom unary operator.

Example:

#include <Eigen/Core>
#include <iostream>
using namespace Eigen;
using namespace std;
// define a custom template unary functor
template<typename Scalar>
struct CwiseClampOp {
CwiseClampOp(const Scalar& inf, const Scalar& sup) : m_inf(inf), m_sup(sup) {}
const Scalar operator()(const Scalar& x) const { return x<m_inf ? m_inf : (x>m_sup ? m_sup : x); }
Scalar m_inf, m_sup;
};
int main(int, char**)
{
Matrix4d m1 = Matrix4d::Random();
cout << m1 << endl << "becomes: " << endl << m1.unaryExpr(CwiseClampOp<double>(-0.5,0.5)) << endl;
return 0;
}

Output:

 
See also
unaryExpr, binaryExpr class CwiseUnaryOp

Definition at line 156 of file CommonCwiseUnaryOps.h.

Eigen
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
x
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition: gnuplot_common_settings.hh:12
m1
Matrix3d m1
Definition: IOFormat.cpp:2
main
int main(int argc, char **argv)
Definition: cmake/example_cmake_find_gtsam/main.cpp:63
operator()
internal::enable_if< internal::valid_indexed_view_overload< RowIndices, ColIndices >::value &&internal::traits< typename EIGEN_INDEXED_VIEW_METHOD_TYPE< RowIndices, ColIndices >::type >::ReturnAsIndexedView, typename EIGEN_INDEXED_VIEW_METHOD_TYPE< RowIndices, ColIndices >::type >::type operator()(const RowIndices &rowIndices, const ColIndices &colIndices) EIGEN_INDEXED_VIEW_METHOD_CONST
Definition: IndexedViewMethods.h:73
std
Definition: BFloat16.h:88
inf
static double inf
Definition: testMatrix.cpp:31
ramp
double ramp(double x)
Definition: class_CwiseUnaryOp_ptrfun.cpp:7
Scalar
SCALAR Scalar
Definition: bench_gemm.cpp:46
CwiseClampOp
Definition: class_CwiseUnaryOp.cpp:8


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:18:28