Fix bug #654: allow implicit transposition in Array to Matrix and Matrix to Array constructors
diff --git a/Eigen/src/Core/Array.h b/Eigen/src/Core/Array.h index 3d03508..0b9c38c 100644 --- a/Eigen/src/Core/Array.h +++ b/Eigen/src/Core/Array.h
@@ -225,7 +225,7 @@ : Base(other.derived().rows() * other.derived().cols(), other.derived().rows(), other.derived().cols()) { Base::_check_template_params(); - Base::resize(other.rows(), other.cols()); + Base::_resize_to_match(other); *this = other; }
diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h index 8dba1bf..02be142 100644 --- a/Eigen/src/Core/Matrix.h +++ b/Eigen/src/Core/Matrix.h
@@ -319,7 +319,7 @@ : Base(other.derived().rows() * other.derived().cols(), other.derived().rows(), other.derived().cols()) { Base::_check_template_params(); - Base::resize(other.rows(), other.cols()); + Base::_resize_to_match(other); // FIXME/CHECK: isn't *this = other.derived() more efficient. it allows to // go for pure _set() implementations, right? *this = other;
diff --git a/test/array_for_matrix.cpp b/test/array_for_matrix.cpp index 1250c9f..67e7a2a 100644 --- a/test/array_for_matrix.cpp +++ b/test/array_for_matrix.cpp
@@ -202,6 +202,12 @@ VERIFY(a1.size()==cols); } +void regression_bug_654() +{ + ArrayXf a = RowVectorXf(3); + VectorXf v = Array<float,1,Dynamic>(3); +} + void test_array_for_matrix() { for(int i = 0; i < g_repeat; i++) { @@ -239,4 +245,5 @@ CALL_SUBTEST_5( resize(MatrixXf(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) ); CALL_SUBTEST_6( resize(MatrixXi(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) ); } + CALL_SUBTEST_6( regression_bug_654() ); }