fix compilation error thanks to test case by Trevor Irons, and expand unit test

This commit is contained in:
Benoit Jacob 2010-05-09 13:20:46 -04:00
parent 6624b93d67
commit 82d898083f
3 changed files with 10 additions and 4 deletions

View File

@ -22,8 +22,8 @@
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_COEFFS_H
#define EIGEN_COEFFS_H
#ifndef EIGEN_DENSECOEFFSBASE_H
#define EIGEN_DENSECOEFFSBASE_H
template<typename Derived, bool EnableDirectAccessAPI>
class DenseCoeffsBase : public EigenBase<Derived>
@ -599,4 +599,4 @@ struct ei_outer_stride_at_compile_time<Derived, false>
enum { ret = 0 };
};
#endif // EIGEN_COEFFS_H
#endif // EIGEN_DENSECOEFFSBASE_H

View File

@ -334,7 +334,7 @@ template<typename Scalar>
struct ei_scalar_imag_ref_op {
EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_imag_ref_op)
typedef typename NumTraits<Scalar>::Real result_type;
EIGEN_STRONG_INLINE result_type& operator() (Scalar& a) const { return ei_imag_ref(*const_cast<Scalar*>(&a)); }
EIGEN_STRONG_INLINE result_type& operator() (const Scalar& a) const { return ei_imag_ref(*const_cast<Scalar*>(&a)); }
};
template<typename Scalar>
struct ei_functor_traits<ei_scalar_imag_ref_op<Scalar> >

View File

@ -147,6 +147,12 @@ template<typename MatrixType> void basicStuffComplex(const MatrixType& m)
cm.imag() = rm2;
VERIFY_IS_APPROX(static_cast<const MatrixType&>(cm).real(), rm1);
VERIFY_IS_APPROX(static_cast<const MatrixType&>(cm).imag(), rm2);
rm1.setZero();
rm2.setZero();
rm1 = cm.real();
rm2 = cm.imag();
VERIFY_IS_APPROX(static_cast<const MatrixType&>(cm).real(), rm1);
VERIFY_IS_APPROX(static_cast<const MatrixType&>(cm).imag(), rm2);
cm.real().setZero();
VERIFY(static_cast<const MatrixType&>(cm).real().isZero());
VERIFY(!static_cast<const MatrixType&>(cm).imag().isZero());