1c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// This file is part of Eigen, a lightweight C++ template library 2c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// for linear algebra. 3c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// 4c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// Copyright (C) 2009-2010 Gael Guennebaud <gael.guennebaud@inria.fr> 5c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// 6c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// This Source Code Form is subject to the terms of the Mozilla 7c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// Public License v. 2.0. If a copy of the MPL was not distributed 8c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 10c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath#ifndef EIGEN_SELFCWISEBINARYOP_H 11c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath#define EIGEN_SELFCWISEBINARYOP_H 12c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 13c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathnamespace Eigen { 14c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 15c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \class SelfCwiseBinaryOp 16c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * \ingroup Core_Module 17c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * 18c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * \internal 19c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * 20c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * \brief Internal helper class for optimizing operators like +=, -= 21c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * 22c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * This is a pseudo expression class re-implementing the copyCoeff/copyPacket 23c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * method to directly performs a +=/-= operations in an optimal way. In particular, 24c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * this allows to make sure that the input/output data are loaded only once using 25c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * aligned packet loads. 26c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * 27c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * \sa class SwapWrapper for a similar trick. 28c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath */ 29c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 30c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathnamespace internal { 31c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename BinaryOp, typename Lhs, typename Rhs> 32c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathstruct traits<SelfCwiseBinaryOp<BinaryOp,Lhs,Rhs> > 33c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath : traits<CwiseBinaryOp<BinaryOp,Lhs,Rhs> > 34c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{ 35c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath enum { 36c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath // Note that it is still a good idea to preserve the DirectAccessBit 37c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath // so that assign can correctly align the data. 38c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath Flags = traits<CwiseBinaryOp<BinaryOp,Lhs,Rhs> >::Flags | (Lhs::Flags&DirectAccessBit) | (Lhs::Flags&LvalueBit), 39c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath OuterStrideAtCompileTime = Lhs::OuterStrideAtCompileTime, 40c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath InnerStrideAtCompileTime = Lhs::InnerStrideAtCompileTime 41c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath }; 42c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}; 43c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath} 44c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 45c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename BinaryOp, typename Lhs, typename Rhs> class SelfCwiseBinaryOp 46c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath : public internal::dense_xpr_base< SelfCwiseBinaryOp<BinaryOp, Lhs, Rhs> >::type 47c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{ 48c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath public: 49c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 50c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath typedef typename internal::dense_xpr_base<SelfCwiseBinaryOp>::type Base; 51c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath EIGEN_DENSE_PUBLIC_INTERFACE(SelfCwiseBinaryOp) 52c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 53c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath typedef typename internal::packet_traits<Scalar>::type Packet; 54c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 55c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline SelfCwiseBinaryOp(Lhs& xpr, const BinaryOp& func = BinaryOp()) : m_matrix(xpr), m_functor(func) {} 56c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 57c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline Index rows() const { return m_matrix.rows(); } 58c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline Index cols() const { return m_matrix.cols(); } 59c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline Index outerStride() const { return m_matrix.outerStride(); } 60c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline Index innerStride() const { return m_matrix.innerStride(); } 61c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline const Scalar* data() const { return m_matrix.data(); } 62c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 63c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath // note that this function is needed by assign to correctly align loads/stores 64c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath // TODO make Assign use .data() 65c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline Scalar& coeffRef(Index row, Index col) 66c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 67c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath EIGEN_STATIC_ASSERT_LVALUE(Lhs) 68c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath return m_matrix.const_cast_derived().coeffRef(row, col); 69c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 70c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline const Scalar& coeffRef(Index row, Index col) const 71c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 72c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath return m_matrix.coeffRef(row, col); 73c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 74c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 75c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath // note that this function is needed by assign to correctly align loads/stores 76c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath // TODO make Assign use .data() 77c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline Scalar& coeffRef(Index index) 78c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 79c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath EIGEN_STATIC_ASSERT_LVALUE(Lhs) 80c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath return m_matrix.const_cast_derived().coeffRef(index); 81c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 82c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline const Scalar& coeffRef(Index index) const 83c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 84c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath return m_matrix.const_cast_derived().coeffRef(index); 85c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 86c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 87c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath template<typename OtherDerived> 88c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath void copyCoeff(Index row, Index col, const DenseBase<OtherDerived>& other) 89c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 90c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath OtherDerived& _other = other.const_cast_derived(); 91c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath eigen_internal_assert(row >= 0 && row < rows() 92c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath && col >= 0 && col < cols()); 93c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath Scalar& tmp = m_matrix.coeffRef(row,col); 94c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath tmp = m_functor(tmp, _other.coeff(row,col)); 95c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 96c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 97c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath template<typename OtherDerived> 98c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath void copyCoeff(Index index, const DenseBase<OtherDerived>& other) 99c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 100c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath OtherDerived& _other = other.const_cast_derived(); 101c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath eigen_internal_assert(index >= 0 && index < m_matrix.size()); 102c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath Scalar& tmp = m_matrix.coeffRef(index); 103c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath tmp = m_functor(tmp, _other.coeff(index)); 104c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 105c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 106c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath template<typename OtherDerived, int StoreMode, int LoadMode> 107c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath void copyPacket(Index row, Index col, const DenseBase<OtherDerived>& other) 108c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 109c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath OtherDerived& _other = other.const_cast_derived(); 110c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath eigen_internal_assert(row >= 0 && row < rows() 111c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath && col >= 0 && col < cols()); 112c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath m_matrix.template writePacket<StoreMode>(row, col, 113c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath m_functor.packetOp(m_matrix.template packet<StoreMode>(row, col),_other.template packet<LoadMode>(row, col)) ); 114c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 115c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 116c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath template<typename OtherDerived, int StoreMode, int LoadMode> 117c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath void copyPacket(Index index, const DenseBase<OtherDerived>& other) 118c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 119c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath OtherDerived& _other = other.const_cast_derived(); 120c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath eigen_internal_assert(index >= 0 && index < m_matrix.size()); 121c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath m_matrix.template writePacket<StoreMode>(index, 122c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath m_functor.packetOp(m_matrix.template packet<StoreMode>(index),_other.template packet<LoadMode>(index)) ); 123c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 124c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 125c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath // reimplement lazyAssign to handle complex *= real 126c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath // see CwiseBinaryOp ctor for details 127c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath template<typename RhsDerived> 128c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath EIGEN_STRONG_INLINE SelfCwiseBinaryOp& lazyAssign(const DenseBase<RhsDerived>& rhs) 129c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 130c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Lhs,RhsDerived) 131c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath EIGEN_CHECK_BINARY_COMPATIBILIY(BinaryOp,typename Lhs::Scalar,typename RhsDerived::Scalar); 132c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 133c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath #ifdef EIGEN_DEBUG_ASSIGN 134c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath internal::assign_traits<SelfCwiseBinaryOp, RhsDerived>::debug(); 135c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath #endif 136c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath eigen_assert(rows() == rhs.rows() && cols() == rhs.cols()); 137c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath internal::assign_impl<SelfCwiseBinaryOp, RhsDerived>::run(*this,rhs.derived()); 138c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath #ifndef EIGEN_NO_DEBUG 139c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath this->checkTransposeAliasing(rhs.derived()); 140c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath #endif 141c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath return *this; 142c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 143c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 144c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath // overloaded to honor evaluation of special matrices 145c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath // maybe another solution would be to not use SelfCwiseBinaryOp 146c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath // at first... 147c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath SelfCwiseBinaryOp& operator=(const Rhs& _rhs) 148c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 149c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath typename internal::nested<Rhs>::type rhs(_rhs); 150c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath return Base::operator=(rhs); 151c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 152c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 153c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath Lhs& expression() const 154c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 155c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath return m_matrix; 156c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 157c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 158c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath const BinaryOp& functor() const 159c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 160c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath return m_functor; 161c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 162c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 163c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath protected: 164c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath Lhs& m_matrix; 165c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath const BinaryOp& m_functor; 166c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 167c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath private: 168c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath SelfCwiseBinaryOp& operator=(const SelfCwiseBinaryOp&); 169c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}; 170c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 171c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived> 172c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline Derived& DenseBase<Derived>::operator*=(const Scalar& other) 173c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{ 174c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath typedef typename Derived::PlainObject PlainObject; 175c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath SelfCwiseBinaryOp<internal::scalar_product_op<Scalar>, Derived, typename PlainObject::ConstantReturnType> tmp(derived()); 176c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath tmp = PlainObject::Constant(rows(),cols(),other); 177c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath return derived(); 178c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath} 179c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 180c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived> 181c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline Derived& DenseBase<Derived>::operator/=(const Scalar& other) 182c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{ 183c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath typedef typename internal::conditional<NumTraits<Scalar>::IsInteger, 184c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath internal::scalar_quotient_op<Scalar>, 185c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath internal::scalar_product_op<Scalar> >::type BinOp; 186c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath typedef typename Derived::PlainObject PlainObject; 187c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath SelfCwiseBinaryOp<BinOp, Derived, typename PlainObject::ConstantReturnType> tmp(derived()); 1887faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez Scalar actual_other; 1897faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez if(NumTraits<Scalar>::IsInteger) actual_other = other; 1907faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez else actual_other = Scalar(1)/other; 1917faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez tmp = PlainObject::Constant(rows(),cols(), actual_other); 192c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath return derived(); 193c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath} 194c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 195c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath} // end namespace Eigen 196c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 197c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath#endif // EIGEN_SELFCWISEBINARYOP_H 198