Bugzilla – Attachment 775 Details for
Bug 1391
Feature Request: Allow custom DenseBase plugins to use IOFormat
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Forgot Password
Login:
[x]
This bugzilla service is closed. All entries have been migrated to
https://gitlab.com/libeigen/eigen
[patch]
Moved DenseBase dependencies to DenseBase.h
ioformat.patch (text/plain), 8.36 KB, created by
Kunal Tyagi
on 2017-02-11 19:59:45 UTC
(
hide
)
Description:
Moved DenseBase dependencies to DenseBase.h
Filename:
MIME Type:
Creator:
Kunal Tyagi
Created:
2017-02-11 19:59:45 UTC
Size:
8.36 KB
patch
obsolete
>exporting patch: ># HG changeset patch ># User Kunal Tyagi <kunaltyagi.gsoc@gmail.com> ># Date 1486842942 -19800 ># Sun Feb 12 01:25:42 2017 +0530 ># Branch io_densebase ># Node ID f33983b1367322523d5618752dd091aebd79a329 ># Parent 4d09e90f07c8ac4a3da31dc0f5a782db18904679 >Code redistribution to allow use of IOFormat in DenseBase > >Also corrected some extra whitespaces > >diff --git a/Eigen/Core b/Eigen/Core >--- a/Eigen/Core >+++ b/Eigen/Core >@@ -430,6 +430,8 @@ using std::ptrdiff_t; > // on CUDA devices > #include "src/Core/arch/CUDA/Complex.h" > >+#include "src/Core/IO.h" >+ > #include "src/Core/util/IndexedViewHelper.h" > #include "src/Core/ArithmeticSequence.h" > #include "src/Core/DenseCoeffsBase.h" >@@ -480,7 +482,6 @@ using std::ptrdiff_t; > #include "src/Core/Redux.h" > #include "src/Core/Visitor.h" > #include "src/Core/Fuzzy.h" >-#include "src/Core/IO.h" > #include "src/Core/Swap.h" > #include "src/Core/CommaInitializer.h" > #include "src/Core/GeneralProduct.h" >diff --git a/Eigen/src/Core/DenseBase.h b/Eigen/src/Core/DenseBase.h >--- a/Eigen/src/Core/DenseBase.h >+++ b/Eigen/src/Core/DenseBase.h >@@ -14,15 +14,15 @@ > namespace Eigen { > > namespace internal { >- >+ > // The index type defined by EIGEN_DEFAULT_DENSE_INDEX_TYPE must be a signed type. > // This dummy function simply aims at checking that at compile time. > static inline void check_DenseIndex_is_signed() { >- EIGEN_STATIC_ASSERT(NumTraits<DenseIndex>::IsSigned,THE_INDEX_TYPE_MUST_BE_A_SIGNED_TYPE); >+ EIGEN_STATIC_ASSERT(NumTraits<DenseIndex>::IsSigned,THE_INDEX_TYPE_MUST_BE_A_SIGNED_TYPE); > } > > } // end namespace internal >- >+ > /** \class DenseBase > * \ingroup Core_Module > * >@@ -64,12 +64,12 @@ template<typename Derived> class DenseBa > > /** The numeric type of the expression' coefficients, e.g. float, double, int or std::complex<float>, etc. */ > typedef typename internal::traits<Derived>::Scalar Scalar; >- >+ > /** The numeric type of the expression' coefficients, e.g. float, double, int or std::complex<float>, etc. > * > * It is an alias for the Scalar type */ > typedef Scalar value_type; >- >+ > typedef typename NumTraits<Scalar>::Real RealScalar; > typedef DenseCoeffsBase<Derived> Base; > >@@ -170,11 +170,11 @@ template<typename Derived> class DenseBa > InnerStrideAtCompileTime = internal::inner_stride_at_compile_time<Derived>::ret, > OuterStrideAtCompileTime = internal::outer_stride_at_compile_time<Derived>::ret > }; >- >+ > typedef typename internal::find_best_packet<Scalar,SizeAtCompileTime>::type PacketScalar; > > enum { IsPlainObjectBase = 0 }; >- >+ > /** The plain matrix type corresponding to this expression. > * \sa PlainObject */ > typedef Matrix<typename internal::traits<Derived>::Scalar, >@@ -184,7 +184,7 @@ template<typename Derived> class DenseBa > internal::traits<Derived>::MaxRowsAtCompileTime, > internal::traits<Derived>::MaxColsAtCompileTime > > PlainMatrix; >- >+ > /** The plain array type corresponding to this expression. > * \sa PlainObject */ > typedef Array<typename internal::traits<Derived>::Scalar, >@@ -224,7 +224,7 @@ template<typename Derived> class DenseBa > /** \returns the inner size. > * > * \note For a vector, this is just the size. For a matrix (non-vector), this is the minor dimension >- * with respect to the \ref TopicStorageOrders "storage order", i.e., the number of rows for a >+ * with respect to the \ref TopicStorageOrders "storage order", i.e., the number of rows for a > * column-major matrix, and the number of columns for a row-major matrix. */ > EIGEN_DEVICE_FUNC > Index innerSize() const >@@ -369,7 +369,7 @@ template<typename Derived> class DenseBa > template<typename OtherDerived> EIGEN_DEVICE_FUNC > bool isApprox(const DenseBase<OtherDerived>& other, > const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const; >- EIGEN_DEVICE_FUNC >+ EIGEN_DEVICE_FUNC > bool isMuchSmallerThan(const RealScalar& other, > const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const; > template<typename OtherDerived> EIGEN_DEVICE_FUNC >@@ -380,7 +380,7 @@ template<typename Derived> class DenseBa > EIGEN_DEVICE_FUNC bool isConstant(const Scalar& value, const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const; > EIGEN_DEVICE_FUNC bool isZero(const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const; > EIGEN_DEVICE_FUNC bool isOnes(const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const; >- >+ > inline bool hasNaN() const; > inline bool allFinite() const; > >@@ -394,7 +394,7 @@ template<typename Derived> class DenseBa > * > * Notice that in the case of a plain matrix or vector (not an expression) this function just returns > * a const reference, in order to avoid a useless copy. >- * >+ * > * \warning Be carefull with eval() and the auto C++ keyword, as detailed in this \link TopicPitfalls_auto_keyword page \endlink. > */ > EIGEN_DEVICE_FUNC >@@ -405,7 +405,7 @@ template<typename Derived> class DenseBa > // size types on MSVC. > return typename internal::eval<Derived>::type(derived()); > } >- >+ > /** swaps *this with the expression \a other. > * > */ >@@ -600,6 +600,39 @@ template<typename Derived> class DenseBa > template<typename OtherDerived> EIGEN_DEVICE_FUNC explicit DenseBase(const DenseBase<OtherDerived>&); > }; > >+/** \returns a WithFormat proxy object allowing to print a matrix the with given >+ * format \a fmt. >+ * >+ * See class IOFormat for some examples. >+ * >+ * \sa class IOFormat, class WithFormat >+ */ >+template<typename Derived> >+inline const WithFormat<Derived> >+DenseBase<Derived>::format(const IOFormat& fmt) const >+{ >+ return WithFormat<Derived>(derived(), fmt); >+} >+ >+/** \relates DenseBase >+ * >+ * Outputs the matrix, to the given stream. >+ * >+ * If you wish to print the matrix with a format different than the default, use DenseBase::format(). >+ * >+ * It is also possible to change the default format by defining EIGEN_DEFAULT_IO_FORMAT before including Eigen headers. >+ * If not defined, this will automatically be defined to Eigen::IOFormat(), that is the Eigen::IOFormat with default parameters. >+ * >+ * \sa DenseBase::format() >+ */ >+template<typename Derived> >+std::ostream & operator << >+(std::ostream & s, >+ const DenseBase<Derived> & m) >+{ >+ return internal::print_matrix(s, m.eval(), EIGEN_DEFAULT_IO_FORMAT); >+} >+ > } // end namespace Eigen > > #endif // EIGEN_DENSEBASE_H >diff --git a/Eigen/src/Core/IO.h b/Eigen/src/Core/IO.h >--- a/Eigen/src/Core/IO.h >+++ b/Eigen/src/Core/IO.h >@@ -11,7 +11,7 @@ > #ifndef EIGEN_IO_H > #define EIGEN_IO_H > >-namespace Eigen { >+namespace Eigen { > > enum { DontAlignCols = 1 }; > enum { StreamPrecision = -1, >@@ -109,20 +109,6 @@ class WithFormat > IOFormat m_format; > }; > >-/** \returns a WithFormat proxy object allowing to print a matrix the with given >- * format \a fmt. >- * >- * See class IOFormat for some examples. >- * >- * \sa class IOFormat, class WithFormat >- */ >-template<typename Derived> >-inline const WithFormat<Derived> >-DenseBase<Derived>::format(const IOFormat& fmt) const >-{ >- return WithFormat<Derived>(derived(), fmt); >-} >- > namespace internal { > > // NOTE: This helper is kept for backward compatibility with previous code specializing >@@ -147,7 +133,7 @@ std::ostream & print_matrix(std::ostream > s << fmt.matPrefix << fmt.matSuffix; > return s; > } >- >+ > typename Derived::Nested m = _m; > typedef typename Derived::Scalar Scalar; > >@@ -212,28 +198,8 @@ std::ostream & print_matrix(std::ostream > if(explicit_precision) s.precision(old_precision); > return s; > } >- > } // end namespace internal > >-/** \relates DenseBase >- * >- * Outputs the matrix, to the given stream. >- * >- * If you wish to print the matrix with a format different than the default, use DenseBase::format(). >- * >- * It is also possible to change the default format by defining EIGEN_DEFAULT_IO_FORMAT before including Eigen headers. >- * If not defined, this will automatically be defined to Eigen::IOFormat(), that is the Eigen::IOFormat with default parameters. >- * >- * \sa DenseBase::format() >- */ >-template<typename Derived> >-std::ostream & operator << >-(std::ostream & s, >- const DenseBase<Derived> & m) >-{ >- return internal::print_matrix(s, m.eval(), EIGEN_DEFAULT_IO_FORMAT); >-} >- > } // end namespace Eigen > > #endif // EIGEN_IO_H
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 1391
: 775