xref: /aosp_15_r20/external/eigen/Eigen/src/plugins/ArrayCwiseUnaryOps.h (revision bf2c37156dfe67e5dfebd6d394bad8b2ab5804d4)
1*bf2c3715SXin Li 
2*bf2c3715SXin Li 
3*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_abs_op<Scalar>, const Derived> AbsReturnType;
4*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_arg_op<Scalar>, const Derived> ArgReturnType;
5*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_abs2_op<Scalar>, const Derived> Abs2ReturnType;
6*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_sqrt_op<Scalar>, const Derived> SqrtReturnType;
7*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_rsqrt_op<Scalar>, const Derived> RsqrtReturnType;
8*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_sign_op<Scalar>, const Derived> SignReturnType;
9*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_inverse_op<Scalar>, const Derived> InverseReturnType;
10*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_boolean_not_op<Scalar>, const Derived> BooleanNotReturnType;
11*bf2c3715SXin Li 
12*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_exp_op<Scalar>, const Derived> ExpReturnType;
13*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_expm1_op<Scalar>, const Derived> Expm1ReturnType;
14*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_log_op<Scalar>, const Derived> LogReturnType;
15*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_log1p_op<Scalar>, const Derived> Log1pReturnType;
16*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_log10_op<Scalar>, const Derived> Log10ReturnType;
17*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_log2_op<Scalar>, const Derived> Log2ReturnType;
18*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_cos_op<Scalar>, const Derived> CosReturnType;
19*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_sin_op<Scalar>, const Derived> SinReturnType;
20*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_tan_op<Scalar>, const Derived> TanReturnType;
21*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_acos_op<Scalar>, const Derived> AcosReturnType;
22*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_asin_op<Scalar>, const Derived> AsinReturnType;
23*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_atan_op<Scalar>, const Derived> AtanReturnType;
24*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_tanh_op<Scalar>, const Derived> TanhReturnType;
25*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_logistic_op<Scalar>, const Derived> LogisticReturnType;
26*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_sinh_op<Scalar>, const Derived> SinhReturnType;
27*bf2c3715SXin Li #if EIGEN_HAS_CXX11_MATH
28*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_atanh_op<Scalar>, const Derived> AtanhReturnType;
29*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_asinh_op<Scalar>, const Derived> AsinhReturnType;
30*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_acosh_op<Scalar>, const Derived> AcoshReturnType;
31*bf2c3715SXin Li #endif
32*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_cosh_op<Scalar>, const Derived> CoshReturnType;
33*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_square_op<Scalar>, const Derived> SquareReturnType;
34*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_cube_op<Scalar>, const Derived> CubeReturnType;
35*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_round_op<Scalar>, const Derived> RoundReturnType;
36*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_rint_op<Scalar>, const Derived> RintReturnType;
37*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_floor_op<Scalar>, const Derived> FloorReturnType;
38*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_ceil_op<Scalar>, const Derived> CeilReturnType;
39*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_isnan_op<Scalar>, const Derived> IsNaNReturnType;
40*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_isinf_op<Scalar>, const Derived> IsInfReturnType;
41*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_isfinite_op<Scalar>, const Derived> IsFiniteReturnType;
42*bf2c3715SXin Li 
43*bf2c3715SXin Li /** \returns an expression of the coefficient-wise absolute value of \c *this
44*bf2c3715SXin Li   *
45*bf2c3715SXin Li   * Example: \include Cwise_abs.cpp
46*bf2c3715SXin Li   * Output: \verbinclude Cwise_abs.out
47*bf2c3715SXin Li   *
48*bf2c3715SXin Li   * \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_abs">Math functions</a>, abs2()
49*bf2c3715SXin Li   */
50*bf2c3715SXin Li EIGEN_DEVICE_FUNC
51*bf2c3715SXin Li EIGEN_STRONG_INLINE const AbsReturnType
abs()52*bf2c3715SXin Li abs() const
53*bf2c3715SXin Li {
54*bf2c3715SXin Li   return AbsReturnType(derived());
55*bf2c3715SXin Li }
56*bf2c3715SXin Li 
57*bf2c3715SXin Li /** \returns an expression of the coefficient-wise phase angle of \c *this
58*bf2c3715SXin Li   *
59*bf2c3715SXin Li   * Example: \include Cwise_arg.cpp
60*bf2c3715SXin Li   * Output: \verbinclude Cwise_arg.out
61*bf2c3715SXin Li   *
62*bf2c3715SXin Li   * \sa abs()
63*bf2c3715SXin Li   */
64*bf2c3715SXin Li EIGEN_DEVICE_FUNC
65*bf2c3715SXin Li EIGEN_STRONG_INLINE const ArgReturnType
arg()66*bf2c3715SXin Li arg() const
67*bf2c3715SXin Li {
68*bf2c3715SXin Li   return ArgReturnType(derived());
69*bf2c3715SXin Li }
70*bf2c3715SXin Li 
71*bf2c3715SXin Li /** \returns an expression of the coefficient-wise squared absolute value of \c *this
72*bf2c3715SXin Li   *
73*bf2c3715SXin Li   * Example: \include Cwise_abs2.cpp
74*bf2c3715SXin Li   * Output: \verbinclude Cwise_abs2.out
75*bf2c3715SXin Li   *
76*bf2c3715SXin Li   * \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_abs2">Math functions</a>, abs(), square()
77*bf2c3715SXin Li   */
78*bf2c3715SXin Li EIGEN_DEVICE_FUNC
79*bf2c3715SXin Li EIGEN_STRONG_INLINE const Abs2ReturnType
abs2()80*bf2c3715SXin Li abs2() const
81*bf2c3715SXin Li {
82*bf2c3715SXin Li   return Abs2ReturnType(derived());
83*bf2c3715SXin Li }
84*bf2c3715SXin Li 
85*bf2c3715SXin Li /** \returns an expression of the coefficient-wise exponential of *this.
86*bf2c3715SXin Li   *
87*bf2c3715SXin Li   * This function computes the coefficient-wise exponential. The function MatrixBase::exp() in the
88*bf2c3715SXin Li   * unsupported module MatrixFunctions computes the matrix exponential.
89*bf2c3715SXin Li   *
90*bf2c3715SXin Li   * Example: \include Cwise_exp.cpp
91*bf2c3715SXin Li   * Output: \verbinclude Cwise_exp.out
92*bf2c3715SXin Li   *
93*bf2c3715SXin Li   * \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_exp">Math functions</a>, pow(), log(), sin(), cos()
94*bf2c3715SXin Li   */
95*bf2c3715SXin Li EIGEN_DEVICE_FUNC
96*bf2c3715SXin Li inline const ExpReturnType
exp()97*bf2c3715SXin Li exp() const
98*bf2c3715SXin Li {
99*bf2c3715SXin Li   return ExpReturnType(derived());
100*bf2c3715SXin Li }
101*bf2c3715SXin Li 
102*bf2c3715SXin Li /** \returns an expression of the coefficient-wise exponential of *this minus 1.
103*bf2c3715SXin Li   *
104*bf2c3715SXin Li   * In exact arithmetic, \c x.expm1() is equivalent to \c x.exp() - 1,
105*bf2c3715SXin Li   * however, with finite precision, this function is much more accurate when \c x is close to zero.
106*bf2c3715SXin Li   *
107*bf2c3715SXin Li   * \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_expm1">Math functions</a>, exp()
108*bf2c3715SXin Li   */
109*bf2c3715SXin Li EIGEN_DEVICE_FUNC
110*bf2c3715SXin Li inline const Expm1ReturnType
expm1()111*bf2c3715SXin Li expm1() const
112*bf2c3715SXin Li {
113*bf2c3715SXin Li   return Expm1ReturnType(derived());
114*bf2c3715SXin Li }
115*bf2c3715SXin Li 
116*bf2c3715SXin Li /** \returns an expression of the coefficient-wise logarithm of *this.
117*bf2c3715SXin Li   *
118*bf2c3715SXin Li   * This function computes the coefficient-wise logarithm. The function MatrixBase::log() in the
119*bf2c3715SXin Li   * unsupported module MatrixFunctions computes the matrix logarithm.
120*bf2c3715SXin Li   *
121*bf2c3715SXin Li   * Example: \include Cwise_log.cpp
122*bf2c3715SXin Li   * Output: \verbinclude Cwise_log.out
123*bf2c3715SXin Li   *
124*bf2c3715SXin Li   * \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_log">Math functions</a>, log()
125*bf2c3715SXin Li   */
126*bf2c3715SXin Li EIGEN_DEVICE_FUNC
127*bf2c3715SXin Li inline const LogReturnType
log()128*bf2c3715SXin Li log() const
129*bf2c3715SXin Li {
130*bf2c3715SXin Li   return LogReturnType(derived());
131*bf2c3715SXin Li }
132*bf2c3715SXin Li 
133*bf2c3715SXin Li /** \returns an expression of the coefficient-wise logarithm of 1 plus \c *this.
134*bf2c3715SXin Li   *
135*bf2c3715SXin Li   * In exact arithmetic, \c x.log() is equivalent to \c (x+1).log(),
136*bf2c3715SXin Li   * however, with finite precision, this function is much more accurate when \c x is close to zero.
137*bf2c3715SXin Li   *
138*bf2c3715SXin Li   * \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_log1p">Math functions</a>, log()
139*bf2c3715SXin Li   */
140*bf2c3715SXin Li EIGEN_DEVICE_FUNC
141*bf2c3715SXin Li inline const Log1pReturnType
log1p()142*bf2c3715SXin Li log1p() const
143*bf2c3715SXin Li {
144*bf2c3715SXin Li   return Log1pReturnType(derived());
145*bf2c3715SXin Li }
146*bf2c3715SXin Li 
147*bf2c3715SXin Li /** \returns an expression of the coefficient-wise base-10 logarithm of *this.
148*bf2c3715SXin Li   *
149*bf2c3715SXin Li   * This function computes the coefficient-wise base-10 logarithm.
150*bf2c3715SXin Li   *
151*bf2c3715SXin Li   * Example: \include Cwise_log10.cpp
152*bf2c3715SXin Li   * Output: \verbinclude Cwise_log10.out
153*bf2c3715SXin Li   *
154*bf2c3715SXin Li   * \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_log10">Math functions</a>, log()
155*bf2c3715SXin Li   */
156*bf2c3715SXin Li EIGEN_DEVICE_FUNC
157*bf2c3715SXin Li inline const Log10ReturnType
log10()158*bf2c3715SXin Li log10() const
159*bf2c3715SXin Li {
160*bf2c3715SXin Li   return Log10ReturnType(derived());
161*bf2c3715SXin Li }
162*bf2c3715SXin Li 
163*bf2c3715SXin Li /** \returns an expression of the coefficient-wise base-2 logarithm of *this.
164*bf2c3715SXin Li   *
165*bf2c3715SXin Li   * This function computes the coefficient-wise base-2 logarithm.
166*bf2c3715SXin Li   *
167*bf2c3715SXin Li   */
168*bf2c3715SXin Li EIGEN_DEVICE_FUNC
169*bf2c3715SXin Li inline const Log2ReturnType
log2()170*bf2c3715SXin Li log2() const
171*bf2c3715SXin Li {
172*bf2c3715SXin Li   return Log2ReturnType(derived());
173*bf2c3715SXin Li }
174*bf2c3715SXin Li 
175*bf2c3715SXin Li /** \returns an expression of the coefficient-wise square root of *this.
176*bf2c3715SXin Li   *
177*bf2c3715SXin Li   * This function computes the coefficient-wise square root. The function MatrixBase::sqrt() in the
178*bf2c3715SXin Li   * unsupported module MatrixFunctions computes the matrix square root.
179*bf2c3715SXin Li   *
180*bf2c3715SXin Li   * Example: \include Cwise_sqrt.cpp
181*bf2c3715SXin Li   * Output: \verbinclude Cwise_sqrt.out
182*bf2c3715SXin Li   *
183*bf2c3715SXin Li   * \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_sqrt">Math functions</a>, pow(), square()
184*bf2c3715SXin Li   */
185*bf2c3715SXin Li EIGEN_DEVICE_FUNC
186*bf2c3715SXin Li inline const SqrtReturnType
sqrt()187*bf2c3715SXin Li sqrt() const
188*bf2c3715SXin Li {
189*bf2c3715SXin Li   return SqrtReturnType(derived());
190*bf2c3715SXin Li }
191*bf2c3715SXin Li 
192*bf2c3715SXin Li /** \returns an expression of the coefficient-wise inverse square root of *this.
193*bf2c3715SXin Li   *
194*bf2c3715SXin Li   * This function computes the coefficient-wise inverse square root.
195*bf2c3715SXin Li   *
196*bf2c3715SXin Li   * Example: \include Cwise_sqrt.cpp
197*bf2c3715SXin Li   * Output: \verbinclude Cwise_sqrt.out
198*bf2c3715SXin Li   *
199*bf2c3715SXin Li   * \sa pow(), square()
200*bf2c3715SXin Li   */
201*bf2c3715SXin Li EIGEN_DEVICE_FUNC
202*bf2c3715SXin Li inline const RsqrtReturnType
rsqrt()203*bf2c3715SXin Li rsqrt() const
204*bf2c3715SXin Li {
205*bf2c3715SXin Li   return RsqrtReturnType(derived());
206*bf2c3715SXin Li }
207*bf2c3715SXin Li 
208*bf2c3715SXin Li /** \returns an expression of the coefficient-wise signum of *this.
209*bf2c3715SXin Li   *
210*bf2c3715SXin Li   * This function computes the coefficient-wise signum.
211*bf2c3715SXin Li   *
212*bf2c3715SXin Li   * Example: \include Cwise_sign.cpp
213*bf2c3715SXin Li   * Output: \verbinclude Cwise_sign.out
214*bf2c3715SXin Li   *
215*bf2c3715SXin Li   * \sa pow(), square()
216*bf2c3715SXin Li   */
217*bf2c3715SXin Li EIGEN_DEVICE_FUNC
218*bf2c3715SXin Li inline const SignReturnType
sign()219*bf2c3715SXin Li sign() const
220*bf2c3715SXin Li {
221*bf2c3715SXin Li   return SignReturnType(derived());
222*bf2c3715SXin Li }
223*bf2c3715SXin Li 
224*bf2c3715SXin Li 
225*bf2c3715SXin Li /** \returns an expression of the coefficient-wise cosine of *this.
226*bf2c3715SXin Li   *
227*bf2c3715SXin Li   * This function computes the coefficient-wise cosine. The function MatrixBase::cos() in the
228*bf2c3715SXin Li   * unsupported module MatrixFunctions computes the matrix cosine.
229*bf2c3715SXin Li   *
230*bf2c3715SXin Li   * Example: \include Cwise_cos.cpp
231*bf2c3715SXin Li   * Output: \verbinclude Cwise_cos.out
232*bf2c3715SXin Li   *
233*bf2c3715SXin Li   * \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_cos">Math functions</a>, sin(), acos()
234*bf2c3715SXin Li   */
235*bf2c3715SXin Li EIGEN_DEVICE_FUNC
236*bf2c3715SXin Li inline const CosReturnType
cos()237*bf2c3715SXin Li cos() const
238*bf2c3715SXin Li {
239*bf2c3715SXin Li   return CosReturnType(derived());
240*bf2c3715SXin Li }
241*bf2c3715SXin Li 
242*bf2c3715SXin Li 
243*bf2c3715SXin Li /** \returns an expression of the coefficient-wise sine of *this.
244*bf2c3715SXin Li   *
245*bf2c3715SXin Li   * This function computes the coefficient-wise sine. The function MatrixBase::sin() in the
246*bf2c3715SXin Li   * unsupported module MatrixFunctions computes the matrix sine.
247*bf2c3715SXin Li   *
248*bf2c3715SXin Li   * Example: \include Cwise_sin.cpp
249*bf2c3715SXin Li   * Output: \verbinclude Cwise_sin.out
250*bf2c3715SXin Li   *
251*bf2c3715SXin Li   * \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_sin">Math functions</a>, cos(), asin()
252*bf2c3715SXin Li   */
253*bf2c3715SXin Li EIGEN_DEVICE_FUNC
254*bf2c3715SXin Li inline const SinReturnType
sin()255*bf2c3715SXin Li sin() const
256*bf2c3715SXin Li {
257*bf2c3715SXin Li   return SinReturnType(derived());
258*bf2c3715SXin Li }
259*bf2c3715SXin Li 
260*bf2c3715SXin Li /** \returns an expression of the coefficient-wise tan of *this.
261*bf2c3715SXin Li   *
262*bf2c3715SXin Li   * Example: \include Cwise_tan.cpp
263*bf2c3715SXin Li   * Output: \verbinclude Cwise_tan.out
264*bf2c3715SXin Li   *
265*bf2c3715SXin Li   * \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_tan">Math functions</a>, cos(), sin()
266*bf2c3715SXin Li   */
267*bf2c3715SXin Li EIGEN_DEVICE_FUNC
268*bf2c3715SXin Li inline const TanReturnType
tan()269*bf2c3715SXin Li tan() const
270*bf2c3715SXin Li {
271*bf2c3715SXin Li   return TanReturnType(derived());
272*bf2c3715SXin Li }
273*bf2c3715SXin Li 
274*bf2c3715SXin Li /** \returns an expression of the coefficient-wise arc tan of *this.
275*bf2c3715SXin Li   *
276*bf2c3715SXin Li   * Example: \include Cwise_atan.cpp
277*bf2c3715SXin Li   * Output: \verbinclude Cwise_atan.out
278*bf2c3715SXin Li   *
279*bf2c3715SXin Li   * \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_atan">Math functions</a>, tan(), asin(), acos()
280*bf2c3715SXin Li   */
281*bf2c3715SXin Li EIGEN_DEVICE_FUNC
282*bf2c3715SXin Li inline const AtanReturnType
atan()283*bf2c3715SXin Li atan() const
284*bf2c3715SXin Li {
285*bf2c3715SXin Li   return AtanReturnType(derived());
286*bf2c3715SXin Li }
287*bf2c3715SXin Li 
288*bf2c3715SXin Li /** \returns an expression of the coefficient-wise arc cosine of *this.
289*bf2c3715SXin Li   *
290*bf2c3715SXin Li   * Example: \include Cwise_acos.cpp
291*bf2c3715SXin Li   * Output: \verbinclude Cwise_acos.out
292*bf2c3715SXin Li   *
293*bf2c3715SXin Li   * \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_acos">Math functions</a>, cos(), asin()
294*bf2c3715SXin Li   */
295*bf2c3715SXin Li EIGEN_DEVICE_FUNC
296*bf2c3715SXin Li inline const AcosReturnType
acos()297*bf2c3715SXin Li acos() const
298*bf2c3715SXin Li {
299*bf2c3715SXin Li   return AcosReturnType(derived());
300*bf2c3715SXin Li }
301*bf2c3715SXin Li 
302*bf2c3715SXin Li /** \returns an expression of the coefficient-wise arc sine of *this.
303*bf2c3715SXin Li   *
304*bf2c3715SXin Li   * Example: \include Cwise_asin.cpp
305*bf2c3715SXin Li   * Output: \verbinclude Cwise_asin.out
306*bf2c3715SXin Li   *
307*bf2c3715SXin Li   * \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_asin">Math functions</a>, sin(), acos()
308*bf2c3715SXin Li   */
309*bf2c3715SXin Li EIGEN_DEVICE_FUNC
310*bf2c3715SXin Li inline const AsinReturnType
asin()311*bf2c3715SXin Li asin() const
312*bf2c3715SXin Li {
313*bf2c3715SXin Li   return AsinReturnType(derived());
314*bf2c3715SXin Li }
315*bf2c3715SXin Li 
316*bf2c3715SXin Li /** \returns an expression of the coefficient-wise hyperbolic tan of *this.
317*bf2c3715SXin Li   *
318*bf2c3715SXin Li   * Example: \include Cwise_tanh.cpp
319*bf2c3715SXin Li   * Output: \verbinclude Cwise_tanh.out
320*bf2c3715SXin Li   *
321*bf2c3715SXin Li   * \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_tanh">Math functions</a>, tan(), sinh(), cosh()
322*bf2c3715SXin Li   */
323*bf2c3715SXin Li EIGEN_DEVICE_FUNC
324*bf2c3715SXin Li inline const TanhReturnType
tanh()325*bf2c3715SXin Li tanh() const
326*bf2c3715SXin Li {
327*bf2c3715SXin Li   return TanhReturnType(derived());
328*bf2c3715SXin Li }
329*bf2c3715SXin Li 
330*bf2c3715SXin Li /** \returns an expression of the coefficient-wise hyperbolic sin of *this.
331*bf2c3715SXin Li   *
332*bf2c3715SXin Li   * Example: \include Cwise_sinh.cpp
333*bf2c3715SXin Li   * Output: \verbinclude Cwise_sinh.out
334*bf2c3715SXin Li   *
335*bf2c3715SXin Li   * \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_sinh">Math functions</a>, sin(), tanh(), cosh()
336*bf2c3715SXin Li   */
337*bf2c3715SXin Li EIGEN_DEVICE_FUNC
338*bf2c3715SXin Li inline const SinhReturnType
sinh()339*bf2c3715SXin Li sinh() const
340*bf2c3715SXin Li {
341*bf2c3715SXin Li   return SinhReturnType(derived());
342*bf2c3715SXin Li }
343*bf2c3715SXin Li 
344*bf2c3715SXin Li /** \returns an expression of the coefficient-wise hyperbolic cos of *this.
345*bf2c3715SXin Li   *
346*bf2c3715SXin Li   * Example: \include Cwise_cosh.cpp
347*bf2c3715SXin Li   * Output: \verbinclude Cwise_cosh.out
348*bf2c3715SXin Li   *
349*bf2c3715SXin Li   * \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_cosh">Math functions</a>, tanh(), sinh(), cosh()
350*bf2c3715SXin Li   */
351*bf2c3715SXin Li EIGEN_DEVICE_FUNC
352*bf2c3715SXin Li inline const CoshReturnType
cosh()353*bf2c3715SXin Li cosh() const
354*bf2c3715SXin Li {
355*bf2c3715SXin Li   return CoshReturnType(derived());
356*bf2c3715SXin Li }
357*bf2c3715SXin Li 
358*bf2c3715SXin Li #if EIGEN_HAS_CXX11_MATH
359*bf2c3715SXin Li /** \returns an expression of the coefficient-wise inverse hyperbolic tan of *this.
360*bf2c3715SXin Li   *
361*bf2c3715SXin Li   * \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_atanh">Math functions</a>, atanh(), asinh(), acosh()
362*bf2c3715SXin Li   */
363*bf2c3715SXin Li EIGEN_DEVICE_FUNC
364*bf2c3715SXin Li inline const AtanhReturnType
atanh()365*bf2c3715SXin Li atanh() const
366*bf2c3715SXin Li {
367*bf2c3715SXin Li   return AtanhReturnType(derived());
368*bf2c3715SXin Li }
369*bf2c3715SXin Li 
370*bf2c3715SXin Li /** \returns an expression of the coefficient-wise inverse hyperbolic sin of *this.
371*bf2c3715SXin Li   *
372*bf2c3715SXin Li   * \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_asinh">Math functions</a>, atanh(), asinh(), acosh()
373*bf2c3715SXin Li   */
374*bf2c3715SXin Li EIGEN_DEVICE_FUNC
375*bf2c3715SXin Li inline const AsinhReturnType
asinh()376*bf2c3715SXin Li asinh() const
377*bf2c3715SXin Li {
378*bf2c3715SXin Li   return AsinhReturnType(derived());
379*bf2c3715SXin Li }
380*bf2c3715SXin Li 
381*bf2c3715SXin Li /** \returns an expression of the coefficient-wise inverse hyperbolic cos of *this.
382*bf2c3715SXin Li   *
383*bf2c3715SXin Li   * \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_acosh">Math functions</a>, atanh(), asinh(), acosh()
384*bf2c3715SXin Li   */
385*bf2c3715SXin Li EIGEN_DEVICE_FUNC
386*bf2c3715SXin Li inline const AcoshReturnType
acosh()387*bf2c3715SXin Li acosh() const
388*bf2c3715SXin Li {
389*bf2c3715SXin Li   return AcoshReturnType(derived());
390*bf2c3715SXin Li }
391*bf2c3715SXin Li #endif
392*bf2c3715SXin Li 
393*bf2c3715SXin Li /** \returns an expression of the coefficient-wise logistic of *this.
394*bf2c3715SXin Li   */
395*bf2c3715SXin Li EIGEN_DEVICE_FUNC
396*bf2c3715SXin Li inline const LogisticReturnType
logistic()397*bf2c3715SXin Li logistic() const
398*bf2c3715SXin Li {
399*bf2c3715SXin Li   return LogisticReturnType(derived());
400*bf2c3715SXin Li }
401*bf2c3715SXin Li 
402*bf2c3715SXin Li /** \returns an expression of the coefficient-wise inverse of *this.
403*bf2c3715SXin Li   *
404*bf2c3715SXin Li   * Example: \include Cwise_inverse.cpp
405*bf2c3715SXin Li   * Output: \verbinclude Cwise_inverse.out
406*bf2c3715SXin Li   *
407*bf2c3715SXin Li   * \sa operator/(), operator*()
408*bf2c3715SXin Li   */
409*bf2c3715SXin Li EIGEN_DEVICE_FUNC
410*bf2c3715SXin Li inline const InverseReturnType
inverse()411*bf2c3715SXin Li inverse() const
412*bf2c3715SXin Li {
413*bf2c3715SXin Li   return InverseReturnType(derived());
414*bf2c3715SXin Li }
415*bf2c3715SXin Li 
416*bf2c3715SXin Li /** \returns an expression of the coefficient-wise square of *this.
417*bf2c3715SXin Li   *
418*bf2c3715SXin Li   * Example: \include Cwise_square.cpp
419*bf2c3715SXin Li   * Output: \verbinclude Cwise_square.out
420*bf2c3715SXin Li   *
421*bf2c3715SXin Li   * \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_squareE">Math functions</a>, abs2(), cube(), pow()
422*bf2c3715SXin Li   */
423*bf2c3715SXin Li EIGEN_DEVICE_FUNC
424*bf2c3715SXin Li inline const SquareReturnType
square()425*bf2c3715SXin Li square() const
426*bf2c3715SXin Li {
427*bf2c3715SXin Li   return SquareReturnType(derived());
428*bf2c3715SXin Li }
429*bf2c3715SXin Li 
430*bf2c3715SXin Li /** \returns an expression of the coefficient-wise cube of *this.
431*bf2c3715SXin Li   *
432*bf2c3715SXin Li   * Example: \include Cwise_cube.cpp
433*bf2c3715SXin Li   * Output: \verbinclude Cwise_cube.out
434*bf2c3715SXin Li   *
435*bf2c3715SXin Li   * \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_cube">Math functions</a>, square(), pow()
436*bf2c3715SXin Li   */
437*bf2c3715SXin Li EIGEN_DEVICE_FUNC
438*bf2c3715SXin Li inline const CubeReturnType
cube()439*bf2c3715SXin Li cube() const
440*bf2c3715SXin Li {
441*bf2c3715SXin Li   return CubeReturnType(derived());
442*bf2c3715SXin Li }
443*bf2c3715SXin Li 
444*bf2c3715SXin Li /** \returns an expression of the coefficient-wise rint of *this.
445*bf2c3715SXin Li   *
446*bf2c3715SXin Li   * Example: \include Cwise_rint.cpp
447*bf2c3715SXin Li   * Output: \verbinclude Cwise_rint.out
448*bf2c3715SXin Li   *
449*bf2c3715SXin Li   * \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_rint">Math functions</a>, ceil(), floor()
450*bf2c3715SXin Li   */
451*bf2c3715SXin Li EIGEN_DEVICE_FUNC
452*bf2c3715SXin Li inline const RintReturnType
rint()453*bf2c3715SXin Li rint() const
454*bf2c3715SXin Li {
455*bf2c3715SXin Li   return RintReturnType(derived());
456*bf2c3715SXin Li }
457*bf2c3715SXin Li 
458*bf2c3715SXin Li /** \returns an expression of the coefficient-wise round of *this.
459*bf2c3715SXin Li   *
460*bf2c3715SXin Li   * Example: \include Cwise_round.cpp
461*bf2c3715SXin Li   * Output: \verbinclude Cwise_round.out
462*bf2c3715SXin Li   *
463*bf2c3715SXin Li   * \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_round">Math functions</a>, ceil(), floor()
464*bf2c3715SXin Li   */
465*bf2c3715SXin Li EIGEN_DEVICE_FUNC
466*bf2c3715SXin Li inline const RoundReturnType
round()467*bf2c3715SXin Li round() const
468*bf2c3715SXin Li {
469*bf2c3715SXin Li   return RoundReturnType(derived());
470*bf2c3715SXin Li }
471*bf2c3715SXin Li 
472*bf2c3715SXin Li /** \returns an expression of the coefficient-wise floor of *this.
473*bf2c3715SXin Li   *
474*bf2c3715SXin Li   * Example: \include Cwise_floor.cpp
475*bf2c3715SXin Li   * Output: \verbinclude Cwise_floor.out
476*bf2c3715SXin Li   *
477*bf2c3715SXin Li   * \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_floor">Math functions</a>, ceil(), round()
478*bf2c3715SXin Li   */
479*bf2c3715SXin Li EIGEN_DEVICE_FUNC
480*bf2c3715SXin Li inline const FloorReturnType
floor()481*bf2c3715SXin Li floor() const
482*bf2c3715SXin Li {
483*bf2c3715SXin Li   return FloorReturnType(derived());
484*bf2c3715SXin Li }
485*bf2c3715SXin Li 
486*bf2c3715SXin Li /** \returns an expression of the coefficient-wise ceil of *this.
487*bf2c3715SXin Li   *
488*bf2c3715SXin Li   * Example: \include Cwise_ceil.cpp
489*bf2c3715SXin Li   * Output: \verbinclude Cwise_ceil.out
490*bf2c3715SXin Li   *
491*bf2c3715SXin Li   * \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_ceil">Math functions</a>, floor(), round()
492*bf2c3715SXin Li   */
493*bf2c3715SXin Li EIGEN_DEVICE_FUNC
494*bf2c3715SXin Li inline const CeilReturnType
ceil()495*bf2c3715SXin Li ceil() const
496*bf2c3715SXin Li {
497*bf2c3715SXin Li   return CeilReturnType(derived());
498*bf2c3715SXin Li }
499*bf2c3715SXin Li 
500*bf2c3715SXin Li template<int N> struct ShiftRightXpr {
501*bf2c3715SXin Li   typedef CwiseUnaryOp<internal::scalar_shift_right_op<Scalar, N>, const Derived> Type;
502*bf2c3715SXin Li };
503*bf2c3715SXin Li 
504*bf2c3715SXin Li /** \returns an expression of \c *this with the \a Scalar type arithmetically
505*bf2c3715SXin Li   * shifted right by \a N bit positions.
506*bf2c3715SXin Li   *
507*bf2c3715SXin Li   * The template parameter \a N specifies the number of bit positions to shift.
508*bf2c3715SXin Li   *
509*bf2c3715SXin Li   * \sa shiftLeft()
510*bf2c3715SXin Li   */
511*bf2c3715SXin Li template<int N>
512*bf2c3715SXin Li EIGEN_DEVICE_FUNC
513*bf2c3715SXin Li typename ShiftRightXpr<N>::Type
shiftRight()514*bf2c3715SXin Li shiftRight() const
515*bf2c3715SXin Li {
516*bf2c3715SXin Li   return typename ShiftRightXpr<N>::Type(derived());
517*bf2c3715SXin Li }
518*bf2c3715SXin Li 
519*bf2c3715SXin Li 
520*bf2c3715SXin Li template<int N> struct ShiftLeftXpr {
521*bf2c3715SXin Li   typedef CwiseUnaryOp<internal::scalar_shift_left_op<Scalar, N>, const Derived> Type;
522*bf2c3715SXin Li };
523*bf2c3715SXin Li 
524*bf2c3715SXin Li /** \returns an expression of \c *this with the \a Scalar type logically
525*bf2c3715SXin Li   * shifted left by \a N bit positions.
526*bf2c3715SXin Li   *
527*bf2c3715SXin Li   * The template parameter \a N specifies the number of bit positions to shift.
528*bf2c3715SXin Li   *
529*bf2c3715SXin Li   * \sa shiftRight()
530*bf2c3715SXin Li   */
531*bf2c3715SXin Li template<int N>
532*bf2c3715SXin Li EIGEN_DEVICE_FUNC
533*bf2c3715SXin Li typename ShiftLeftXpr<N>::Type
shiftLeft()534*bf2c3715SXin Li shiftLeft() const
535*bf2c3715SXin Li {
536*bf2c3715SXin Li   return typename ShiftLeftXpr<N>::Type(derived());
537*bf2c3715SXin Li }
538*bf2c3715SXin Li 
539*bf2c3715SXin Li /** \returns an expression of the coefficient-wise isnan of *this.
540*bf2c3715SXin Li   *
541*bf2c3715SXin Li   * Example: \include Cwise_isNaN.cpp
542*bf2c3715SXin Li   * Output: \verbinclude Cwise_isNaN.out
543*bf2c3715SXin Li   *
544*bf2c3715SXin Li   * \sa isfinite(), isinf()
545*bf2c3715SXin Li   */
546*bf2c3715SXin Li EIGEN_DEVICE_FUNC
547*bf2c3715SXin Li inline const IsNaNReturnType
isNaN()548*bf2c3715SXin Li isNaN() const
549*bf2c3715SXin Li {
550*bf2c3715SXin Li   return IsNaNReturnType(derived());
551*bf2c3715SXin Li }
552*bf2c3715SXin Li 
553*bf2c3715SXin Li /** \returns an expression of the coefficient-wise isinf of *this.
554*bf2c3715SXin Li   *
555*bf2c3715SXin Li   * Example: \include Cwise_isInf.cpp
556*bf2c3715SXin Li   * Output: \verbinclude Cwise_isInf.out
557*bf2c3715SXin Li   *
558*bf2c3715SXin Li   * \sa isnan(), isfinite()
559*bf2c3715SXin Li   */
560*bf2c3715SXin Li EIGEN_DEVICE_FUNC
561*bf2c3715SXin Li inline const IsInfReturnType
isInf()562*bf2c3715SXin Li isInf() const
563*bf2c3715SXin Li {
564*bf2c3715SXin Li   return IsInfReturnType(derived());
565*bf2c3715SXin Li }
566*bf2c3715SXin Li 
567*bf2c3715SXin Li /** \returns an expression of the coefficient-wise isfinite of *this.
568*bf2c3715SXin Li   *
569*bf2c3715SXin Li   * Example: \include Cwise_isFinite.cpp
570*bf2c3715SXin Li   * Output: \verbinclude Cwise_isFinite.out
571*bf2c3715SXin Li   *
572*bf2c3715SXin Li   * \sa isnan(), isinf()
573*bf2c3715SXin Li   */
574*bf2c3715SXin Li EIGEN_DEVICE_FUNC
575*bf2c3715SXin Li inline const IsFiniteReturnType
isFinite()576*bf2c3715SXin Li isFinite() const
577*bf2c3715SXin Li {
578*bf2c3715SXin Li   return IsFiniteReturnType(derived());
579*bf2c3715SXin Li }
580*bf2c3715SXin Li 
581*bf2c3715SXin Li /** \returns an expression of the coefficient-wise ! operator of *this
582*bf2c3715SXin Li   *
583*bf2c3715SXin Li   * \warning this operator is for expression of bool only.
584*bf2c3715SXin Li   *
585*bf2c3715SXin Li   * Example: \include Cwise_boolean_not.cpp
586*bf2c3715SXin Li   * Output: \verbinclude Cwise_boolean_not.out
587*bf2c3715SXin Li   *
588*bf2c3715SXin Li   * \sa operator!=()
589*bf2c3715SXin Li   */
590*bf2c3715SXin Li EIGEN_DEVICE_FUNC
591*bf2c3715SXin Li inline const BooleanNotReturnType
592*bf2c3715SXin Li operator!() const
593*bf2c3715SXin Li {
594*bf2c3715SXin Li   EIGEN_STATIC_ASSERT((internal::is_same<bool,Scalar>::value),
595*bf2c3715SXin Li                       THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_OF_BOOL);
596*bf2c3715SXin Li   return BooleanNotReturnType(derived());
597*bf2c3715SXin Li }
598*bf2c3715SXin Li 
599*bf2c3715SXin Li 
600*bf2c3715SXin Li // --- SpecialFunctions module ---
601*bf2c3715SXin Li 
602*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_lgamma_op<Scalar>, const Derived> LgammaReturnType;
603*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_digamma_op<Scalar>, const Derived> DigammaReturnType;
604*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_erf_op<Scalar>, const Derived> ErfReturnType;
605*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_erfc_op<Scalar>, const Derived> ErfcReturnType;
606*bf2c3715SXin Li typedef CwiseUnaryOp<internal::scalar_ndtri_op<Scalar>, const Derived> NdtriReturnType;
607*bf2c3715SXin Li 
608*bf2c3715SXin Li /** \cpp11 \returns an expression of the coefficient-wise ln(|gamma(*this)|).
609*bf2c3715SXin Li   *
610*bf2c3715SXin Li   * \specialfunctions_module
611*bf2c3715SXin Li   *
612*bf2c3715SXin Li   * \note This function supports only float and double scalar types in c++11 mode. To support other scalar types,
613*bf2c3715SXin Li   * or float/double in non c++11 mode, the user has to provide implementations of lgamma(T) for any scalar
614*bf2c3715SXin Li   * type T to be supported.
615*bf2c3715SXin Li   *
616*bf2c3715SXin Li   * \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_lgamma">Math functions</a>, digamma()
617*bf2c3715SXin Li   */
618*bf2c3715SXin Li EIGEN_DEVICE_FUNC
619*bf2c3715SXin Li inline const LgammaReturnType
lgamma()620*bf2c3715SXin Li lgamma() const
621*bf2c3715SXin Li {
622*bf2c3715SXin Li   return LgammaReturnType(derived());
623*bf2c3715SXin Li }
624*bf2c3715SXin Li 
625*bf2c3715SXin Li /** \returns an expression of the coefficient-wise digamma (psi, derivative of lgamma).
626*bf2c3715SXin Li   *
627*bf2c3715SXin Li   * \specialfunctions_module
628*bf2c3715SXin Li   *
629*bf2c3715SXin Li   * \note This function supports only float and double scalar types. To support other scalar types,
630*bf2c3715SXin Li   * the user has to provide implementations of digamma(T) for any scalar
631*bf2c3715SXin Li   * type T to be supported.
632*bf2c3715SXin Li   *
633*bf2c3715SXin Li   * \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_digamma">Math functions</a>, Eigen::digamma(), Eigen::polygamma(), lgamma()
634*bf2c3715SXin Li   */
635*bf2c3715SXin Li EIGEN_DEVICE_FUNC
636*bf2c3715SXin Li inline const DigammaReturnType
digamma()637*bf2c3715SXin Li digamma() const
638*bf2c3715SXin Li {
639*bf2c3715SXin Li   return DigammaReturnType(derived());
640*bf2c3715SXin Li }
641*bf2c3715SXin Li 
642*bf2c3715SXin Li /** \cpp11 \returns an expression of the coefficient-wise Gauss error
643*bf2c3715SXin Li   * function of *this.
644*bf2c3715SXin Li   *
645*bf2c3715SXin Li   * \specialfunctions_module
646*bf2c3715SXin Li   *
647*bf2c3715SXin Li   * \note This function supports only float and double scalar types in c++11 mode. To support other scalar types,
648*bf2c3715SXin Li   * or float/double in non c++11 mode, the user has to provide implementations of erf(T) for any scalar
649*bf2c3715SXin Li   * type T to be supported.
650*bf2c3715SXin Li   *
651*bf2c3715SXin Li   * \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_erf">Math functions</a>, erfc()
652*bf2c3715SXin Li   */
653*bf2c3715SXin Li EIGEN_DEVICE_FUNC
654*bf2c3715SXin Li inline const ErfReturnType
erf()655*bf2c3715SXin Li erf() const
656*bf2c3715SXin Li {
657*bf2c3715SXin Li   return ErfReturnType(derived());
658*bf2c3715SXin Li }
659*bf2c3715SXin Li 
660*bf2c3715SXin Li /** \cpp11 \returns an expression of the coefficient-wise Complementary error
661*bf2c3715SXin Li   * function of *this.
662*bf2c3715SXin Li   *
663*bf2c3715SXin Li   * \specialfunctions_module
664*bf2c3715SXin Li   *
665*bf2c3715SXin Li   * \note This function supports only float and double scalar types in c++11 mode. To support other scalar types,
666*bf2c3715SXin Li   * or float/double in non c++11 mode, the user has to provide implementations of erfc(T) for any scalar
667*bf2c3715SXin Li   * type T to be supported.
668*bf2c3715SXin Li   *
669*bf2c3715SXin Li   * \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_erfc">Math functions</a>, erf()
670*bf2c3715SXin Li   */
671*bf2c3715SXin Li EIGEN_DEVICE_FUNC
672*bf2c3715SXin Li inline const ErfcReturnType
erfc()673*bf2c3715SXin Li erfc() const
674*bf2c3715SXin Li {
675*bf2c3715SXin Li   return ErfcReturnType(derived());
676*bf2c3715SXin Li }
677*bf2c3715SXin Li 
678*bf2c3715SXin Li /** \returns an expression of the coefficient-wise inverse of the CDF of the Normal distribution function
679*bf2c3715SXin Li   * function of *this.
680*bf2c3715SXin Li   *
681*bf2c3715SXin Li   * \specialfunctions_module
682*bf2c3715SXin Li   *
683*bf2c3715SXin Li   * In other words, considering `x = ndtri(y)`, it returns the argument, x, for which the area under the
684*bf2c3715SXin Li   * Gaussian probability density function (integrated from minus infinity to x) is equal to y.
685*bf2c3715SXin Li   *
686*bf2c3715SXin Li   * \note This function supports only float and double scalar types. To support other scalar types,
687*bf2c3715SXin Li   * the user has to provide implementations of ndtri(T) for any scalar type T to be supported.
688*bf2c3715SXin Li   *
689*bf2c3715SXin Li   * \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_ndtri">Math functions</a>
690*bf2c3715SXin Li   */
691*bf2c3715SXin Li EIGEN_DEVICE_FUNC
692*bf2c3715SXin Li inline const NdtriReturnType
ndtri()693*bf2c3715SXin Li ndtri() const
694*bf2c3715SXin Li {
695*bf2c3715SXin Li   return NdtriReturnType(derived());
696*bf2c3715SXin Li }
697