|
| 1 | +// clang-format off |
1 | 2 | /*****************************************************************//** |
2 | 3 | * \file matrix_base_ext.hpp |
3 | 4 | * \brief |
4 | 5 | * |
5 | 6 | * \author Xuhua Huang |
6 | 7 | * \date January 02, 2023 |
7 | 8 | *********************************************************************/ |
| 9 | +// clang-format on |
8 | 10 |
|
9 | 11 | #include <Eigen/Core> |
10 | 12 |
|
11 | | -inline Scalar at(uint i, uint j) const { return this->operator()(i, j); } |
12 | | -inline Scalar& at(uint i, uint j) { return this->operator()(i, j); } |
13 | | -inline Scalar at(uint i) const { return this->operator[](i); } |
14 | | -inline Scalar& at(uint i) { return this->operator[](i); } |
| 13 | +inline Scalar at(uint i, uint j) const { |
| 14 | + return this->operator()(i, j); |
| 15 | +} |
| 16 | +inline Scalar& at(uint i, uint j) { |
| 17 | + return this->operator()(i, j); |
| 18 | +} |
| 19 | +inline Scalar at(uint i) const { |
| 20 | + return this->operator[](i); |
| 21 | +} |
| 22 | +inline Scalar& at(uint i) { |
| 23 | + return this->operator[](i); |
| 24 | +} |
15 | 25 |
|
16 | | -inline RealScalar squaredLength() const { return squaredNorm(); } |
17 | | -inline RealScalar length() const { return norm(); } |
18 | | -inline RealScalar invLength(void) const { return fast_inv_sqrt(squaredNorm()); } |
| 26 | +inline RealScalar squaredLength() const { |
| 27 | + return squaredNorm(); |
| 28 | +} |
| 29 | +inline RealScalar length() const { |
| 30 | + return norm(); |
| 31 | +} |
| 32 | +inline RealScalar invLength(void) const { |
| 33 | + return fast_inv_sqrt(squaredNorm()); |
| 34 | +} |
19 | 35 |
|
20 | | -template<typename OtherDerived> |
21 | | -inline Scalar squaredDistanceTo(const MatrixBase<OtherDerived>& other) const |
22 | | -{ |
| 36 | +template <typename OtherDerived> |
| 37 | +inline Scalar squaredDistanceTo(const MatrixBase<OtherDerived>& other) const { |
23 | 38 | return (derived() - other.derived()).squaredNorm(); |
24 | 39 | } |
25 | 40 |
|
26 | | -template<typename OtherDerived> |
27 | | -inline RealScalar distanceTo(const MatrixBase<OtherDerived>& other) const |
28 | | -{ |
| 41 | +template <typename OtherDerived> |
| 42 | +inline RealScalar distanceTo(const MatrixBase<OtherDerived>& other) const { |
29 | 43 | return internal::sqrt(derived().squaredDistanceTo(other)); |
30 | 44 | } |
31 | 45 |
|
32 | | -inline void scaleTo(RealScalar l) { RealScalar vl = norm(); if (vl > 1e-9) derived() *= (l / vl); } |
| 46 | +inline void scaleTo(RealScalar l) { |
| 47 | + RealScalar vl = norm(); |
| 48 | + if (vl > 1e-9) |
| 49 | + derived() *= (l / vl); |
| 50 | +} |
33 | 51 |
|
34 | | -inline Transpose<Derived> transposed() { return this->transpose(); } |
35 | | -inline const Transpose<Derived> transposed() const { return this->transpose(); } |
| 52 | +inline Transpose<Derived> transposed() { |
| 53 | + return this->transpose(); |
| 54 | +} |
| 55 | +inline const Transpose<Derived> transposed() const { |
| 56 | + return this->transpose(); |
| 57 | +} |
36 | 58 |
|
37 | | -inline uint minComponentId(void) const { int i; this->minCoeff(&i); return i; } |
38 | | -inline uint maxComponentId(void) const { int i; this->maxCoeff(&i); return i; } |
| 59 | +inline uint minComponentId(void) const { |
| 60 | + int i; |
| 61 | + this->minCoeff(&i); |
| 62 | + return i; |
| 63 | +} |
| 64 | +inline uint maxComponentId(void) const { |
| 65 | + int i; |
| 66 | + this->maxCoeff(&i); |
| 67 | + return i; |
| 68 | +} |
39 | 69 |
|
40 | | -template<typename OtherDerived> |
41 | | -void makeFloor(const MatrixBase<OtherDerived>& other) { derived() = derived().cwiseMin(other.derived()); } |
| 70 | +template <typename OtherDerived> |
| 71 | +void makeFloor(const MatrixBase<OtherDerived>& other) { |
| 72 | + derived() = derived().cwiseMin(other.derived()); |
| 73 | +} |
42 | 74 |
|
43 | | -template<typename OtherDerived> |
44 | | -void makeCeil(const MatrixBase<OtherDerived>& other) { derived() = derived().cwiseMax(other.derived()); } |
| 75 | +template <typename OtherDerived> |
| 76 | +void makeCeil(const MatrixBase<OtherDerived>& other) { |
| 77 | + derived() = derived().cwiseMax(other.derived()); |
| 78 | +} |
45 | 79 |
|
46 | 80 | const CwiseBinaryOp<internal::scalar_sum_op<Scalar>, const Derived, const ConstantReturnType> |
47 | | -operator+(const Scalar& scalar) const |
48 | | -{ |
49 | | - return CwiseBinaryOp<internal::scalar_sum_op<Scalar>, const Derived, const ConstantReturnType>(derived(), Constant(rows(), cols(), scalar)); |
| 81 | +operator+(const Scalar& scalar) const { |
| 82 | + return CwiseBinaryOp<internal::scalar_sum_op<Scalar>, const Derived, const ConstantReturnType>( |
| 83 | + derived(), Constant(rows(), cols(), scalar) |
| 84 | + ); |
50 | 85 | } |
51 | 86 |
|
52 | 87 | friend const CwiseBinaryOp<internal::scalar_sum_op<Scalar>, const ConstantReturnType, Derived> |
53 | | -operator+(const Scalar& scalar, const MatrixBase<Derived>& mat) |
54 | | -{ |
55 | | - return CwiseBinaryOp<internal::scalar_sum_op<Scalar>, const ConstantReturnType, Derived>(Constant(rows(), cols(), scalar), mat.derived()); |
| 88 | +operator+(const Scalar& scalar, const MatrixBase<Derived>& mat) { |
| 89 | + return CwiseBinaryOp<internal::scalar_sum_op<Scalar>, const ConstantReturnType, Derived>( |
| 90 | + Constant(rows(), cols(), scalar), mat.derived() |
| 91 | + ); |
56 | 92 | } |
0 commit comments