Lines 699-756
class PlainObjectBase : public internal:
Link Here
|
699 |
&& (internal::is_same<T1,Index>::value) |
699 |
&& (internal::is_same<T1,Index>::value) |
700 |
&& Base::SizeAtCompileTime==2,T1>::type* = 0) |
700 |
&& Base::SizeAtCompileTime==2,T1>::type* = 0) |
701 |
{ |
701 |
{ |
702 |
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 2) |
702 |
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 2) |
703 |
m_storage.data()[0] = Scalar(val0); |
703 |
m_storage.data()[0] = Scalar(val0); |
704 |
m_storage.data()[1] = Scalar(val1); |
704 |
m_storage.data()[1] = Scalar(val1); |
705 |
} |
705 |
} |
706 |
|
706 |
|
|
|
707 |
// The argument is convertible to the Index type and we either have a non 1x1 Matrix, or a dynamic-sized Array, |
708 |
// then the argument is meant to be the size of the object. |
707 |
template<typename T> |
709 |
template<typename T> |
708 |
EIGEN_DEVICE_FUNC |
710 |
EIGEN_DEVICE_FUNC |
709 |
EIGEN_STRONG_INLINE void _init1(Index size, typename internal::enable_if<Base::SizeAtCompileTime!=1 || !internal::is_convertible<T, Scalar>::value,T>::type* = 0) |
711 |
EIGEN_STRONG_INLINE void _init1(Index size, typename internal::enable_if< (Base::SizeAtCompileTime!=1 || !internal::is_convertible<T, Scalar>::value) |
|
|
712 |
&& ((!internal::is_same<typename internal::traits<Derived>::XprKind,ArrayXpr>::value || Base::SizeAtCompileTime==Dynamic)),T>::type* = 0) |
710 |
{ |
713 |
{ |
711 |
// NOTE MSVC 2008 complains if we directly put bool(NumTraits<T>::IsInteger) as the EIGEN_STATIC_ASSERT argument. |
714 |
// NOTE MSVC 2008 complains if we directly put bool(NumTraits<T>::IsInteger) as the EIGEN_STATIC_ASSERT argument. |
712 |
const bool is_integer = NumTraits<T>::IsInteger; |
715 |
const bool is_integer = NumTraits<T>::IsInteger; |
713 |
EIGEN_STATIC_ASSERT(is_integer, |
716 |
EIGEN_STATIC_ASSERT(is_integer, |
714 |
FLOATING_POINT_ARGUMENT_PASSED__INTEGER_WAS_EXPECTED) |
717 |
FLOATING_POINT_ARGUMENT_PASSED__INTEGER_WAS_EXPECTED) |
715 |
resize(size); |
718 |
resize(size); |
716 |
} |
719 |
} |
|
|
720 |
|
721 |
// We have a 1x1 matrix/array => the argument is interpreted as the value of the unique coefficient (case where scalar type can be implicitely converted) |
717 |
template<typename T> |
722 |
template<typename T> |
718 |
EIGEN_DEVICE_FUNC |
723 |
EIGEN_DEVICE_FUNC |
719 |
EIGEN_STRONG_INLINE void _init1(const Scalar& val0, typename internal::enable_if<Base::SizeAtCompileTime==1 && internal::is_convertible<T, Scalar>::value,T>::type* = 0) |
724 |
EIGEN_STRONG_INLINE void _init1(const Scalar& val0, typename internal::enable_if<Base::SizeAtCompileTime==1 && internal::is_convertible<T, Scalar>::value,T>::type* = 0) |
720 |
{ |
725 |
{ |
721 |
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 1) |
726 |
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 1) |
722 |
m_storage.data()[0] = val0; |
727 |
m_storage.data()[0] = val0; |
723 |
} |
728 |
} |
724 |
|
729 |
|
|
|
730 |
// We have a 1x1 matrix/array => the argument is interpreted as the value of the unique coefficient (case where scalar type match the index type) |
725 |
template<typename T> |
731 |
template<typename T> |
726 |
EIGEN_DEVICE_FUNC |
732 |
EIGEN_DEVICE_FUNC |
727 |
EIGEN_STRONG_INLINE void _init1(const Index& val0, |
733 |
EIGEN_STRONG_INLINE void _init1(const Index& val0, |
728 |
typename internal::enable_if< (!internal::is_same<Index,Scalar>::value) |
734 |
typename internal::enable_if< (!internal::is_same<Index,Scalar>::value) |
729 |
&& (internal::is_same<Index,T>::value) |
735 |
&& (internal::is_same<Index,T>::value) |
730 |
&& Base::SizeAtCompileTime==1 |
736 |
&& Base::SizeAtCompileTime==1 |
731 |
&& internal::is_convertible<T, Scalar>::value,T*>::type* = 0) |
737 |
&& internal::is_convertible<T, Scalar>::value,T*>::type* = 0) |
732 |
{ |
738 |
{ |
733 |
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 1) |
739 |
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 1) |
734 |
m_storage.data()[0] = Scalar(val0); |
740 |
m_storage.data()[0] = Scalar(val0); |
735 |
} |
741 |
} |
736 |
|
742 |
|
|
|
743 |
// Initialize a fixed size matrix from a pointer to raw data |
737 |
template<typename T> |
744 |
template<typename T> |
738 |
EIGEN_DEVICE_FUNC |
745 |
EIGEN_DEVICE_FUNC |
739 |
EIGEN_STRONG_INLINE void _init1(const Scalar* data){ |
746 |
EIGEN_STRONG_INLINE void _init1(const Scalar* data){ |
740 |
this->_set_noalias(ConstMapType(data)); |
747 |
this->_set_noalias(ConstMapType(data)); |
741 |
} |
748 |
} |
742 |
|
749 |
|
|
|
750 |
// Initialize an arbitrary matrix from a dense expression |
743 |
template<typename T, typename OtherDerived> |
751 |
template<typename T, typename OtherDerived> |
744 |
EIGEN_DEVICE_FUNC |
752 |
EIGEN_DEVICE_FUNC |
745 |
EIGEN_STRONG_INLINE void _init1(const DenseBase<OtherDerived>& other){ |
753 |
EIGEN_STRONG_INLINE void _init1(const DenseBase<OtherDerived>& other){ |
746 |
this->_set_noalias(other); |
754 |
this->_set_noalias(other); |
747 |
} |
755 |
} |
748 |
|
756 |
|
|
|
757 |
// Initialize an arbitrary matrix from a generic Eigen expression |
749 |
template<typename T, typename OtherDerived> |
758 |
template<typename T, typename OtherDerived> |
750 |
EIGEN_DEVICE_FUNC |
759 |
EIGEN_DEVICE_FUNC |
751 |
EIGEN_STRONG_INLINE void _init1(const EigenBase<OtherDerived>& other){ |
760 |
EIGEN_STRONG_INLINE void _init1(const EigenBase<OtherDerived>& other){ |
752 |
this->derived() = other; |
761 |
this->derived() = other; |
753 |
} |
762 |
} |
754 |
|
763 |
|
755 |
template<typename T, typename OtherDerived> |
764 |
template<typename T, typename OtherDerived> |
756 |
EIGEN_DEVICE_FUNC |
765 |
EIGEN_DEVICE_FUNC |
Lines 761-776
class PlainObjectBase : public internal:
Link Here
|
761 |
} |
770 |
} |
762 |
|
771 |
|
763 |
template<typename T, typename OtherDerived, int ColsAtCompileTime> |
772 |
template<typename T, typename OtherDerived, int ColsAtCompileTime> |
764 |
EIGEN_DEVICE_FUNC |
773 |
EIGEN_DEVICE_FUNC |
765 |
EIGEN_STRONG_INLINE void _init1(const RotationBase<OtherDerived,ColsAtCompileTime>& r) |
774 |
EIGEN_STRONG_INLINE void _init1(const RotationBase<OtherDerived,ColsAtCompileTime>& r) |
766 |
{ |
775 |
{ |
767 |
this->derived() = r; |
776 |
this->derived() = r; |
768 |
} |
777 |
} |
|
|
778 |
|
779 |
// For fixed -size arrays: |
780 |
template<typename T> |
781 |
EIGEN_DEVICE_FUNC |
782 |
EIGEN_STRONG_INLINE void _init1(const Scalar& val0, |
783 |
typename internal::enable_if< Base::SizeAtCompileTime!=Dynamic |
784 |
&& Base::SizeAtCompileTime!=1 |
785 |
&& internal::is_convertible<T, Scalar>::value |
786 |
&& internal::is_same<typename internal::traits<Derived>::XprKind,ArrayXpr>::value,T>::type* = 0) |
787 |
{ |
788 |
Base::setConstant(val0); |
789 |
} |
790 |
|
791 |
template<typename T> |
792 |
EIGEN_DEVICE_FUNC |
793 |
EIGEN_STRONG_INLINE void _init1(const Index& val0, |
794 |
typename internal::enable_if< (!internal::is_same<Index,Scalar>::value) |
795 |
&& (internal::is_same<Index,T>::value) |
796 |
&& Base::SizeAtCompileTime!=Dynamic |
797 |
&& Base::SizeAtCompileTime!=1 |
798 |
&& internal::is_convertible<T, Scalar>::value |
799 |
&& internal::is_same<typename internal::traits<Derived>::XprKind,ArrayXpr>::value,T*>::type* = 0) |
800 |
{ |
801 |
Base::setConstant(val0); |
802 |
} |
769 |
|
803 |
|
770 |
template<typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers> |
804 |
template<typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers> |
771 |
friend struct internal::matrix_swap_impl; |
805 |
friend struct internal::matrix_swap_impl; |
772 |
|
806 |
|
773 |
/** \internal generic implementation of swap for dense storage since for dynamic-sized matrices of same type it is enough to swap the |
807 |
/** \internal generic implementation of swap for dense storage since for dynamic-sized matrices of same type it is enough to swap the |
774 |
* data pointers. |
808 |
* data pointers. |
775 |
*/ |
809 |
*/ |
776 |
template<typename OtherDerived> |
810 |
template<typename OtherDerived> |