Eigen  5.0.1
 
Loading...
Searching...
No Matches
MatrixCwiseUnaryOps.inc
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// SPDX-License-Identifier: MPL-2.0
11
12// This file is included into the body of the base classes supporting matrix specific coefficient-wise functions.
13// These are MatrixBase, ArrayBase, and SparseMatrixBase.
14
20EIGEN_DOC_UNARY_ADDONS(cwiseAbs, absolute value)
24EIGEN_MAKE_CWISE_UNARY_OP(cwiseAbs, internal::scalar_abs_op, CwiseAbsReturnType)
25
26
31EIGEN_DOC_UNARY_ADDONS(cwiseAbs2, squared absolute value)
35EIGEN_MAKE_CWISE_UNARY_OP(cwiseAbs2, internal::scalar_abs2_op, CwiseAbs2ReturnType)
36
37
42EIGEN_DOC_UNARY_ADDONS(cwiseSqrt, square - root)
46EIGEN_MAKE_CWISE_UNARY_OP(cwiseSqrt, internal::scalar_sqrt_op, CwiseSqrtReturnType)
47
48
50EIGEN_DOC_UNARY_ADDONS(cwiseCbrt, cube - root)
54EIGEN_MAKE_CWISE_UNARY_OP(cwiseCbrt, internal::scalar_cbrt_op, CwiseCbrtReturnType)
55
56
58EIGEN_DOC_UNARY_ADDONS(cwiseSquare, square)
62EIGEN_MAKE_CWISE_UNARY_OP(cwiseSquare, internal::scalar_square_op, CwiseSquareReturnType)
63
64
69EIGEN_DOC_UNARY_ADDONS(cwiseSign, sign function)
71EIGEN_MAKE_CWISE_UNARY_OP(cwiseSign, internal::scalar_sign_op, CwiseSignReturnType)
72
73
78EIGEN_DOC_UNARY_ADDONS(cwiseInverse, inverse)
82EIGEN_MAKE_CWISE_UNARY_OP(cwiseInverse, internal::scalar_inverse_op, CwiseInverseReturnType)
83
84
89EIGEN_DOC_UNARY_ADDONS(cwiseArg, arg)
90
91EIGEN_MAKE_CWISE_UNARY_OP(cwiseArg, internal::scalar_arg_op, CwiseArgReturnType)
92
93EIGEN_MAKE_CWISE_UNARY_OP(cwiseCArg, internal::scalar_carg_op, CwiseCArgReturnType)
94
95template <typename ScalarExponent>
96using CwisePowReturnType =
97 std::enable_if_t<internal::is_arithmetic<typename NumTraits<ScalarExponent>::Real>::value,
98 CwiseUnaryOp<internal::scalar_unary_pow_op<Scalar, ScalarExponent>, const Derived>>;
99
100template <typename ScalarExponent>
101EIGEN_DEVICE_FUNC constexpr inline const CwisePowReturnType<ScalarExponent> cwisePow(
102 const ScalarExponent& exponent) const {
103 return CwisePowReturnType<ScalarExponent>(derived(), internal::scalar_unary_pow_op<Scalar, ScalarExponent>(exponent));
104}