SelfCwiseBinaryOp.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // This file is part of Eigen, a lightweight C++ template library
  2. // for linear algebra.
  3. //
  4. // Copyright (C) 2009-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
  5. //
  6. // This Source Code Form is subject to the terms of the Mozilla
  7. // Public License v. 2.0. If a copy of the MPL was not distributed
  8. // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
  9. #ifndef EIGEN_SELFCWISEBINARYOP_H
  10. #define EIGEN_SELFCWISEBINARYOP_H
  11. namespace Eigen {
  12. // TODO generalize the scalar type of 'other'
  13. template<typename Derived>
  14. EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::operator*=(const Scalar& other)
  15. {
  16. internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::mul_assign_op<Scalar,Scalar>());
  17. return derived();
  18. }
  19. template<typename Derived>
  20. EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& ArrayBase<Derived>::operator+=(const Scalar& other)
  21. {
  22. internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::add_assign_op<Scalar,Scalar>());
  23. return derived();
  24. }
  25. template<typename Derived>
  26. EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& ArrayBase<Derived>::operator-=(const Scalar& other)
  27. {
  28. internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::sub_assign_op<Scalar,Scalar>());
  29. return derived();
  30. }
  31. template<typename Derived>
  32. EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::operator/=(const Scalar& other)
  33. {
  34. internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::div_assign_op<Scalar,Scalar>());
  35. return derived();
  36. }
  37. } // end namespace Eigen
  38. #endif // EIGEN_SELFCWISEBINARYOP_H