SelfCwiseBinaryOp.h 1.66 KB
Newer Older
LM's avatar
LM committed
1 2 3 4 5
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// Copyright (C) 2009-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
//
Don Gagne's avatar
Don Gagne committed
6 7 8
// 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/.
LM's avatar
LM committed
9 10 11 12

#ifndef EIGEN_SELFCWISEBINARYOP_H
#define EIGEN_SELFCWISEBINARYOP_H

Don Gagne's avatar
Don Gagne committed
13 14
namespace Eigen { 

15
// TODO generalize the scalar type of 'other'
LM's avatar
LM committed
16

17 18
template<typename Derived>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::operator*=(const Scalar& other)
LM's avatar
LM committed
19
{
20 21
  internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::mul_assign_op<Scalar,Scalar>());
  return derived();
LM's avatar
LM committed
22 23
}

24 25
template<typename Derived>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& ArrayBase<Derived>::operator+=(const Scalar& other)
LM's avatar
LM committed
26
{
27 28 29
  internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::add_assign_op<Scalar,Scalar>());
  return derived();
}
LM's avatar
LM committed
30 31

template<typename Derived>
32
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& ArrayBase<Derived>::operator-=(const Scalar& other)
LM's avatar
LM committed
33
{
34
  internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::sub_assign_op<Scalar,Scalar>());
LM's avatar
LM committed
35 36 37 38
  return derived();
}

template<typename Derived>
39
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::operator/=(const Scalar& other)
LM's avatar
LM committed
40
{
41
  internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::div_assign_op<Scalar,Scalar>());
LM's avatar
LM committed
42 43 44
  return derived();
}

Don Gagne's avatar
Don Gagne committed
45 46
} // end namespace Eigen

LM's avatar
LM committed
47
#endif // EIGEN_SELFCWISEBINARYOP_H