1// This file is part of Eigen, a lightweight C++ template library
2// for linear algebra.
3//
4// Copyright (C) 2007 Michael Olbrich <michael.olbrich@gmx.net>
5// Copyright (C) 2006-2010 Benoit Jacob <jacob.benoit.1@gmail.com>
6// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
7//
8// This Source Code Form is subject to the terms of the Mozilla
9// Public License v. 2.0. If a copy of the MPL was not distributed
10// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
11
12#ifndef EIGEN_ASSIGN_H
13#define EIGEN_ASSIGN_H
14
15namespace Eigen {
16
17template<typename Derived>
18template<typename OtherDerived>
19EIGEN_STRONG_INLINE Derived& DenseBase<Derived>
20 ::lazyAssign(const DenseBase<OtherDerived>& other)
21{
22 enum{
23 SameType = internal::is_same<typename Derived::Scalar,typename OtherDerived::Scalar>::value
24 };
25
26 EIGEN_STATIC_ASSERT_LVALUE(Derived)
27 EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Derived,OtherDerived)
28 EIGEN_STATIC_ASSERT(SameType,YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
29
30 eigen_assert(rows() == other.rows() && cols() == other.cols());
31 internal::call_assignment_no_alias(derived(),other.derived());
32
33 return derived();
34}
35
36template<typename Derived>
37template<typename OtherDerived>
38EIGEN_DEVICE_FUNC
39EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::operator=(const DenseBase<OtherDerived>& other)
40{
41 internal::call_assignment(derived(), other.derived());
42 return derived();
43}
44
45template<typename Derived>
46EIGEN_DEVICE_FUNC
47EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::operator=(const DenseBase& other)
48{
49 internal::call_assignment(derived(), other.derived());
50 return derived();
51}
52
53template<typename Derived>
54EIGEN_DEVICE_FUNC
55EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::operator=(const MatrixBase& other)
56{
57 internal::call_assignment(derived(), other.derived());
58 return derived();
59}
60
61template<typename Derived>
62template <typename OtherDerived>
63EIGEN_DEVICE_FUNC
64EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::operator=(const DenseBase<OtherDerived>& other)
65{
66 internal::call_assignment(derived(), other.derived());
67 return derived();
68}
69
70template<typename Derived>
71template <typename OtherDerived>
72EIGEN_DEVICE_FUNC
73EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::operator=(const EigenBase<OtherDerived>& other)
74{
75 internal::call_assignment(derived(), other.derived());
76 return derived();
77}
78
79template<typename Derived>
80template<typename OtherDerived>
81EIGEN_DEVICE_FUNC
82EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::operator=(const ReturnByValue<OtherDerived>& other)
83{
84 other.derived().evalTo(derived());
85 return derived();
86}
87
88} // end namespace Eigen
89
90#endif // EIGEN_ASSIGN_H
91