Bugzilla – Attachment 664 Details for
Bug 408
block() does not allow recursion
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]
New version of the patch merging both previous ones
fuse_block_block_v3.diff (text/plain), 41.29 KB, created by
Gael Guennebaud
on 2016-03-07 14:55:45 UTC
(
hide
)
Description:
New version of the patch merging both previous ones
Filename:
MIME Type:
Creator:
Gael Guennebaud
Created:
2016-03-07 14:55:45 UTC
Size:
41.29 KB
patch
obsolete
># HG changeset patch ># Parent 277b14149f534d0db41a1af31dbc3de61256e081 > >diff --git a/Eigen/src/Core/Block.h b/Eigen/src/Core/Block.h >--- a/Eigen/src/Core/Block.h >+++ b/Eigen/src/Core/Block.h >@@ -1,12 +1,12 @@ > // This file is part of Eigen, a lightweight C++ template library > // for linear algebra. > // >-// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr> >+// Copyright (C) 2008-2016 Gael Guennebaud <gael.guennebaud@inria.fr> > // Copyright (C) 2006-2010 Benoit Jacob <jacob.benoit.1@gmail.com> > // > // This Source Code Form is subject to the terms of the Mozilla > // Public License v. 2.0. If a copy of the MPL was not distributed > // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. > > #ifndef EIGEN_BLOCK_H > #define EIGEN_BLOCK_H >@@ -49,17 +49,17 @@ struct traits<Block<XprType, BlockRows, > > // FIXME, this traits is rather specialized for dense object and it needs to be cleaned further > FlagsLvalueBit = is_lvalue<XprType>::value ? LvalueBit : 0, > FlagsRowMajorBit = IsRowMajor ? RowMajorBit : 0, > Flags = (traits<XprType>::Flags & (DirectAccessBit | (InnerPanel?CompressedAccessBit:0))) | FlagsLvalueBit | FlagsRowMajorBit, > // FIXME DirectAccessBit should not be handled by expressions > // > // Alignment is needed by MapBase's assertions >- // We can sefely set it to false here. Internal alignment errors will be detected by an eigen_internal_assert in the respective evaluator >+ // We can safely set it to false here. Internal alignment errors will be detected by an eigen_internal_assert in the respective evaluator > Alignment = 0 > }; > }; > > template<typename XprType, int BlockRows=Dynamic, int BlockCols=Dynamic, bool InnerPanel = false, > bool HasDirectAccess = internal::has_direct_access<XprType>::ret> class BlockImpl_dense; > > } // end namespace internal >@@ -141,19 +141,289 @@ template<typename XprType, int BlockRows > Index blockRows, Index blockCols) > : Impl(xpr, startRow, startCol, blockRows, blockCols) > { > eigen_assert((RowsAtCompileTime==Dynamic || RowsAtCompileTime==blockRows) > && (ColsAtCompileTime==Dynamic || ColsAtCompileTime==blockCols)); > eigen_assert(startRow >= 0 && blockRows >= 0 && startRow <= xpr.rows() - blockRows > && startCol >= 0 && blockCols >= 0 && startCol <= xpr.cols() - blockCols); > } >+ >+#ifndef EIGEN_PARSED_BY_DOXYGEN >+ typedef Block<XprType, internal::traits<Block>::RowsAtCompileTime, 1, InnerPanel && (!Base::IsRowMajor)> ColXpr; >+ typedef const Block<const XprType, internal::traits<Block>::RowsAtCompileTime, 1, InnerPanel && (!Base::IsRowMajor)> ConstColXpr; >+ typedef Block<XprType, 1, internal::traits<Block>::ColsAtCompileTime, InnerPanel && Base::IsRowMajor> RowXpr; >+ typedef const Block<const XprType, 1, internal::traits<Block>::ColsAtCompileTime, InnerPanel && Base::IsRowMajor> ConstRowXpr; >+ typedef Block<XprType, internal::traits<Block>::RowsAtCompileTime, Dynamic, InnerPanel && (!Base::IsRowMajor)> ColsBlockXpr; >+ typedef const Block<const XprType, internal::traits<Block>::RowsAtCompileTime, Dynamic, InnerPanel && (!Base::IsRowMajor)> ConstColsBlockXpr; >+ typedef Block<XprType, Dynamic, internal::traits<Block>::ColsAtCompileTime, InnerPanel && Base::IsRowMajor> RowsBlockXpr; >+ typedef const Block<const XprType, Dynamic, internal::traits<Block>::ColsAtCompileTime, InnerPanel && Base::IsRowMajor> ConstRowsBlockXpr; >+ template<int N> struct NColsBlockXpr { typedef Block<XprType, internal::traits<Block>::RowsAtCompileTime, N, InnerPanel && (!Base::IsRowMajor)> Type; }; >+ template<int N> struct ConstNColsBlockXpr { typedef const Block<const XprType, internal::traits<Block>::RowsAtCompileTime, N, InnerPanel && (!Base::IsRowMajor)> Type; }; >+ template<int N> struct NRowsBlockXpr { typedef Block<XprType, N, internal::traits<Block>::ColsAtCompileTime, InnerPanel && Base::IsRowMajor> Type; }; >+ template<int N> struct ConstNRowsBlockXpr { typedef const Block<const XprType, N, internal::traits<Block>::ColsAtCompileTime, InnerPanel && Base::IsRowMajor> Type; }; >+ typedef Block<XprType> BlockXpr; >+ typedef const Block<const XprType> ConstBlockXpr; >+ template<int Rows, int Cols> struct FixedBlockXpr { typedef Block<XprType,Rows,Cols> Type; }; >+ template<int Rows, int Cols> struct ConstFixedBlockXpr { typedef Block<const XprType,Rows,Cols> Type; }; >+ >+ enum { >+ IsColVector = internal::is_column_vector_at_compile_time<Block>::value >+ }; >+ >+ typedef VectorBlock<XprType, Dynamic, IsColVector> SegmentReturnType; >+ typedef const VectorBlock<const XprType, Dynamic, IsColVector> ConstSegmentReturnType; >+ template<int Size> struct FixedSegmentReturnType { typedef VectorBlock<XprType, Size, IsColVector> Type; }; >+ template<int Size> struct ConstFixedSegmentReturnType { typedef const VectorBlock<const XprType, Size, IsColVector> Type; }; >+ >+ using Base::rows; >+ using Base::cols; >+ using Base::size; >+ #define EIGEN_BLOCK_METHODS_SKIP_TYPEDEFS >+ typedef Block Derived; >+ #include "../plugins/BlockMethods.h" >+ #undef EIGEN_BLOCK_METHODS_SKIP_TYPEDEFS >+ >+ typedef typename internal::remove_const<XprType>::type XprTypeNonConst; >+ >+ template<int OtherRows,int OtherCols, bool OtherInnerPanel> >+ EIGEN_DEVICE_FUNC >+ inline Block( Block<XprTypeNonConst,OtherRows,OtherCols,OtherInnerPanel> &blk, Index i) >+ : Impl(blk.nestedExpression(), >+ blk.startRow() + ((BlockRows==1) && (BlockCols==Block<XprTypeNonConst,OtherRows,OtherCols,OtherInnerPanel>::ColsAtCompileTime) ? i : 0), >+ blk.startCol() + ((BlockRows==Block<XprTypeNonConst,OtherRows,OtherCols,OtherInnerPanel>::RowsAtCompileTime) && (BlockCols==1) ? i : 0), >+ BlockRows==1 ? 1 : blk.rows(), >+ BlockCols==1 ? 1 : blk.cols() >+ ) >+ { >+ eigen_assert( (i>=0) && ( >+ ((BlockRows==1) && (BlockCols==Block<XprTypeNonConst,OtherRows,OtherCols,OtherInnerPanel>::ColsAtCompileTime) && i<blk.rows()) >+ ||((BlockRows==Block<XprTypeNonConst,OtherRows,OtherCols,OtherInnerPanel>::RowsAtCompileTime) && (BlockCols==1) && i<blk.cols()))); >+ } >+ >+ template<int OtherRows,int OtherCols, bool OtherInnerPanel> >+ EIGEN_DEVICE_FUNC >+ inline Block(Block<XprTypeNonConst,OtherRows,OtherCols,OtherInnerPanel> &blk, Index startRow, Index startCol) >+ : Impl(blk.nestedExpression(), >+ blk.startRow() + startRow, >+ blk.startCol() + startCol) >+ { >+ EIGEN_STATIC_ASSERT(RowsAtCompileTime!=Dynamic && ColsAtCompileTime!=Dynamic,THIS_METHOD_IS_ONLY_FOR_FIXED_SIZE) >+ eigen_assert(startRow >= 0 && BlockRows >= 0 && startRow + BlockRows <= blk.rows() >+ && startCol >= 0 && BlockCols >= 0 && startCol + BlockCols <= blk.cols()); >+ } >+ >+ template<int OtherRows,int OtherCols, bool OtherInnerPanel> >+ EIGEN_DEVICE_FUNC >+ inline Block(Block<XprTypeNonConst,OtherRows,OtherCols,OtherInnerPanel> &blk, Index startRow, Index startCol, Index blockRows, Index blockCols) >+ : Impl(blk.nestedExpression(), blk.startRow() + startRow, blk.startCol() + startCol, blockRows, blockCols) >+ { >+ eigen_assert((RowsAtCompileTime==Dynamic || RowsAtCompileTime==blockRows) >+ && (ColsAtCompileTime==Dynamic || ColsAtCompileTime==blockCols)); >+ eigen_assert(startRow >= 0 && blockRows >= 0 && startRow <= blk.rows() - blockRows >+ && startCol >= 0 && blockCols >= 0 && startCol <= blk.cols() - blockCols); >+ } >+ >+ template<int OtherRows,int OtherCols, bool OtherInnerPanel> >+ EIGEN_DEVICE_FUNC >+ inline Block( const Block<XprTypeNonConst,OtherRows,OtherCols,OtherInnerPanel> &blk, Index i) >+ : Impl(blk.nestedExpression(), >+ blk.startRow() + ((BlockRows==1) && (BlockCols==Block<XprTypeNonConst,OtherRows,OtherCols,OtherInnerPanel>::ColsAtCompileTime) ? i : 0), >+ blk.startCol() + ((BlockRows==Block<XprTypeNonConst,OtherRows,OtherCols,OtherInnerPanel>::RowsAtCompileTime) && (BlockCols==1) ? i : 0), >+ BlockRows==1 ? 1 : blk.rows(), >+ BlockCols==1 ? 1 : blk.cols() >+ ) >+ { >+ eigen_assert( (i>=0) && ( >+ ((BlockRows==1) && (BlockCols==Block<XprTypeNonConst,OtherRows,OtherCols,OtherInnerPanel>::ColsAtCompileTime) && i<blk.rows()) >+ ||((BlockRows==Block<XprTypeNonConst,OtherRows,OtherCols,OtherInnerPanel>::RowsAtCompileTime) && (BlockCols==1) && i<blk.cols()))); >+ } >+ >+ template<int OtherRows,int OtherCols, bool OtherInnerPanel> >+ EIGEN_DEVICE_FUNC >+ inline Block(const Block<XprTypeNonConst,OtherRows,OtherCols,OtherInnerPanel> &blk, Index startRow, Index startCol) >+ : Impl(blk.nestedExpression(), >+ blk.startRow() + startRow, >+ blk.startCol() + startCol) >+ { >+ EIGEN_STATIC_ASSERT(RowsAtCompileTime!=Dynamic && ColsAtCompileTime!=Dynamic,THIS_METHOD_IS_ONLY_FOR_FIXED_SIZE) >+ eigen_assert(startRow >= 0 && BlockRows >= 0 && startRow + BlockRows <= blk.rows() >+ && startCol >= 0 && BlockCols >= 0 && startCol + BlockCols <= blk.cols()); >+ } >+ >+ template<int OtherRows,int OtherCols, bool OtherInnerPanel> >+ EIGEN_DEVICE_FUNC >+ inline Block(const Block<XprTypeNonConst,OtherRows,OtherCols,OtherInnerPanel> &blk, Index startRow, Index startCol, Index blockRows, Index blockCols) >+ : Impl(blk.nestedExpression(), blk.startRow() + startRow, blk.startCol() + startCol, blockRows, blockCols) >+ { >+ eigen_assert((RowsAtCompileTime==Dynamic || RowsAtCompileTime==blockRows) >+ && (ColsAtCompileTime==Dynamic || ColsAtCompileTime==blockCols)); >+ eigen_assert(startRow >= 0 && blockRows >= 0 && startRow <= blk.rows() - blockRows >+ && startCol >= 0 && blockCols >= 0 && startCol <= blk.cols() - blockCols); >+ } >+ >+ template<int OtherRows,int OtherCols, bool OtherInnerPanel> >+ EIGEN_DEVICE_FUNC >+ inline Block( const Block<const XprTypeNonConst,OtherRows,OtherCols,OtherInnerPanel> &blk, Index i) >+ : Impl(blk.nestedExpression(), >+ blk.startRow() + ((BlockRows==1) && (BlockCols==Block<XprTypeNonConst,OtherRows,OtherCols,OtherInnerPanel>::ColsAtCompileTime) ? i : 0), >+ blk.startCol() + ((BlockRows==Block<XprTypeNonConst,OtherRows,OtherCols,OtherInnerPanel>::RowsAtCompileTime) && (BlockCols==1) ? i : 0), >+ BlockRows==1 ? 1 : blk.rows(), >+ BlockCols==1 ? 1 : blk.cols() >+ ) >+ { >+ eigen_assert( (i>=0) && ( >+ ((BlockRows==1) && (BlockCols==Block<XprTypeNonConst,OtherRows,OtherCols,OtherInnerPanel>::ColsAtCompileTime) && i<blk.rows()) >+ ||((BlockRows==Block<XprTypeNonConst,OtherRows,OtherCols,OtherInnerPanel>::RowsAtCompileTime) && (BlockCols==1) && i<blk.cols()))); >+ } >+ >+ template<int OtherRows,int OtherCols, bool OtherInnerPanel> >+ EIGEN_DEVICE_FUNC >+ inline Block(const Block<const XprTypeNonConst,OtherRows,OtherCols,OtherInnerPanel> &blk, Index startRow, Index startCol) >+ : Impl(blk.nestedExpression(), >+ blk.startRow() + startRow, >+ blk.startCol() + startCol) >+ { >+ EIGEN_STATIC_ASSERT(RowsAtCompileTime!=Dynamic && ColsAtCompileTime!=Dynamic,THIS_METHOD_IS_ONLY_FOR_FIXED_SIZE) >+ eigen_assert(startRow >= 0 && BlockRows >= 0 && startRow + BlockRows <= blk.rows() >+ && startCol >= 0 && BlockCols >= 0 && startCol + BlockCols <= blk.cols()); >+ } >+ >+ template<int OtherRows,int OtherCols, bool OtherInnerPanel> >+ EIGEN_DEVICE_FUNC >+ inline Block(const Block<const XprTypeNonConst,OtherRows,OtherCols,OtherInnerPanel> &blk, Index startRow, Index startCol, Index blockRows, Index blockCols) >+ : Impl(blk.nestedExpression(), blk.startRow() + startRow, blk.startCol() + startCol, blockRows, blockCols) >+ { >+ eigen_assert((RowsAtCompileTime==Dynamic || RowsAtCompileTime==blockRows) >+ && (ColsAtCompileTime==Dynamic || ColsAtCompileTime==blockCols)); >+ eigen_assert(startRow >= 0 && blockRows >= 0 && startRow <= blk.rows() - blockRows >+ && startCol >= 0 && blockCols >= 0 && startCol <= blk.cols() - blockCols); >+ } >+#endif >+ > }; >- >-// The generic default implementation for dense block simplu forward to the internal::BlockImpl_dense >+ >+// Fuse any Block<Block<X>> expressions as a Block<X> expression >+// This is the non-const specialization >+template<typename XprType, int BlockRows0, int BlockCols0, bool InnerPanel0, int BlockRows, int BlockCols, bool InnerPanel> >+class Block<Block<XprType, BlockRows0, BlockCols0, InnerPanel0>, BlockRows, BlockCols, InnerPanel> >+ : public Block<XprType,BlockRows,BlockCols,InnerPanel && InnerPanel0> >+{ >+ typedef Block<XprType,BlockRows0,BlockCols0,InnerPanel0> ArgType; >+ typedef Block<XprType,BlockRows,BlockCols,InnerPanel && InnerPanel0> Base; >+public: >+ using Base::operator=; >+ >+ /** Column or Row constructor >+ */ >+ EIGEN_DEVICE_FUNC >+ template<typename OtherBlock> >+ inline Block(OtherBlock &blk, Index i) >+ : Base(blk.nestedExpression(), >+ blk.startRow() + ((BlockRows==1) && (BlockCols==ArgType::ColsAtCompileTime) ? i : 0), >+ blk.startCol() + ((BlockRows==ArgType::RowsAtCompileTime) && (BlockCols==1) ? i : 0), >+ BlockRows==1 ? 1 : blk.rows(), >+ BlockCols==1 ? 1 : blk.cols() >+ ) >+ { >+ eigen_assert( (i>=0) && ( >+ ((BlockRows==1) && (BlockCols==ArgType::ColsAtCompileTime) && i<blk.rows()) >+ ||((BlockRows==ArgType::RowsAtCompileTime) && (BlockCols==1) && i<blk.cols()))); >+ } >+ >+ /** Fixed-size constructor >+ */ >+ EIGEN_DEVICE_FUNC >+ template<typename OtherBlock> >+ inline Block(OtherBlock &blk, Index startRow, Index startCol) >+ : Base(blk.nestedExpression(), >+ blk.startRow() + startRow, >+ blk.startCol() + startCol) >+ { >+ EIGEN_STATIC_ASSERT(Base::RowsAtCompileTime!=Dynamic && Base::ColsAtCompileTime!=Dynamic,THIS_METHOD_IS_ONLY_FOR_FIXED_SIZE) >+ eigen_assert(startRow >= 0 && BlockRows >= 0 && startRow + BlockRows <= blk.rows() >+ && startCol >= 0 && BlockCols >= 0 && startCol + BlockCols <= blk.cols()); >+ } >+ >+ /** Dynamic-size constructor >+ */ >+ EIGEN_DEVICE_FUNC >+ template<typename OtherBlock> >+ inline Block(OtherBlock &blk, Index startRow, Index startCol, Index blockRows, Index blockCols) >+ : Base(blk.nestedExpression(), blk.startRow() + startRow, blk.startCol() + startCol, blockRows, blockCols) >+ { >+ eigen_assert((Base::RowsAtCompileTime==Dynamic || Base::RowsAtCompileTime==blockRows) >+ && (Base::ColsAtCompileTime==Dynamic || Base::ColsAtCompileTime==blockCols)); >+ eigen_assert(startRow >= 0 && blockRows >= 0 && startRow <= blk.rows() - blockRows >+ && startCol >= 0 && blockCols >= 0 && startCol <= blk.cols() - blockCols); >+ } >+ >+ // This ctor enable codes like Block<B> c = b.block(...) where B is already a Block. >+ EIGEN_DEVICE_FUNC >+ inline Block(const Base &blk) : Base(blk) {} >+}; >+ >+// Fuse any Block<const Block<X>> expressions as a Block<const X> expression >+// This is the const specialization >+template<typename XprType, int BlockRows0, int BlockCols0, bool InnerPanel0, int BlockRows, int BlockCols, bool InnerPanel> >+class Block<const Block<XprType, BlockRows0, BlockCols0, InnerPanel0>, BlockRows, BlockCols, InnerPanel> >+ : public Block<const XprType,BlockRows,BlockCols,InnerPanel && InnerPanel0> >+{ >+ typedef Block<XprType, BlockRows0, BlockCols0, InnerPanel0> ArgType; >+ typedef Block<const XprType,BlockRows,BlockCols,InnerPanel && InnerPanel0> Base; >+public: >+ using Base::operator=; >+ >+ /** Column or Row constructor >+ */ >+ EIGEN_DEVICE_FUNC >+ inline Block(const ArgType &blk, Index i) >+ : Base(blk.nestedExpression(), >+ blk.startRow() + ((BlockRows==1) && (BlockCols==ArgType::ColsAtCompileTime) ? i : 0), >+ blk.startCol() + ((BlockRows==ArgType::RowsAtCompileTime) && (BlockCols==1) ? i : 0), >+ BlockRows==1 ? 1 : blk.rows(), >+ BlockCols==1 ? 1 : blk.cols() >+ ) >+ { >+ eigen_assert( (i>=0) && ( >+ ((BlockRows==1) && (BlockCols==ArgType::ColsAtCompileTime) && i<blk.rows()) >+ ||((BlockRows==ArgType::RowsAtCompileTime) && (BlockCols==1) && i<blk.cols()))); >+ } >+ >+ /** Fixed-size constructor >+ */ >+ EIGEN_DEVICE_FUNC >+ inline Block(const ArgType &blk, Index startRow, Index startCol) >+ : Base(blk.nestedExpression(), >+ blk.startRow() + startRow, >+ blk.startCol() + startCol) >+ { >+ EIGEN_STATIC_ASSERT(Base::RowsAtCompileTime!=Dynamic && Base::ColsAtCompileTime!=Dynamic,THIS_METHOD_IS_ONLY_FOR_FIXED_SIZE) >+ eigen_assert(startRow >= 0 && BlockRows >= 0 && startRow + BlockRows <= blk.rows() >+ && startCol >= 0 && BlockCols >= 0 && startCol + BlockCols <= blk.cols()); >+ } >+ >+ /** Dynamic-size constructor >+ */ >+ EIGEN_DEVICE_FUNC >+ inline Block(const ArgType &blk, Index startRow, Index startCol, Index blockRows, Index blockCols) >+ : Base(blk.nestedExpression(), blk.startRow() + startRow, blk.startCol() + startCol, blockRows, blockCols) >+ { >+ eigen_assert((Base::RowsAtCompileTime==Dynamic || Base::RowsAtCompileTime==blockRows) >+ && (Base::ColsAtCompileTime==Dynamic || Base::ColsAtCompileTime==blockCols)); >+ eigen_assert(startRow >= 0 && blockRows >= 0 && startRow <= blk.rows() - blockRows >+ && startCol >= 0 && blockCols >= 0 && startCol <= blk.cols() - blockCols); >+ } >+ >+ // This ctor enable codes like Block<B> c = b.block(...) where B is already a Block. >+ EIGEN_DEVICE_FUNC >+ inline Block(const Base &blk) : Base(blk) {} >+}; >+ >+// The generic default implementation for dense block simply forward to the internal::BlockImpl_dense > // that must be specialized for direct and non-direct access... > template<typename XprType, int BlockRows, int BlockCols, bool InnerPanel> > class BlockImpl<XprType, BlockRows, BlockCols, InnerPanel, Dense> > : public internal::BlockImpl_dense<XprType, BlockRows, BlockCols, InnerPanel> > { > typedef internal::BlockImpl_dense<XprType, BlockRows, BlockCols, InnerPanel> Impl; > typedef typename XprType::StorageIndex StorageIndex; > public: >diff --git a/Eigen/src/Core/VectorBlock.h b/Eigen/src/Core/VectorBlock.h >--- a/Eigen/src/Core/VectorBlock.h >+++ b/Eigen/src/Core/VectorBlock.h >@@ -9,23 +9,20 @@ > // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. > > #ifndef EIGEN_VECTORBLOCK_H > #define EIGEN_VECTORBLOCK_H > > namespace Eigen { > > namespace internal { >-template<typename VectorType, int Size> >-struct traits<VectorBlock<VectorType, Size> > >- : public traits<Block<VectorType, >- traits<VectorType>::Flags & RowMajorBit ? 1 : Size, >- traits<VectorType>::Flags & RowMajorBit ? Size : 1> > >-{ >-}; >+template<typename VectorType, int Size, bool IsColVector> >+struct traits<VectorBlock<VectorType, Size, IsColVector> > >+ : public traits<Block<VectorType, IsColVector ? Size : 1, IsColVector ? 1 : Size> > >+{}; > } > > /** \class VectorBlock > * \ingroup Core_Module > * > * \brief Expression of a fixed-size or dynamic-size sub-vector > * > * \tparam VectorType the type of the object in which we are taking a sub-vector >@@ -48,27 +45,21 @@ struct traits<VectorBlock<VectorType, Si > * it does not cause a dynamic memory allocation. > * > * Here is an example illustrating the fixed-size case: > * \include class_FixedVectorBlock.cpp > * Output: \verbinclude class_FixedVectorBlock.out > * > * \sa class Block, DenseBase::segment(Index,Index,Index,Index), DenseBase::segment(Index,Index) > */ >-template<typename VectorType, int Size> class VectorBlock >- : public Block<VectorType, >- internal::traits<VectorType>::Flags & RowMajorBit ? 1 : Size, >- internal::traits<VectorType>::Flags & RowMajorBit ? Size : 1> >+template<typename VectorType, int Size, bool IsColVector> class VectorBlock >+ : public Block<VectorType, IsColVector ? Size : 1, IsColVector ? 1 : Size> > { >- typedef Block<VectorType, >- internal::traits<VectorType>::Flags & RowMajorBit ? 1 : Size, >- internal::traits<VectorType>::Flags & RowMajorBit ? Size : 1> Base; >- enum { >- IsColVector = !(internal::traits<VectorType>::Flags & RowMajorBit) >- }; >+ typedef Block<VectorType, IsColVector ? Size : 1, IsColVector ? 1 : Size> Base; >+ > public: > EIGEN_DENSE_PUBLIC_INTERFACE(VectorBlock) > > using Base::operator=; > > /** Dynamic-size constructor > */ > EIGEN_DEVICE_FUNC >@@ -83,14 +74,76 @@ template<typename VectorType, int Size> > /** Fixed-size constructor > */ > EIGEN_DEVICE_FUNC > inline VectorBlock(VectorType& vector, Index start) > : Base(vector, IsColVector ? start : 0, IsColVector ? 0 : start) > { > EIGEN_STATIC_ASSERT_VECTOR_ONLY(VectorBlock); > } >+ >+#ifndef EIGEN_PARSED_BY_DOXYGEN >+ typedef typename Base::XprTypeNonConst XprTypeNonConst; >+ template<int OtherRows,int OtherCols, bool OtherInnerPanel> >+ EIGEN_DEVICE_FUNC >+ inline VectorBlock(Block<XprTypeNonConst,OtherRows,OtherCols,OtherInnerPanel> &blk, Index start, Index size) >+ : Base(blk.nestedExpression(), >+ blk.startRow() + (IsColVector ? start : 0), >+ blk.startCol() + (IsColVector ? 0 : start), >+ IsColVector ? size : 1, IsColVector ? 1 : size) >+ { >+ EIGEN_STATIC_ASSERT_VECTOR_ONLY(VectorBlock); >+ } >+ >+ template<int OtherRows,int OtherCols, bool OtherInnerPanel> >+ EIGEN_DEVICE_FUNC >+ inline VectorBlock(Block<XprTypeNonConst,OtherRows,OtherCols,OtherInnerPanel> &blk, Index start) >+ : Base(blk.nestedExpression(), blk.startRow() + (IsColVector ? start : 0), blk.startCol() + (IsColVector ? 0 : start)) >+ { >+ EIGEN_STATIC_ASSERT_VECTOR_ONLY(VectorBlock); >+ } >+ >+ >+ template<int OtherRows,int OtherCols, bool OtherInnerPanel> >+ EIGEN_DEVICE_FUNC >+ inline VectorBlock(const Block<XprTypeNonConst,OtherRows,OtherCols,OtherInnerPanel> &blk, Index start, Index size) >+ : Base(blk.nestedExpression(), >+ blk.startRow() + (IsColVector ? start : 0), >+ blk.startCol() + (IsColVector ? 0 : start), >+ IsColVector ? size : 1, IsColVector ? 1 : size) >+ { >+ EIGEN_STATIC_ASSERT_VECTOR_ONLY(VectorBlock); >+ } >+ >+ template<int OtherRows,int OtherCols, bool OtherInnerPanel> >+ EIGEN_DEVICE_FUNC >+ inline VectorBlock(const Block<XprTypeNonConst,OtherRows,OtherCols,OtherInnerPanel> &blk, Index start) >+ : Base(blk.nestedExpression(), blk.startRow() + (IsColVector ? start : 0), blk.startCol() + (IsColVector ? 0 : start)) >+ { >+ EIGEN_STATIC_ASSERT_VECTOR_ONLY(VectorBlock); >+ } >+ >+ >+ template<int OtherRows,int OtherCols, bool OtherInnerPanel> >+ EIGEN_DEVICE_FUNC >+ inline VectorBlock(const Block<const XprTypeNonConst,OtherRows,OtherCols,OtherInnerPanel> &blk, Index start, Index size) >+ : Base(blk.nestedExpression(), >+ blk.startRow() + (IsColVector ? start : 0), >+ blk.startCol() + (IsColVector ? 0 : start), >+ IsColVector ? size : 1, IsColVector ? 1 : size) >+ { >+ EIGEN_STATIC_ASSERT_VECTOR_ONLY(VectorBlock); >+ } >+ >+ template<int OtherRows,int OtherCols, bool OtherInnerPanel> >+ EIGEN_DEVICE_FUNC >+ inline VectorBlock(const Block<const XprTypeNonConst,OtherRows,OtherCols,OtherInnerPanel> &blk, Index start) >+ : Base(blk.nestedExpression(), blk.startRow() + (IsColVector ? start : 0), blk.startCol() + (IsColVector ? 0 : start)) >+ { >+ EIGEN_STATIC_ASSERT_VECTOR_ONLY(VectorBlock); >+ } >+#endif > }; > > > } // end namespace Eigen > > #endif // EIGEN_VECTORBLOCK_H >diff --git a/Eigen/src/Core/util/ForwardDeclarations.h b/Eigen/src/Core/util/ForwardDeclarations.h >--- a/Eigen/src/Core/util/ForwardDeclarations.h >+++ b/Eigen/src/Core/util/ForwardDeclarations.h >@@ -35,16 +35,18 @@ template<typename Derived> struct access > : (has_write_access ? WriteAccessors : ReadOnlyAccessors) > }; > }; > > template<typename T> struct evaluator_traits; > > template< typename T> struct evaluator; > >+template<typename T> struct is_column_vector_at_compile_time; >+ > } // end namespace internal > > template<typename T> struct NumTraits; > > template<typename Derived> struct EigenBase; > template<typename Derived> class DenseBase; > template<typename Derived> class PlainObjectBase; > >@@ -79,17 +81,17 @@ template<typename Derived> class ArrayBa > template<typename ExpressionType, unsigned int Added, unsigned int Removed> class Flagged; > template<typename ExpressionType, template <typename> class StorageBase > class NoAlias; > template<typename ExpressionType> class NestByValue; > template<typename ExpressionType> class ForceAlignedAccess; > template<typename ExpressionType> class SwapWrapper; > > template<typename XprType, int BlockRows=Dynamic, int BlockCols=Dynamic, bool InnerPanel = false> class Block; > >-template<typename MatrixType, int Size=Dynamic> class VectorBlock; >+template<typename VectorType, int Size=Dynamic, bool IsColumnVector = internal::is_column_vector_at_compile_time<VectorType>::value> class VectorBlock; > template<typename MatrixType> class Transpose; > template<typename MatrixType> class Conjugate; > template<typename NullaryOp, typename MatrixType> class CwiseNullaryOp; > template<typename UnaryOp, typename MatrixType> class CwiseUnaryOp; > template<typename ViewOp, typename MatrixType> class CwiseUnaryView; > template<typename BinaryOp, typename Lhs, typename Rhs> class CwiseBinaryOp; > template<typename Decomposition, typename Rhstype> class Solve; > template<typename XprType> class Inverse; >diff --git a/Eigen/src/Core/util/XprHelper.h b/Eigen/src/Core/util/XprHelper.h >--- a/Eigen/src/Core/util/XprHelper.h >+++ b/Eigen/src/Core/util/XprHelper.h >@@ -223,16 +223,25 @@ template<int _Rows, int _Cols> struct si > enum { ret = (_Rows==Dynamic || _Cols==Dynamic) ? Dynamic : _Rows * _Cols }; > }; > > template<typename XprType> struct size_of_xpr_at_compile_time > { > enum { ret = size_at_compile_time<traits<XprType>::RowsAtCompileTime,traits<XprType>::ColsAtCompileTime>::ret }; > }; > >+template<typename T> struct is_column_vector_at_compile_time >+{ >+ enum { >+ value = (internal::traits<T>::ColsAtCompileTime==1 && internal::traits<T>::RowsAtCompileTime==1) >+ ? (!(internal::traits<T>::Flags & RowMajorBit)) >+ : (internal::traits<T>::ColsAtCompileTime==1) >+ }; >+}; >+ > /* plain_matrix_type : the difference from eval is that plain_matrix_type is always a plain matrix type, > * whereas eval is a const reference in the case of a matrix > */ > > template<typename T, typename StorageKind = typename traits<T>::StorageKind> struct plain_matrix_type; > template<typename T, typename BaseClassType, int Flags> struct plain_matrix_type_dense; > template<typename T> struct plain_matrix_type<T,Dense> > { >@@ -656,17 +665,17 @@ bool is_same_dense(const T1 &, const T2 > return false; > } > > template<typename T, typename U> struct is_same_or_void { enum { value = is_same<T,U>::value }; }; > template<typename T> struct is_same_or_void<void,T> { enum { value = 1 }; }; > template<typename T> struct is_same_or_void<T,void> { enum { value = 1 }; }; > template<> struct is_same_or_void<void,void> { enum { value = 1 }; }; > >-#ifdef EIGEN_DEBUG_ASSIGN >+#if defined EIGEN_DEBUG_ASSIGN || defined EIGEN_DEBUG_DEMANGLING > std::string demangle_traversal(int t) > { > if(t==DefaultTraversal) return "DefaultTraversal"; > if(t==LinearTraversal) return "LinearTraversal"; > if(t==InnerVectorizedTraversal) return "InnerVectorizedTraversal"; > if(t==LinearVectorizedTraversal) return "LinearVectorizedTraversal"; > if(t==SliceVectorizedTraversal) return "SliceVectorizedTraversal"; > return "?"; >diff --git a/Eigen/src/plugins/BlockMethods.h b/Eigen/src/plugins/BlockMethods.h >--- a/Eigen/src/plugins/BlockMethods.h >+++ b/Eigen/src/plugins/BlockMethods.h >@@ -5,16 +5,17 @@ > // Copyright (C) 2006-2010 Benoit Jacob <jacob.benoit.1@gmail.com> > // > // This Source Code Form is subject to the terms of the Mozilla > // Public License v. 2.0. If a copy of the MPL was not distributed > // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. > > #ifndef EIGEN_PARSED_BY_DOXYGEN > >+#ifndef EIGEN_BLOCK_METHODS_SKIP_TYPEDEFS > /** \internal expression type of a column */ > typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, 1, !IsRowMajor> ColXpr; > typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, 1, !IsRowMajor> ConstColXpr; > /** \internal expression type of a row */ > typedef Block<Derived, 1, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> RowXpr; > typedef const Block<const Derived, 1, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> ConstRowXpr; > /** \internal expression type of a block of whole columns */ > typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, Dynamic, !IsRowMajor> ColsBlockXpr; >@@ -34,16 +35,17 @@ typedef const Block<const Derived> Const > /** \internal expression of a block of fixed sizes */ > template<int Rows, int Cols> struct FixedBlockXpr { typedef Block<Derived,Rows,Cols> Type; }; > template<int Rows, int Cols> struct ConstFixedBlockXpr { typedef Block<const Derived,Rows,Cols> Type; }; > > typedef VectorBlock<Derived> SegmentReturnType; > typedef const VectorBlock<const Derived> ConstSegmentReturnType; > template<int Size> struct FixedSegmentReturnType { typedef VectorBlock<Derived, Size> Type; }; > template<int Size> struct ConstFixedSegmentReturnType { typedef const VectorBlock<const Derived, Size> Type; }; >+#endif > > #endif // not EIGEN_PARSED_BY_DOXYGEN > > /** \returns a dynamic-size expression of a block in *this. > * > * \param startRow the first row in the block > * \param startCol the first column in the block > * \param blockRows the number of rows in the block >diff --git a/test/block.cpp b/test/block.cpp >--- a/test/block.cpp >+++ b/test/block.cpp >@@ -3,16 +3,17 @@ > // > // Copyright (C) 2006-2010 Benoit Jacob <jacob.benoit.1@gmail.com> > // > // This Source Code Form is subject to the terms of the Mozilla > // Public License v. 2.0. If a copy of the MPL was not distributed > // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. > > #define EIGEN_NO_STATIC_ASSERT // otherwise we fail at compile time on unused paths >+#define EIGEN_DEBUG_DEMANGLING > #include "main.h" > > template<typename MatrixType, typename Index, typename Scalar> > typename Eigen::internal::enable_if<!NumTraits<typename MatrixType::Scalar>::IsComplex,typename MatrixType::Scalar>::type > block_real_only(const MatrixType &m1, Index r1, Index r2, Index c1, Index c2, const Scalar& s1) { > // check cwise-Functions: > VERIFY_IS_APPROX(m1.row(r1).cwiseMax(s1), m1.cwiseMax(s1).row(r1)); > VERIFY_IS_APPROX(m1.col(c1).cwiseMin(s1), m1.cwiseMin(s1).col(c1)); >@@ -183,16 +184,202 @@ template<typename MatrixType> void block > VERIFY_IS_EQUAL(dv, dm); > > VERIFY_IS_EQUAL( (m1.template block<Dynamic,1>(1,0,0,1)), m1.block(1,0,0,1)); > VERIFY_IS_EQUAL( (m1.template block<1,Dynamic>(0,1,1,0)), m1.block(0,1,1,0)); > VERIFY_IS_EQUAL( ((m1*1).template block<Dynamic,1>(1,0,0,1)), m1.block(1,0,0,1)); > VERIFY_IS_EQUAL( ((m1*1).template block<1,Dynamic>(0,1,1,0)), m1.block(0,1,1,0)); > } > >+template<typename T> >+bool same_type(const T&, const T&) { return true; } >+ >+template<typename Expr, typename Ref, typename ExprFused> >+void checkbb(const DenseBase<Expr> &a_xpr, const DenseBase<Ref> &a_ref, const DenseBase<ExprFused> &a_xprfused) >+{ >+ const Expr& xpr(a_xpr.derived()); >+ const Ref& ref(a_ref.derived()); >+ const ExprFused& xprfused(a_xprfused.derived()); >+ >+ VERIFY_IS_APPROX(xprfused, ref); >+ >+ VERIFY(same_type<ExprFused>(xpr, xprfused)); >+ >+ if(ExprFused::Flags!=Expr::Flags) >+ std::cerr << "Expected: " << internal::demangle_flags(ExprFused::Flags) << std::endl >+ << "Got: " << internal::demangle_flags(Expr::Flags) << std::endl; >+ >+ VERIFY_IS_EQUAL(ExprFused::Flags, Expr::Flags); >+ VERIFY_IS_EQUAL(ExprFused::RowsAtCompileTime, Expr::RowsAtCompileTime); >+ VERIFY_IS_EQUAL(ExprFused::ColsAtCompileTime, Expr::ColsAtCompileTime); >+ VERIFY_IS_EQUAL(ExprFused::MaxRowsAtCompileTime, Expr::MaxRowsAtCompileTime); >+ VERIFY_IS_EQUAL(ExprFused::MaxColsAtCompileTime, Expr::MaxColsAtCompileTime); >+ >+ typedef internal::evaluator<ExprFused> EvalFused; >+ typedef internal::evaluator<Expr> EvalExpr; >+ VERIFY_IS_EQUAL(EvalFused::Flags, EvalExpr::Flags); >+ VERIFY_IS_EQUAL(EvalFused::Alignment, EvalExpr::Alignment); >+ >+ VERIFY_IS_APPROX(xpr.derived(), ref); >+ VERIFY_IS_APPROX(xpr, ref); >+} >+ >+template<typename MatrixType> >+void block_rec(const MatrixType& a) >+{ >+ if(a.cols()>1) >+ { >+ block_rec(a.leftCols(a.cols()/2)); >+ block_rec(a.rightCols(a.cols()/2)); >+ } >+} >+ >+template<typename T> const T& make_const(const T& x) { return x; } >+ >+template<typename MatrixType> >+void check_block_block_fusion(const MatrixType &m) >+{ >+ Index rows = m.rows(); >+ Index cols = m.cols(); >+ >+ MatrixType m1 = MatrixType::Random(rows, cols), >+ m2 = MatrixType::Random(rows, cols); >+ >+ Index r1 = internal::random<Index>(0,rows-1); >+ Index c1 = internal::random<Index>(0,cols-1); >+ Index nr1 = internal::random<Index>(1,rows-r1); >+ Index nc1 = internal::random<Index>(1,cols-c1); >+ >+ Index r2 = internal::random<Index>(0,nr1-1); >+ Index c2 = internal::random<Index>(0,nc1-1); >+ Index nr2 = internal::random<Index>(1,nr1-r2); >+ Index nc2 = internal::random<Index>(1,nc1-c2); >+ >+ CALL_SUBTEST( checkbb(m1.block(r1,c1, nr1,nc1).block(r2,c2,nr2,nc2), >+ m1.block(r1,c1, nr1,nc1).eval().block(r2,c2,nr2,nc2).eval(), >+ m1.block(r1+r2, c1+c2, nr2, nc2)) ); >+ CALL_SUBTEST( checkbb(make_const(m1.block(r1,c1, nr1,nc1)).block(r2,c2,nr2,nc2), >+ m1.block(r1,c1, nr1,nc1).eval().block(r2,c2,nr2,nc2).eval(), >+ make_const(m1).block(r1+r2, c1+c2, nr2, nc2)) ); >+ CALL_SUBTEST( checkbb((m1+m2).block(r1,c1, nr1,nc1).block(r2,c2,nr2,nc2), >+ (m1+m2).block(r1,c1, nr1,nc1).eval().block(r2,c2,nr2,nc2).eval(), >+ (m1+m2).block(r1+r2, c1+c2, nr2, nc2)) ); >+ >+ CALL_SUBTEST( checkbb(m1.block(r1,c1, nr1,nc1).row(r2), >+ m1.block(r1,c1, nr1,nc1).eval().row(r2).eval(), >+ m1.template block<1,Dynamic>(r1+r2, c1, 1, nc1)) ); >+ CALL_SUBTEST( checkbb(make_const(m1.block(r1,c1, nr1,nc1)).row(r2), >+ m1.block(r1,c1, nr1,nc1).eval().row(r2).eval(), >+ make_const(m1).template block<1,Dynamic>(r1+r2, c1, 1, nc1)) ); >+ CALL_SUBTEST( checkbb((m1+m2).block(r1,c1, nr1,nc1).row(r2), >+ (m1+m2).block(r1,c1, nr1,nc1).eval().row(r2).eval(), >+ (m1+m2).template block<1,Dynamic>(r1+r2, c1, 1, nc1)) ); >+ >+ CALL_SUBTEST( checkbb(m1.block(r1,c1, nr1,nc1).col(c2), >+ m1.block(r1,c1, nr1,nc1).eval().col(c2).eval(), >+ m1.template block<Dynamic,1>(r1, c1+c2, nr1, 1)) ); >+ CALL_SUBTEST( checkbb(make_const(m1.block(r1,c1, nr1,nc1)).col(c2), >+ m1.block(r1,c1, nr1,nc1).eval().col(c2).eval(), >+ make_const(m1).template block<Dynamic,1>(r1, c1+c2, nr1, 1)) ); >+ CALL_SUBTEST( checkbb((m1+m2).block(r1,c1, nr1,nc1).col(c2), >+ (m1+m2).block(r1,c1, nr1,nc1).eval().col(c2).eval(), >+ (m1+m2).template block<Dynamic,1>(r1, c1+c2, nr1, 1)) ); >+ >+ CALL_SUBTEST( checkbb(m1.row(r1).segment(c1,nc1), >+ m1.row(r1).eval().segment(c1,nc1).eval(), >+ m1.template block<1,Dynamic>(r1, c1, 1, nc1)) ); >+ CALL_SUBTEST( checkbb(make_const(m1.row(r1)).segment(c1,nc1), >+ m1.row(r1).eval().segment(c1,nc1).eval(), >+ make_const(m1).template block<1,Dynamic>(r1, c1, 1, nc1)) ); >+ CALL_SUBTEST( checkbb((m1+m2).row(r1).segment(c1,nc1), >+ (m1+m2).row(r1).eval().segment(c1,nc1).eval(), >+ (m1+m2).template block<1,Dynamic>(r1, c1, 1, nc1)) ); >+ >+ CALL_SUBTEST( checkbb(m1.col(c1).segment(r1,nr1), >+ m1.col(c1).eval().segment(r1,nr1).eval(), >+ m1.template block<Dynamic,1>(r1, c1, nr1, 1)) ); >+ CALL_SUBTEST( checkbb(make_const(m1.col(c1)).segment(r1,nr1), >+ m1.col(c1).eval().segment(r1,nr1).eval(), >+ make_const(m1).template block<Dynamic,1>(r1, c1, nr1, 1)) ); >+ CALL_SUBTEST( checkbb((m1+m2).col(c1).segment(r1,nr1), >+ (m1+m2).col(c1).eval().segment(r1,nr1).eval(), >+ (m1+m2).template block<Dynamic,1>(r1, c1, nr1, 1)) ); >+ >+ CALL_SUBTEST( checkbb(m1.middleCols(c1,nc1).col(c2).segment(r1,nr1), >+ m1.middleCols(c1,nc1).eval().col(c2).eval().segment(r1,nr1).eval(), >+ m1.template block<Dynamic,1>(r1, c1+c2, nr1, 1)) ); >+ CALL_SUBTEST( checkbb(make_const(m1.middleCols(c1,nc1)).col(c2).segment(r1,nr1), >+ m1.middleCols(c1,nc1).eval().col(c2).eval().segment(r1,nr1).eval(), >+ make_const(m1).template block<Dynamic,1>(r1, c1+c2, nr1, 1)) ); >+ CALL_SUBTEST( checkbb(make_const(m1.middleCols(c1,nc1).col(c2)).segment(r1,nr1), >+ m1.middleCols(c1,nc1).eval().col(c2).eval().segment(r1,nr1).eval(), >+ make_const(m1).template block<Dynamic,1>(r1, c1+c2, nr1, 1)) ); >+ CALL_SUBTEST( checkbb((m1+m2).middleCols(c1,nc1).col(c2).segment(r1,nr1), >+ (m1+m2).middleCols(c1,nc1).eval().col(c2).eval().segment(r1,nr1).eval(), >+ (m1+m2).template block<Dynamic,1>(r1, c1+c2, nr1, 1)) ); >+ >+ CALL_SUBTEST( checkbb(m1.row(r1).col(c1), >+ m1.row(r1).eval().col(c1).eval(), >+ m1.template block<1,1>(r1, c1)) ); >+ CALL_SUBTEST( checkbb(make_const(m1.row(r1)).col(c1), >+ m1.row(r1).eval().col(c1).eval(), >+ make_const(m1).template block<1,1>(r1, c1)) ); >+ CALL_SUBTEST( checkbb((m1+m2).row(r1).col(c1), >+ (m1+m2).row(r1).eval().col(c1).eval(), >+ (m1+m2).template block<1,1>(r1, c1)) ); >+ >+ CALL_SUBTEST( checkbb(m1.row(r1).col(c1).segment(0,1), >+ m1.row(r1).eval().col(c1).eval().segment(0,1).eval(), >+ m1.template block<Dynamic,1>(r1, c1, 1,1)) ); >+ CALL_SUBTEST( checkbb(make_const(m1.row(r1)).col(c1).segment(0,1), >+ m1.row(r1).eval().col(c1).eval().segment(0,1).eval(), >+ make_const(m1).template block<Dynamic,1>(r1, c1, 1,1)) ); >+ CALL_SUBTEST( checkbb(make_const(m1.row(r1).col(c1)).segment(0,1), >+ m1.row(r1).eval().col(c1).eval().segment(0,1).eval(), >+ make_const(m1).template block<Dynamic,1>(r1, c1, 1,1)) ); >+ CALL_SUBTEST( checkbb((m1+m2).row(r1).col(c1).segment(0,1), >+ (m1+m2).row(r1).eval().col(c1).eval().segment(0,1).eval(), >+ (m1+m2).template block<Dynamic,1>(r1, c1, 1,1)) ); >+ >+ block_rec(m1); >+ block_rec(m1+m2); >+ block_rec(m1.transpose()); >+ >+ >+ // Check compatibility with hand-writen Block<Block<> > expression. >+ { >+ typedef Block<MatrixType> B; >+ B m11 = m1.block(r1,c1,nr1,nc1); >+ Block<B> m111 = m11.block(r2,c2,nr2,nc2); >+ VERIFY_IS_APPROX(m111, m1.block(r1+r2,c1+c2, nr2, nc2)); >+ >+ Block<B> m112(m11,r2,c2,nr2,nc2); >+ VERIFY_IS_APPROX(m112, m1.block(r1+r2,c1+c2, nr2, nc2)); >+ CALL_SUBTEST( checkbb(m112, m1.block(r1+r2,c1+c2, nr2, nc2), m1.block(r1+r2,c1+c2, nr2, nc2)) ); >+ >+ typename B::BlockXpr m113 = m11.block(r2,c2,nr2,nc2); >+ VERIFY_IS_APPROX(m113, m1.block(r1+r2,c1+c2, nr2, nc2)); >+ CALL_SUBTEST( checkbb(m113, m1.block(r1+r2,c1+c2, nr2, nc2), m1.block(r1+r2,c1+c2, nr2, nc2)) ); >+ } >+ >+ // Check preservation of max-sizes >+ if(m1.rows()>=2 && m2.cols()>=2) { >+ >+ typedef Block<MatrixType,2,2> B; >+ B m3(m1,0,0); >+ VERIFY_IS_EQUAL(m3.MaxRowsAtCompileTime, 2); >+ VERIFY_IS_EQUAL(m3.MaxColsAtCompileTime, 2); >+ VERIFY_IS_EQUAL((m3.block(0,0,1,1)).MaxRowsAtCompileTime, 2); >+ VERIFY_IS_EQUAL((m3.block(0,0,1,1)).MaxColsAtCompileTime, 2); >+ >+ VERIFY_IS_EQUAL((m1.template block<2,2>(0,0).block(0,0,1,1)).MaxRowsAtCompileTime, 2); >+ VERIFY_IS_EQUAL((m1.template block<2,2>(0,0).block(0,0,1,1)).MaxColsAtCompileTime, 2); >+ >+ } >+} > > template<typename MatrixType> > void compare_using_data_and_stride(const MatrixType& m) > { > typedef typename MatrixType::Index Index; > Index rows = m.rows(); > Index cols = m.cols(); > Index size = m.size(); >@@ -251,14 +438,23 @@ void test_block() > CALL_SUBTEST_2( block(Matrix4d()) ); > CALL_SUBTEST_3( block(MatrixXcf(3, 3)) ); > CALL_SUBTEST_4( block(MatrixXi(8, 12)) ); > CALL_SUBTEST_5( block(MatrixXcd(20, 20)) ); > CALL_SUBTEST_6( block(MatrixXf(20, 20)) ); > > CALL_SUBTEST_8( block(Matrix<float,Dynamic,4>(3, 4)) ); > >+ CALL_SUBTEST_9( check_block_block_fusion(MatrixXi(internal::random(1,50), internal::random(1,50))) ); >+ CALL_SUBTEST_9( check_block_block_fusion(Matrix4i()) ); >+ CALL_SUBTEST_9( check_block_block_fusion(Matrix3i()) ); >+ >+ CALL_SUBTEST_9( check_block_block_fusion(MatrixXd(internal::random(1,50), internal::random(1,50))) ); >+ CALL_SUBTEST_9( check_block_block_fusion(Matrix4d()) ); >+ CALL_SUBTEST_9( check_block_block_fusion(Matrix3d()) ); >+ CALL_SUBTEST_9( check_block_block_fusion(Matrix2d()) ); >+ > #ifndef EIGEN_DEFAULT_TO_ROW_MAJOR > CALL_SUBTEST_6( data_and_stride(MatrixXf(internal::random(5,50), internal::random(5,50))) ); > CALL_SUBTEST_7( data_and_stride(Matrix<int,Dynamic,Dynamic,RowMajor>(internal::random(5,50), internal::random(5,50))) ); > #endif > } > }
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 408
:
655
|
660
| 664