1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>
5 // Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
6 //
7 // This Source Code Form is subject to the terms of the Mozilla
8 // Public License v. 2.0. If a copy of the MPL was not distributed
9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 
11 // This file is included into the body of the base classes supporting matrix specific coefficient-wise functions.
12 // This include MatrixBase and SparseMatrixBase.
13 
14 
15 typedef CwiseUnaryOp<internal::scalar_abs_op<Scalar>, const Derived> CwiseAbsReturnType;
16 typedef CwiseUnaryOp<internal::scalar_abs2_op<Scalar>, const Derived> CwiseAbs2ReturnType;
17 typedef CwiseUnaryOp<internal::scalar_arg_op<Scalar>, const Derived> CwiseArgReturnType;
18 typedef CwiseUnaryOp<internal::scalar_sqrt_op<Scalar>, const Derived> CwiseSqrtReturnType;
19 typedef CwiseUnaryOp<internal::scalar_sign_op<Scalar>, const Derived> CwiseSignReturnType;
20 typedef CwiseUnaryOp<internal::scalar_inverse_op<Scalar>, const Derived> CwiseInverseReturnType;
21 
22 /// \returns an expression of the coefficient-wise absolute value of \c *this
23 ///
24 /// Example: \include MatrixBase_cwiseAbs.cpp
25 /// Output: \verbinclude MatrixBase_cwiseAbs.out
26 ///
EIGEN_DOC_UNARY_ADDONS(cwiseAbs,absolute value)27 EIGEN_DOC_UNARY_ADDONS(cwiseAbs,absolute value)
28 ///
29 /// \sa cwiseAbs2()
30 ///
31 EIGEN_DEVICE_FUNC
32 EIGEN_STRONG_INLINE const CwiseAbsReturnType
33 cwiseAbs() const { return CwiseAbsReturnType(derived()); }
34 
35 /// \returns an expression of the coefficient-wise squared absolute value of \c *this
36 ///
37 /// Example: \include MatrixBase_cwiseAbs2.cpp
38 /// Output: \verbinclude MatrixBase_cwiseAbs2.out
39 ///
EIGEN_DOC_UNARY_ADDONS(cwiseAbs2,squared absolute value)40 EIGEN_DOC_UNARY_ADDONS(cwiseAbs2,squared absolute value)
41 ///
42 /// \sa cwiseAbs()
43 ///
44 EIGEN_DEVICE_FUNC
45 EIGEN_STRONG_INLINE const CwiseAbs2ReturnType
46 cwiseAbs2() const { return CwiseAbs2ReturnType(derived()); }
47 
48 /// \returns an expression of the coefficient-wise square root of *this.
49 ///
50 /// Example: \include MatrixBase_cwiseSqrt.cpp
51 /// Output: \verbinclude MatrixBase_cwiseSqrt.out
52 ///
53 EIGEN_DOC_UNARY_ADDONS(cwiseSqrt,square-root)
54 ///
55 /// \sa cwisePow(), cwiseSquare()
56 ///
57 EIGEN_DEVICE_FUNC
58 inline const CwiseSqrtReturnType
cwiseSqrt()59 cwiseSqrt() const { return CwiseSqrtReturnType(derived()); }
60 
61 /// \returns an expression of the coefficient-wise signum of *this.
62 ///
63 /// Example: \include MatrixBase_cwiseSign.cpp
64 /// Output: \verbinclude MatrixBase_cwiseSign.out
65 ///
EIGEN_DOC_UNARY_ADDONS(cwiseSign,sign function)66 EIGEN_DOC_UNARY_ADDONS(cwiseSign,sign function)
67 ///
68 EIGEN_DEVICE_FUNC
69 inline const CwiseSignReturnType
70 cwiseSign() const { return CwiseSignReturnType(derived()); }
71 
72 
73 /// \returns an expression of the coefficient-wise inverse of *this.
74 ///
75 /// Example: \include MatrixBase_cwiseInverse.cpp
76 /// Output: \verbinclude MatrixBase_cwiseInverse.out
77 ///
EIGEN_DOC_UNARY_ADDONS(cwiseInverse,inverse)78 EIGEN_DOC_UNARY_ADDONS(cwiseInverse,inverse)
79 ///
80 /// \sa cwiseProduct()
81 ///
82 EIGEN_DEVICE_FUNC
83 inline const CwiseInverseReturnType
84 cwiseInverse() const { return CwiseInverseReturnType(derived()); }
85 
86 /// \returns an expression of the coefficient-wise phase angle of \c *this
87 ///
88 /// Example: \include MatrixBase_cwiseArg.cpp
89 /// Output: \verbinclude MatrixBase_cwiseArg.out
90 ///
EIGEN_DOC_UNARY_ADDONS(cwiseArg,arg)91 EIGEN_DOC_UNARY_ADDONS(cwiseArg,arg)
92 
93 EIGEN_DEVICE_FUNC
94 inline const CwiseArgReturnType
95 cwiseArg() const { return CwiseArgReturnType(derived()); }
96