ArrayBase.h
Go to the documentation of this file.
00001 // This file is part of Eigen, a lightweight C++ template library
00002 // for linear algebra.
00003 //
00004 // Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>
00005 //
00006 // This Source Code Form is subject to the terms of the Mozilla
00007 // Public License v. 2.0. If a copy of the MPL was not distributed
00008 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
00009 
00010 #ifndef EIGEN_ARRAYBASE_H
00011 #define EIGEN_ARRAYBASE_H
00012 
00013 namespace Eigen { 
00014 
00015 template<typename ExpressionType> class MatrixWrapper;
00016 
00039 template<typename Derived> class ArrayBase
00040   : public DenseBase<Derived>
00041 {
00042   public:
00043 #ifndef EIGEN_PARSED_BY_DOXYGEN
00044 
00045     typedef ArrayBase StorageBaseType;
00046 
00047     typedef ArrayBase Eigen_BaseClassForSpecializationOfGlobalMathFuncImpl;
00048 
00049     using internal::special_scalar_op_base<Derived,typename internal::traits<Derived>::Scalar,
00050                 typename NumTraits<typename internal::traits<Derived>::Scalar>::Real>::operator*;
00051 
00052     typedef typename internal::traits<Derived>::StorageKind StorageKind;
00053     typedef typename internal::traits<Derived>::Index Index;
00054     typedef typename internal::traits<Derived>::Scalar Scalar;
00055     typedef typename internal::packet_traits<Scalar>::type PacketScalar;
00056     typedef typename NumTraits<Scalar>::Real RealScalar;
00057 
00058     typedef DenseBase<Derived> Base;
00059     using Base::RowsAtCompileTime;
00060     using Base::ColsAtCompileTime;
00061     using Base::SizeAtCompileTime;
00062     using Base::MaxRowsAtCompileTime;
00063     using Base::MaxColsAtCompileTime;
00064     using Base::MaxSizeAtCompileTime;
00065     using Base::IsVectorAtCompileTime;
00066     using Base::Flags;
00067     using Base::CoeffReadCost;
00068 
00069     using Base::derived;
00070     using Base::const_cast_derived;
00071     using Base::rows;
00072     using Base::cols;
00073     using Base::size;
00074     using Base::coeff;
00075     using Base::coeffRef;
00076     using Base::lazyAssign;
00077     using Base::operator=;
00078     using Base::operator+=;
00079     using Base::operator-=;
00080     using Base::operator*=;
00081     using Base::operator/=;
00082 
00083     typedef typename Base::CoeffReturnType CoeffReturnType;
00084 
00085 #endif // not EIGEN_PARSED_BY_DOXYGEN
00086 
00087 #ifndef EIGEN_PARSED_BY_DOXYGEN
00088 
00093     typedef Array<typename internal::traits<Derived>::Scalar,
00094                 internal::traits<Derived>::RowsAtCompileTime,
00095                 internal::traits<Derived>::ColsAtCompileTime,
00096                 AutoAlign | (internal::traits<Derived>::Flags&RowMajorBit ? RowMajor : ColMajor),
00097                 internal::traits<Derived>::MaxRowsAtCompileTime,
00098                 internal::traits<Derived>::MaxColsAtCompileTime
00099           > PlainObject;
00100 
00101 
00103     typedef CwiseNullaryOp<internal::scalar_constant_op<Scalar>,Derived> ConstantReturnType;
00104 #endif // not EIGEN_PARSED_BY_DOXYGEN
00105 
00106 #define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::ArrayBase
00107 #   include "../plugins/CommonCwiseUnaryOps.h"
00108 #   include "../plugins/MatrixCwiseUnaryOps.h"
00109 #   include "../plugins/ArrayCwiseUnaryOps.h"
00110 #   include "../plugins/CommonCwiseBinaryOps.h"
00111 #   include "../plugins/MatrixCwiseBinaryOps.h"
00112 #   include "../plugins/ArrayCwiseBinaryOps.h"
00113 #   ifdef EIGEN_ARRAYBASE_PLUGIN
00114 #     include EIGEN_ARRAYBASE_PLUGIN
00115 #   endif
00116 #undef EIGEN_CURRENT_STORAGE_BASE_CLASS
00117 
00121     Derived& operator=(const ArrayBase& other)
00122     {
00123       return internal::assign_selector<Derived,Derived>::run(derived(), other.derived());
00124     }
00125 
00126     Derived& operator+=(const Scalar& scalar)
00127     { return *this = derived() + scalar; }
00128     Derived& operator-=(const Scalar& scalar)
00129     { return *this = derived() - scalar; }
00130 
00131     template<typename OtherDerived>
00132     Derived& operator+=(const ArrayBase<OtherDerived>& other);
00133     template<typename OtherDerived>
00134     Derived& operator-=(const ArrayBase<OtherDerived>& other);
00135 
00136     template<typename OtherDerived>
00137     Derived& operator*=(const ArrayBase<OtherDerived>& other);
00138 
00139     template<typename OtherDerived>
00140     Derived& operator/=(const ArrayBase<OtherDerived>& other);
00141 
00142   public:
00143     ArrayBase<Derived>& array() { return *this; }
00144     const ArrayBase<Derived>& array() const { return *this; }
00145 
00148     MatrixWrapper<Derived> matrix() { return derived(); }
00149     const MatrixWrapper<const Derived> matrix() const { return derived(); }
00150 
00151 //     template<typename Dest>
00152 //     inline void evalTo(Dest& dst) const { dst = matrix(); }
00153 
00154   protected:
00155     ArrayBase() : Base() {}
00156 
00157   private:
00158     explicit ArrayBase(Index);
00159     ArrayBase(Index,Index);
00160     template<typename OtherDerived> explicit ArrayBase(const ArrayBase<OtherDerived>&);
00161   protected:
00162     // mixing arrays and matrices is not legal
00163     template<typename OtherDerived> Derived& operator+=(const MatrixBase<OtherDerived>& )
00164     {EIGEN_STATIC_ASSERT(std::ptrdiff_t(sizeof(typename OtherDerived::Scalar))==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES); return *this;}
00165     // mixing arrays and matrices is not legal
00166     template<typename OtherDerived> Derived& operator-=(const MatrixBase<OtherDerived>& )
00167     {EIGEN_STATIC_ASSERT(std::ptrdiff_t(sizeof(typename OtherDerived::Scalar))==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES); return *this;}
00168 };
00169 
00174 template<typename Derived>
00175 template<typename OtherDerived>
00176 EIGEN_STRONG_INLINE Derived &
00177 ArrayBase<Derived>::operator-=(const ArrayBase<OtherDerived> &other)
00178 {
00179   SelfCwiseBinaryOp<internal::scalar_difference_op<Scalar>, Derived, OtherDerived> tmp(derived());
00180   tmp = other.derived();
00181   return derived();
00182 }
00183 
00188 template<typename Derived>
00189 template<typename OtherDerived>
00190 EIGEN_STRONG_INLINE Derived &
00191 ArrayBase<Derived>::operator+=(const ArrayBase<OtherDerived>& other)
00192 {
00193   SelfCwiseBinaryOp<internal::scalar_sum_op<Scalar>, Derived, OtherDerived> tmp(derived());
00194   tmp = other.derived();
00195   return derived();
00196 }
00197 
00202 template<typename Derived>
00203 template<typename OtherDerived>
00204 EIGEN_STRONG_INLINE Derived &
00205 ArrayBase<Derived>::operator*=(const ArrayBase<OtherDerived>& other)
00206 {
00207   SelfCwiseBinaryOp<internal::scalar_product_op<Scalar>, Derived, OtherDerived> tmp(derived());
00208   tmp = other.derived();
00209   return derived();
00210 }
00211 
00216 template<typename Derived>
00217 template<typename OtherDerived>
00218 EIGEN_STRONG_INLINE Derived &
00219 ArrayBase<Derived>::operator/=(const ArrayBase<OtherDerived>& other)
00220 {
00221   SelfCwiseBinaryOp<internal::scalar_quotient_op<Scalar>, Derived, OtherDerived> tmp(derived());
00222   tmp = other.derived();
00223   return derived();
00224 }
00225 
00226 } // end namespace Eigen
00227 
00228 #endif // EIGEN_ARRAYBASE_H


win_eigen
Author(s): Daniel Stonier
autogenerated on Wed Sep 16 2015 07:10:17