Assign.h 2.66 KB
Newer Older
LM's avatar
LM committed
1 2 3 4 5 6 7
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// Copyright (C) 2007 Michael Olbrich <michael.olbrich@gmx.net>
// Copyright (C) 2006-2010 Benoit Jacob <jacob.benoit.1@gmail.com>
// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
//
Don Gagne's avatar
Don Gagne committed
8 9 10
// 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
11 12 13 14

#ifndef EIGEN_ASSIGN_H
#define EIGEN_ASSIGN_H

Don Gagne's avatar
Don Gagne committed
15 16
namespace Eigen {

LM's avatar
LM committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30
template<typename Derived>
template<typename OtherDerived>
EIGEN_STRONG_INLINE Derived& DenseBase<Derived>
  ::lazyAssign(const DenseBase<OtherDerived>& other)
{
  enum{
    SameType = internal::is_same<typename Derived::Scalar,typename OtherDerived::Scalar>::value
  };

  EIGEN_STATIC_ASSERT_LVALUE(Derived)
  EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Derived,OtherDerived)
  EIGEN_STATIC_ASSERT(SameType,YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)

  eigen_assert(rows() == other.rows() && cols() == other.cols());
31 32
  internal::call_assignment_no_alias(derived(),other.derived());
  
LM's avatar
LM committed
33 34 35 36 37
  return derived();
}

template<typename Derived>
template<typename OtherDerived>
38
EIGEN_DEVICE_FUNC
LM's avatar
LM committed
39 40
EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::operator=(const DenseBase<OtherDerived>& other)
{
41 42
  internal::call_assignment(derived(), other.derived());
  return derived();
LM's avatar
LM committed
43 44 45
}

template<typename Derived>
46
EIGEN_DEVICE_FUNC
LM's avatar
LM committed
47 48
EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::operator=(const DenseBase& other)
{
49 50
  internal::call_assignment(derived(), other.derived());
  return derived();
LM's avatar
LM committed
51 52 53
}

template<typename Derived>
54
EIGEN_DEVICE_FUNC
LM's avatar
LM committed
55 56
EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::operator=(const MatrixBase& other)
{
57 58
  internal::call_assignment(derived(), other.derived());
  return derived();
LM's avatar
LM committed
59 60 61 62
}

template<typename Derived>
template <typename OtherDerived>
63
EIGEN_DEVICE_FUNC
LM's avatar
LM committed
64 65
EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::operator=(const DenseBase<OtherDerived>& other)
{
66 67
  internal::call_assignment(derived(), other.derived());
  return derived();
LM's avatar
LM committed
68 69 70 71
}

template<typename Derived>
template <typename OtherDerived>
72
EIGEN_DEVICE_FUNC
LM's avatar
LM committed
73 74
EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::operator=(const EigenBase<OtherDerived>& other)
{
75 76
  internal::call_assignment(derived(), other.derived());
  return derived();
LM's avatar
LM committed
77 78 79 80
}

template<typename Derived>
template<typename OtherDerived>
81
EIGEN_DEVICE_FUNC
LM's avatar
LM committed
82 83
EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::operator=(const ReturnByValue<OtherDerived>& other)
{
84 85
  other.derived().evalTo(derived());
  return derived();
LM's avatar
LM committed
86 87
}

Don Gagne's avatar
Don Gagne committed
88 89
} // end namespace Eigen

LM's avatar
LM committed
90
#endif // EIGEN_ASSIGN_H