Format EIGEN_STATIC_ASSERT() as a statement macro
diff --git a/.clang-format b/.clang-format index 28251c6..f3870b8 100644 --- a/.clang-format +++ b/.clang-format
@@ -2,6 +2,8 @@ Language: Cpp BasedOnStyle: Google ColumnLimit: 120 +StatementMacros: + - EIGEN_STATIC_ASSERT SortIncludes: false AttributeMacros: - EIGEN_STRONG_INLINE
diff --git a/Eigen/src/Core/CoreEvaluators.h b/Eigen/src/Core/CoreEvaluators.h index 5e1cbf6..5da9c57 100644 --- a/Eigen/src/Core/CoreEvaluators.h +++ b/Eigen/src/Core/CoreEvaluators.h
@@ -167,7 +167,7 @@ }; template <typename Derived> -struct evaluator<PlainObjectBase<Derived> > : evaluator_base<Derived> { +struct evaluator<PlainObjectBase<Derived>> : evaluator_base<Derived> { typedef PlainObjectBase<Derived> PlainObjectType; typedef typename PlainObjectType::Scalar Scalar; typedef typename PlainObjectType::CoeffReturnType CoeffReturnType; @@ -247,31 +247,29 @@ }; template <typename Scalar, int Rows, int Cols, int Options, int MaxRows, int MaxCols> -struct evaluator<Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> > - : evaluator<PlainObjectBase<Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> > > { +struct evaluator<Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols>> + : evaluator<PlainObjectBase<Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols>>> { typedef Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> XprType; EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE evaluator() {} - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit evaluator(const XprType& m) - : evaluator<PlainObjectBase<XprType> >(m) {} + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit evaluator(const XprType& m) : evaluator<PlainObjectBase<XprType>>(m) {} }; template <typename Scalar, int Rows, int Cols, int Options, int MaxRows, int MaxCols> -struct evaluator<Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols> > - : evaluator<PlainObjectBase<Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols> > > { +struct evaluator<Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols>> + : evaluator<PlainObjectBase<Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols>>> { typedef Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols> XprType; EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE evaluator() {} - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit evaluator(const XprType& m) - : evaluator<PlainObjectBase<XprType> >(m) {} + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit evaluator(const XprType& m) : evaluator<PlainObjectBase<XprType>>(m) {} }; // -------------------- Transpose -------------------- template <typename ArgType> -struct unary_evaluator<Transpose<ArgType>, IndexBased> : evaluator_base<Transpose<ArgType> > { +struct unary_evaluator<Transpose<ArgType>, IndexBased> : evaluator_base<Transpose<ArgType>> { typedef Transpose<ArgType> XprType; enum { @@ -460,8 +458,8 @@ #endif // MSVC workaround template <typename NullaryOp, typename PlainObjectType> -struct evaluator<CwiseNullaryOp<NullaryOp, PlainObjectType> > - : evaluator_base<CwiseNullaryOp<NullaryOp, PlainObjectType> > { +struct evaluator<CwiseNullaryOp<NullaryOp, PlainObjectType>> + : evaluator_base<CwiseNullaryOp<NullaryOp, PlainObjectType>> { typedef CwiseNullaryOp<NullaryOp, PlainObjectType> XprType; typedef internal::remove_all_t<PlainObjectType> PlainObjectTypeCleaned; @@ -509,7 +507,7 @@ // -------------------- CwiseUnaryOp -------------------- template <typename UnaryOp, typename ArgType> -struct unary_evaluator<CwiseUnaryOp<UnaryOp, ArgType>, IndexBased> : evaluator_base<CwiseUnaryOp<UnaryOp, ArgType> > { +struct unary_evaluator<CwiseUnaryOp<UnaryOp, ArgType>, IndexBased> : evaluator_base<CwiseUnaryOp<UnaryOp, ArgType>> { typedef CwiseUnaryOp<UnaryOp, ArgType> XprType; enum { @@ -762,17 +760,17 @@ // this is a ternary expression template <typename TernaryOp, typename Arg1, typename Arg2, typename Arg3> -struct evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> > - : public ternary_evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> > { +struct evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>> + : public ternary_evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>> { typedef CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> XprType; - typedef ternary_evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> > Base; + typedef ternary_evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>> Base; EIGEN_DEVICE_FUNC explicit evaluator(const XprType& xpr) : Base(xpr) {} }; template <typename TernaryOp, typename Arg1, typename Arg2, typename Arg3> struct ternary_evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>, IndexBased, IndexBased> - : evaluator_base<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> > { + : evaluator_base<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>> { typedef CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> XprType; enum { @@ -865,16 +863,16 @@ // this is a binary expression template <typename BinaryOp, typename Lhs, typename Rhs> -struct evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs> > : public binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs> > { +struct evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>> : public binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>> { typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> XprType; - typedef binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs> > Base; + typedef binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>> Base; EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit evaluator(const XprType& xpr) : Base(xpr) {} }; template <typename BinaryOp, typename Lhs, typename Rhs> struct binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>, IndexBased, IndexBased> - : evaluator_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> > { + : evaluator_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs>> { typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> XprType; enum { @@ -939,7 +937,7 @@ template <typename UnaryOp, typename ArgType, typename StrideType> struct unary_evaluator<CwiseUnaryView<UnaryOp, ArgType, StrideType>, IndexBased> - : evaluator_base<CwiseUnaryView<UnaryOp, ArgType, StrideType> > { + : evaluator_base<CwiseUnaryView<UnaryOp, ArgType, StrideType>> { typedef CwiseUnaryView<UnaryOp, ArgType, StrideType> XprType; enum { @@ -1067,7 +1065,7 @@ }; template <typename PlainObjectType, int MapOptions, typename StrideType> -struct evaluator<Map<PlainObjectType, MapOptions, StrideType> > +struct evaluator<Map<PlainObjectType, MapOptions, StrideType>> : public mapbase_evaluator<Map<PlainObjectType, MapOptions, StrideType>, PlainObjectType> { typedef Map<PlainObjectType, MapOptions, StrideType> XprType; typedef typename XprType::Scalar Scalar; @@ -1100,13 +1098,13 @@ // -------------------- Ref -------------------- template <typename PlainObjectType, int RefOptions, typename StrideType> -struct evaluator<Ref<PlainObjectType, RefOptions, StrideType> > +struct evaluator<Ref<PlainObjectType, RefOptions, StrideType>> : public mapbase_evaluator<Ref<PlainObjectType, RefOptions, StrideType>, PlainObjectType> { typedef Ref<PlainObjectType, RefOptions, StrideType> XprType; enum { - Flags = evaluator<Map<PlainObjectType, RefOptions, StrideType> >::Flags, - Alignment = evaluator<Map<PlainObjectType, RefOptions, StrideType> >::Alignment + Flags = evaluator<Map<PlainObjectType, RefOptions, StrideType>>::Flags, + Alignment = evaluator<Map<PlainObjectType, RefOptions, StrideType>>::Alignment }; EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit evaluator(const XprType& ref) @@ -1120,7 +1118,7 @@ struct block_evaluator; template <typename ArgType, int BlockRows, int BlockCols, bool InnerPanel> -struct evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel> > +struct evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>> : block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel> { typedef Block<ArgType, BlockRows, BlockCols, InnerPanel> XprType; typedef typename XprType::Scalar Scalar; @@ -1171,7 +1169,7 @@ // no direct-access => dispatch to a unary evaluator template <typename ArgType, int BlockRows, int BlockCols, bool InnerPanel> struct block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel, /*HasDirectAccess*/ false> - : unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel> > { + : unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>> { typedef Block<ArgType, BlockRows, BlockCols, InnerPanel> XprType; EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit block_evaluator(const XprType& block) @@ -1180,7 +1178,7 @@ template <typename ArgType, int BlockRows, int BlockCols, bool InnerPanel> struct unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>, IndexBased> - : evaluator_base<Block<ArgType, BlockRows, BlockCols, InnerPanel> > { + : evaluator_base<Block<ArgType, BlockRows, BlockCols, InnerPanel>> { typedef Block<ArgType, BlockRows, BlockCols, InnerPanel> XprType; EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& block) @@ -1293,8 +1291,8 @@ // TODO enable vectorization for Select template <typename ConditionMatrixType, typename ThenMatrixType, typename ElseMatrixType> -struct evaluator<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> > - : evaluator_base<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> > { +struct evaluator<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType>> + : evaluator_base<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType>> { typedef Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> XprType; enum { CoeffReadCost = evaluator<ConditionMatrixType>::CoeffReadCost + @@ -1335,8 +1333,8 @@ // -------------------- Replicate -------------------- template <typename ArgType, int RowFactor, int ColFactor> -struct unary_evaluator<Replicate<ArgType, RowFactor, ColFactor> > - : evaluator_base<Replicate<ArgType, RowFactor, ColFactor> > { +struct unary_evaluator<Replicate<ArgType, RowFactor, ColFactor>> + : evaluator_base<Replicate<ArgType, RowFactor, ColFactor>> { typedef Replicate<ArgType, RowFactor, ColFactor> XprType; typedef typename XprType::CoeffReturnType CoeffReturnType; enum { Factor = (RowFactor == Dynamic || ColFactor == Dynamic) ? Dynamic : RowFactor * ColFactor }; @@ -1461,19 +1459,19 @@ }; template <typename TArgType> -struct unary_evaluator<MatrixWrapper<TArgType> > : evaluator_wrapper_base<MatrixWrapper<TArgType> > { +struct unary_evaluator<MatrixWrapper<TArgType>> : evaluator_wrapper_base<MatrixWrapper<TArgType>> { typedef MatrixWrapper<TArgType> XprType; EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& wrapper) - : evaluator_wrapper_base<MatrixWrapper<TArgType> >(wrapper.nestedExpression()) {} + : evaluator_wrapper_base<MatrixWrapper<TArgType>>(wrapper.nestedExpression()) {} }; template <typename TArgType> -struct unary_evaluator<ArrayWrapper<TArgType> > : evaluator_wrapper_base<ArrayWrapper<TArgType> > { +struct unary_evaluator<ArrayWrapper<TArgType>> : evaluator_wrapper_base<ArrayWrapper<TArgType>> { typedef ArrayWrapper<TArgType> XprType; EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& wrapper) - : evaluator_wrapper_base<ArrayWrapper<TArgType> >(wrapper.nestedExpression()) {} + : evaluator_wrapper_base<ArrayWrapper<TArgType>>(wrapper.nestedExpression()) {} }; // -------------------- Reverse -------------------- @@ -1483,7 +1481,7 @@ struct reverse_packet_cond; template <typename ArgType, int Direction> -struct unary_evaluator<Reverse<ArgType, Direction> > : evaluator_base<Reverse<ArgType, Direction> > { +struct unary_evaluator<Reverse<ArgType, Direction>> : evaluator_base<Reverse<ArgType, Direction>> { typedef Reverse<ArgType, Direction> XprType; typedef typename XprType::Scalar Scalar; typedef typename XprType::CoeffReturnType CoeffReturnType; @@ -1584,7 +1582,7 @@ // -------------------- Diagonal -------------------- template <typename ArgType, int DiagIndex> -struct evaluator<Diagonal<ArgType, DiagIndex> > : evaluator_base<Diagonal<ArgType, DiagIndex> > { +struct evaluator<Diagonal<ArgType, DiagIndex>> : evaluator_base<Diagonal<ArgType, DiagIndex>> { typedef Diagonal<ArgType, DiagIndex> XprType; enum { @@ -1643,10 +1641,10 @@ class EvalToTemp; template <typename ArgType> -struct traits<EvalToTemp<ArgType> > : public traits<ArgType> {}; +struct traits<EvalToTemp<ArgType>> : public traits<ArgType> {}; template <typename ArgType> -class EvalToTemp : public dense_xpr_base<EvalToTemp<ArgType> >::type { +class EvalToTemp : public dense_xpr_base<EvalToTemp<ArgType>>::type { public: typedef typename dense_xpr_base<EvalToTemp>::type Base; EIGEN_GENERIC_PUBLIC_INTERFACE(EvalToTemp) @@ -1664,7 +1662,7 @@ }; template <typename ArgType> -struct evaluator<EvalToTemp<ArgType> > : public evaluator<typename ArgType::PlainObject> { +struct evaluator<EvalToTemp<ArgType>> : public evaluator<typename ArgType::PlainObject> { typedef EvalToTemp<ArgType> XprType; typedef typename ArgType::PlainObject PlainObject; typedef evaluator<PlainObject> Base;
diff --git a/Eigen/src/Core/GeneralProduct.h b/Eigen/src/Core/GeneralProduct.h index 1220073..b7ae44f 100644 --- a/Eigen/src/Core/GeneralProduct.h +++ b/Eigen/src/Core/GeneralProduct.h
@@ -243,17 +243,15 @@ template <typename Scalar, int Size, int MaxSize> struct gemv_static_vector_if<Scalar, Size, MaxSize, true> { #if EIGEN_MAX_STATIC_ALIGN_BYTES != 0 - internal::plain_array<Scalar, internal::min_size_prefer_fixed(Size, MaxSize), 0, AlignedMax> - m_data; + internal::plain_array<Scalar, internal::min_size_prefer_fixed(Size, MaxSize), 0, AlignedMax> m_data; EIGEN_STRONG_INLINE Scalar* data() { return m_data.array; } #else // Some architectures cannot align on the stack, // => let's manually enforce alignment by allocating more data and return the address of the first aligned element. - internal::plain_array< - Scalar, internal::min_size_prefer_fixed(Size, MaxSize) + EIGEN_MAX_ALIGN_BYTES, 0> - m_data; + internal::plain_array<Scalar, internal::min_size_prefer_fixed(Size, MaxSize) + EIGEN_MAX_ALIGN_BYTES, 0> m_data; EIGEN_STRONG_INLINE Scalar* data() { - return reinterpret_cast<Scalar*>((std::uintptr_t(m_data.array) & ~(std::size_t(EIGEN_MAX_ALIGN_BYTES - 1))) + EIGEN_MAX_ALIGN_BYTES); + return reinterpret_cast<Scalar*>((std::uintptr_t(m_data.array) & ~(std::size_t(EIGEN_MAX_ALIGN_BYTES - 1))) + + EIGEN_MAX_ALIGN_BYTES); } #endif };
diff --git a/Eigen/src/Core/Replicate.h b/Eigen/src/Core/Replicate.h index c01c627..11d7ad1 100644 --- a/Eigen/src/Core/Replicate.h +++ b/Eigen/src/Core/Replicate.h
@@ -80,15 +80,12 @@ template <typename OriginalMatrixType> EIGEN_DEVICE_FUNC inline Replicate(const OriginalMatrixType& matrix, Index rowFactor, Index colFactor) - : m_matrix(matrix), - m_rowFactor(rowFactor), - m_colFactor(colFactor){ - EIGEN_STATIC_ASSERT((internal::is_same<std::remove_const_t<MatrixType>, OriginalMatrixType>::value), - THE_MATRIX_OR_EXPRESSION_THAT_YOU_PASSED_DOES_NOT_HAVE_THE_EXPECTED_TYPE)} - - EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index rows() const { - return m_matrix.rows() * m_rowFactor.value(); + : m_matrix(matrix), m_rowFactor(rowFactor), m_colFactor(colFactor) { + EIGEN_STATIC_ASSERT((internal::is_same<std::remove_const_t<MatrixType>, OriginalMatrixType>::value), + THE_MATRIX_OR_EXPRESSION_THAT_YOU_PASSED_DOES_NOT_HAVE_THE_EXPECTED_TYPE) } + + EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index rows() const { return m_matrix.rows() * m_rowFactor.value(); } EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index cols() const { return m_matrix.cols() * m_colFactor.value(); } EIGEN_DEVICE_FUNC const MatrixTypeNested_& nestedExpression() const { return m_matrix; }
diff --git a/Eigen/src/Core/products/TriangularSolverMatrix.h b/Eigen/src/Core/products/TriangularSolverMatrix.h index 2122af9..8244758 100644 --- a/Eigen/src/Core/products/TriangularSolverMatrix.h +++ b/Eigen/src/Core/products/TriangularSolverMatrix.h
@@ -57,7 +57,7 @@ Index rs = size - k - 1; // remaining size Index s = TriStorageOrder == RowMajor ? (IsLower ? 0 : i + 1) : IsLower ? i + 1 : i - rs; - Scalar a = (Mode & UnitDiag) ? Scalar(1) : Scalar(Scalar(1)/conj(tri(i,i))); + Scalar a = (Mode & UnitDiag) ? Scalar(1) : Scalar(Scalar(1) / conj(tri(i, i))); for (Index j = 0; j < otherSize; ++j) { if (TriStorageOrder == RowMajor) { Scalar b(0);
diff --git a/Eigen/src/Core/util/SymbolicIndex.h b/Eigen/src/Core/util/SymbolicIndex.h index 9668f1e..dc204af 100644 --- a/Eigen/src/Core/util/SymbolicIndex.h +++ b/Eigen/src/Core/util/SymbolicIndex.h
@@ -96,17 +96,17 @@ return AddExpr<Derived, ValueExpr<>>(derived(), -a); } constexpr ProductExpr<Derived, ValueExpr<>> operator*(Index a) const { - return ProductExpr<Derived, ValueExpr<> >(derived(), a); + return ProductExpr<Derived, ValueExpr<>>(derived(), a); } constexpr QuotientExpr<Derived, ValueExpr<>> operator/(Index a) const { - return QuotientExpr<Derived, ValueExpr<> >(derived(), a); + return QuotientExpr<Derived, ValueExpr<>>(derived(), a); } friend constexpr AddExpr<Derived, ValueExpr<>> operator+(Index a, const BaseExpr& b) { - return AddExpr<Derived, ValueExpr<> >(b.derived(), a); + return AddExpr<Derived, ValueExpr<>>(b.derived(), a); } friend constexpr AddExpr<NegateExpr<Derived>, ValueExpr<>> operator-(Index a, const BaseExpr& b) { - return AddExpr<NegateExpr<Derived>, ValueExpr<> >(-b.derived(), a); + return AddExpr<NegateExpr<Derived>, ValueExpr<>>(-b.derived(), a); } friend constexpr ProductExpr<ValueExpr<>, Derived> operator*(Index a, const BaseExpr& b) { return ProductExpr<ValueExpr<>, Derived>(a, b.derived()); @@ -117,41 +117,41 @@ template <int N> constexpr AddExpr<Derived, ValueExpr<internal::FixedInt<N>>> operator+(internal::FixedInt<N>) const { - return AddExpr<Derived, ValueExpr<internal::FixedInt<N> > >(derived(), ValueExpr<internal::FixedInt<N> >()); + return AddExpr<Derived, ValueExpr<internal::FixedInt<N>>>(derived(), ValueExpr<internal::FixedInt<N>>()); } template <int N> constexpr AddExpr<Derived, ValueExpr<internal::FixedInt<-N>>> operator-(internal::FixedInt<N>) const { - return AddExpr<Derived, ValueExpr<internal::FixedInt<-N> > >(derived(), ValueExpr<internal::FixedInt<-N> >()); + return AddExpr<Derived, ValueExpr<internal::FixedInt<-N>>>(derived(), ValueExpr<internal::FixedInt<-N>>()); } template <int N> constexpr ProductExpr<Derived, ValueExpr<internal::FixedInt<N>>> operator*(internal::FixedInt<N>) const { - return ProductExpr<Derived, ValueExpr<internal::FixedInt<N> > >(derived(), ValueExpr<internal::FixedInt<N> >()); + return ProductExpr<Derived, ValueExpr<internal::FixedInt<N>>>(derived(), ValueExpr<internal::FixedInt<N>>()); } template <int N> constexpr QuotientExpr<Derived, ValueExpr<internal::FixedInt<N>>> operator/(internal::FixedInt<N>) const { - return QuotientExpr<Derived, ValueExpr<internal::FixedInt<N> > >(derived(), ValueExpr<internal::FixedInt<N> >()); + return QuotientExpr<Derived, ValueExpr<internal::FixedInt<N>>>(derived(), ValueExpr<internal::FixedInt<N>>()); } template <int N> friend constexpr AddExpr<Derived, ValueExpr<internal::FixedInt<N>>> operator+(internal::FixedInt<N>, const BaseExpr& b) { - return AddExpr<Derived, ValueExpr<internal::FixedInt<N> > >(b.derived(), ValueExpr<internal::FixedInt<N> >()); + return AddExpr<Derived, ValueExpr<internal::FixedInt<N>>>(b.derived(), ValueExpr<internal::FixedInt<N>>()); } template <int N> friend constexpr AddExpr<NegateExpr<Derived>, ValueExpr<internal::FixedInt<N>>> operator-(internal::FixedInt<N>, const BaseExpr& b) { - return AddExpr<NegateExpr<Derived>, ValueExpr<internal::FixedInt<N> > >(-b.derived(), - ValueExpr<internal::FixedInt<N> >()); + return AddExpr<NegateExpr<Derived>, ValueExpr<internal::FixedInt<N>>>(-b.derived(), + ValueExpr<internal::FixedInt<N>>()); } template <int N> friend constexpr ProductExpr<ValueExpr<internal::FixedInt<N>>, Derived> operator*(internal::FixedInt<N>, const BaseExpr& b) { - return ProductExpr<ValueExpr<internal::FixedInt<N> >, Derived>(ValueExpr<internal::FixedInt<N> >(), b.derived()); + return ProductExpr<ValueExpr<internal::FixedInt<N>>, Derived>(ValueExpr<internal::FixedInt<N>>(), b.derived()); } template <int N> friend constexpr QuotientExpr<ValueExpr<internal::FixedInt<N>>, Derived> operator/(internal::FixedInt<N>, const BaseExpr& b) { - return QuotientExpr<ValueExpr<internal::FixedInt<N> >, Derived>(ValueExpr<internal::FixedInt<N> >(), b.derived()); + return QuotientExpr<ValueExpr<internal::FixedInt<N>>, Derived>(ValueExpr<internal::FixedInt<N>>(), b.derived()); } template <typename OtherDerived> @@ -161,7 +161,7 @@ template <typename OtherDerived> constexpr AddExpr<Derived, NegateExpr<OtherDerived>> operator-(const BaseExpr<OtherDerived>& b) const { - return AddExpr<Derived, NegateExpr<OtherDerived> >(derived(), -b.derived()); + return AddExpr<Derived, NegateExpr<OtherDerived>>(derived(), -b.derived()); } template <typename OtherDerived> @@ -179,7 +179,7 @@ struct is_symbolic { // BaseExpr has no conversion ctor, so we only have to check whether T can be statically cast to its base class // BaseExpr<T>. - enum { value = internal::is_convertible<T, BaseExpr<T> >::value }; + enum { value = internal::is_convertible<T, BaseExpr<T>>::value }; }; // A simple wrapper around an integral value to provide the eval method. @@ -317,7 +317,7 @@ /** Expression of a symbol uniquely identified by the template parameter type \c tag */ template <typename tag> -class SymbolExpr : public BaseExpr<SymbolExpr<tag> > { +class SymbolExpr : public BaseExpr<SymbolExpr<tag>> { public: /** Alias to the template parameter \c tag */ typedef tag Tag; @@ -349,7 +349,7 @@ }; template <typename Arg0> -class NegateExpr : public BaseExpr<NegateExpr<Arg0> > { +class NegateExpr : public BaseExpr<NegateExpr<Arg0>> { public: constexpr NegateExpr() = default; constexpr NegateExpr(const Arg0& arg0) : m_arg0(arg0) {} @@ -370,7 +370,7 @@ }; template <typename Arg0, typename Arg1> -class AddExpr : public BaseExpr<AddExpr<Arg0, Arg1> > { +class AddExpr : public BaseExpr<AddExpr<Arg0, Arg1>> { public: constexpr AddExpr() = default; constexpr AddExpr(const Arg0& arg0, const Arg1& arg1) : m_arg0(arg0), m_arg1(arg1) {} @@ -393,7 +393,7 @@ }; template <typename Arg0, typename Arg1> -class ProductExpr : public BaseExpr<ProductExpr<Arg0, Arg1> > { +class ProductExpr : public BaseExpr<ProductExpr<Arg0, Arg1>> { public: constexpr ProductExpr() = default; constexpr ProductExpr(const Arg0& arg0, const Arg1& arg1) : m_arg0(arg0), m_arg1(arg1) {} @@ -416,7 +416,7 @@ }; template <typename Arg0, typename Arg1> -class QuotientExpr : public BaseExpr<QuotientExpr<Arg0, Arg1> > { +class QuotientExpr : public BaseExpr<QuotientExpr<Arg0, Arg1>> { public: constexpr QuotientExpr() = default; constexpr QuotientExpr(const Arg0& arg0, const Arg1& arg1) : m_arg0(arg0), m_arg1(arg1) {}
diff --git a/Eigen/src/SVD/BDCSVD.h b/Eigen/src/SVD/BDCSVD.h index f80ddc0..52f3564 100644 --- a/Eigen/src/SVD/BDCSVD.h +++ b/Eigen/src/SVD/BDCSVD.h
@@ -1233,7 +1233,7 @@ using std::conj; using std::pow; using std::sqrt; - + RealScalar s = m_computed(firstColm + i, firstColm); RealScalar c = m_computed(firstColm + j, firstColm); RealScalar r = numext::hypot(c, s); @@ -1424,8 +1424,7 @@ if ((diag(i) - diag(i - 1)) < epsilon_strict) { #ifdef EIGEN_BDCSVD_DEBUG_VERBOSE std::cout << "deflation 4.4 with i = " << i << " because " << diag(i) << " - " << diag(i - 1) - << " == " << (diag(i) - diag(i - 1)) << " < " - << epsilon_strict << "\n"; + << " == " << (diag(i) - diag(i - 1)) << " < " << epsilon_strict << "\n"; #endif eigen_internal_assert(abs(diag(i) - diag(i - 1)) < epsilon_coarse && " diagonal entries are not properly sorted");
diff --git a/scripts/format.sh b/scripts/format.sh new file mode 100755 index 0000000..f1c38b2 --- /dev/null +++ b/scripts/format.sh
@@ -0,0 +1,11 @@ +#!/bin/bash + +# Format files with extensions, excluding plugins because they're partial files that don't contain valid syntax +find . -type f \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.cu' -o -name '*.cxx' -o -name '*.h' -o -name '*.inc' -not -path '*/plugins/*' \) | xargs -n 1 -P 0 clang-format-17 -i + +# Format main headers without extensions +find Eigen -maxdepth 1 -type f | xargs -n 1 -P 0 clang-format-17 -i +find unsupported/Eigen -maxdepth 2 -type f -not -name '*.txt' | xargs -n 1 -P 0 clang-format-17 -i + +# Format examples +find doc/examples -type f -name '*.cpp.*' | xargs -n 1 -P 0 clang-format-17 -i
diff --git a/test/array_cwise.cpp b/test/array_cwise.cpp index 155f77a..fdc5b48 100644 --- a/test/array_cwise.cpp +++ b/test/array_cwise.cpp
@@ -960,9 +960,9 @@ // Check for larger magnitude complex numbers that expm1 matches exp - 1. VERIFY_IS_APPROX(expm1(10. * m1), exp(10. * m1) - 1.); - VERIFY_IS_APPROX(sinh(m1), 0.5*(exp(m1)-exp(-m1))); - VERIFY_IS_APPROX(cosh(m1), 0.5*(exp(m1)+exp(-m1))); - VERIFY_IS_APPROX(tanh(m1), (0.5*(exp(m1)-exp(-m1)))/(0.5*(exp(m1)+exp(-m1)))); + VERIFY_IS_APPROX(sinh(m1), 0.5 * (exp(m1) - exp(-m1))); + VERIFY_IS_APPROX(cosh(m1), 0.5 * (exp(m1) + exp(-m1))); + VERIFY_IS_APPROX(tanh(m1), (0.5 * (exp(m1) - exp(-m1))) / (0.5 * (exp(m1) + exp(-m1)))); VERIFY_IS_APPROX(logistic(m1), (1.0 / (1.0 + exp(-m1)))); if (m1.size() > 0) { // Complex exponential overflow edge-case.
diff --git a/test/array_for_matrix.cpp b/test/array_for_matrix.cpp index 10bfe68..e94398a 100644 --- a/test/array_for_matrix.cpp +++ b/test/array_for_matrix.cpp
@@ -140,7 +140,8 @@ // and/or VERIFY(((m1.array() < RealScalar(0)).matrix() && (m1.array() > RealScalar(0)).matrix()).count() == 0); VERIFY(((m1.array() < RealScalar(0)).matrix() || (m1.array() >= RealScalar(0)).matrix()).count() == rows * cols); - VERIFY(((m1.array() < -mid).matrix() || (m1.array() > mid).matrix()).count() == (m1.cwiseAbs().array() > mid).count()); + VERIFY(((m1.array() < -mid).matrix() || (m1.array() > mid).matrix()).count() == + (m1.cwiseAbs().array() > mid).count()); typedef Matrix<Index, Dynamic, 1> VectorOfIndices;
diff --git a/unsupported/Eigen/CXX11/src/Tensor/Tensor.h b/unsupported/Eigen/CXX11/src/Tensor/Tensor.h index 9417469..9dc9591 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/Tensor.h +++ b/unsupported/Eigen/CXX11/src/Tensor/Tensor.h
@@ -239,18 +239,16 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor(const Self& other) : Base(other), m_storage(other.m_storage) {} - template<typename... IndexTypes> - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor(Index firstDimension, IndexTypes... otherDimensions) - : m_storage(firstDimension, otherDimensions...) - { - // The number of dimensions used to construct a tensor must be equal to the rank of the tensor. - EIGEN_STATIC_ASSERT(sizeof...(otherDimensions) + 1 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE) - } + template <typename... IndexTypes> + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor(Index firstDimension, IndexTypes... otherDimensions) + : m_storage(firstDimension, otherDimensions...) { + // The number of dimensions used to construct a tensor must be equal to the rank of the tensor. + EIGEN_STATIC_ASSERT(sizeof...(otherDimensions) + 1 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE) + } - /** Normal Dimension */ - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit Tensor(const array<Index, NumIndices>& dimensions) - : m_storage(internal::array_prod(dimensions), dimensions) - { + /** Normal Dimension */ + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit Tensor(const array<Index, NumIndices>& dimensions) + : m_storage(internal::array_prod(dimensions), dimensions) { EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED }
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h b/unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h index ae8f25f..06d4dfd 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h
@@ -215,14 +215,13 @@ } template <typename... IndexTypes> - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit DSizes(DenseIndex firstDimension, DenseIndex secondDimension, - IndexTypes... otherDimensions) - : Base({{firstDimension, secondDimension, otherDimensions...}}){EIGEN_STATIC_ASSERT( - sizeof...(otherDimensions) + 2 == NumDims, YOU_MADE_A_PROGRAMMING_MISTAKE)} + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit DSizes(DenseIndex firstDimension, DenseIndex secondDimension, + IndexTypes... otherDimensions) + : Base({{firstDimension, secondDimension, otherDimensions...}}) { + EIGEN_STATIC_ASSERT(sizeof...(otherDimensions) + 2 == NumDims, YOU_MADE_A_PROGRAMMING_MISTAKE) + } - EIGEN_DEVICE_FUNC DSizes - & - operator=(const array<DenseIndex, NumDims>& other) { + EIGEN_DEVICE_FUNC DSizes& operator=(const array<DenseIndex, NumDims>& other) { *static_cast<Base*>(this) = other; return *this; }
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorIO.h b/unsupported/Eigen/CXX11/src/Tensor/TensorIO.h index 2605219..0bdb1ab 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorIO.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorIO.h
@@ -367,7 +367,8 @@ const IndexType total_size = internal::array_prod(tensor.dimensions()); if (total_size > 0) { const IndexType first_dim = Eigen::internal::array_get<0>(tensor.dimensions()); - Map<const Array<Scalar, Dynamic, Dynamic, Tensor::Layout>> matrix(tensor.data(), first_dim, total_size / first_dim); + Map<const Array<Scalar, Dynamic, Dynamic, Tensor::Layout>> matrix(tensor.data(), first_dim, + total_size / first_dim); s << matrix; return; }
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorMap.h b/unsupported/Eigen/CXX11/src/Tensor/TensorMap.h index c201707..191413b 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorMap.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorMap.h
@@ -79,14 +79,14 @@ template <typename... IndexTypes> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorMap(StoragePointerType dataPtr, Index firstDimension, IndexTypes... otherDimensions) - : m_data(dataPtr), - m_dimensions(firstDimension, otherDimensions...){ - // The number of dimensions used to construct a tensor must be equal to the rank of the tensor. - EIGEN_STATIC_ASSERT((sizeof...(otherDimensions) + 1 == NumIndices || NumIndices == Dynamic), - YOU_MADE_A_PROGRAMMING_MISTAKE)} + : m_data(dataPtr), m_dimensions(firstDimension, otherDimensions...) { + // The number of dimensions used to construct a tensor must be equal to the rank of the tensor. + EIGEN_STATIC_ASSERT((sizeof...(otherDimensions) + 1 == NumIndices || NumIndices == Dynamic), + YOU_MADE_A_PROGRAMMING_MISTAKE) + } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorMap(StoragePointerType dataPtr, - const array<Index, NumIndices>& dimensions) + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorMap(StoragePointerType dataPtr, + const array<Index, NumIndices>& dimensions) : m_data(dataPtr), m_dimensions(dimensions) {} template <typename Dimensions>
diff --git a/unsupported/Eigen/FFT b/unsupported/Eigen/FFT index 557fdf6..f32ad36 100644 --- a/unsupported/Eigen/FFT +++ b/unsupported/Eigen/FFT
@@ -231,7 +231,7 @@ THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_WITH_DIRECT_MEMORY_ACCESS_SUCH_AS_MAP_OR_PLAIN_MATRICES) if (nfft < 1) nfft = src.size(); - + Index dst_size = nfft; if (NumTraits<src_type>::IsComplex == 0 && HasFlag(HalfSpectrum)) { dst_size = (nfft >> 1) + 1;