ForceAlignedAccess.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-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
00005 //
00006 // Eigen is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 3 of the License, or (at your option) any later version.
00010 //
00011 // Alternatively, you can redistribute it and/or
00012 // modify it under the terms of the GNU General Public License as
00013 // published by the Free Software Foundation; either version 2 of
00014 // the License, or (at your option) any later version.
00015 //
00016 // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
00017 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00018 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
00019 // GNU General Public License for more details.
00020 //
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License and a copy of the GNU General Public License along with
00023 // Eigen. If not, see <http://www.gnu.org/licenses/>.
00024 
00025 #ifndef EIGEN_FORCEALIGNEDACCESS_H
00026 #define EIGEN_FORCEALIGNEDACCESS_H
00027 
00041 namespace internal {
00042 template<typename ExpressionType>
00043 struct traits<ForceAlignedAccess<ExpressionType> > : public traits<ExpressionType>
00044 {};
00045 }
00046 
00047 template<typename ExpressionType> class ForceAlignedAccess
00048   : public internal::dense_xpr_base< ForceAlignedAccess<ExpressionType> >::type
00049 {
00050   public:
00051 
00052     typedef typename internal::dense_xpr_base<ForceAlignedAccess>::type Base;
00053     EIGEN_DENSE_PUBLIC_INTERFACE(ForceAlignedAccess)
00054 
00055     inline ForceAlignedAccess(const ExpressionType& matrix) : m_expression(matrix) {}
00056 
00057     inline Index rows() const { return m_expression.rows(); }
00058     inline Index cols() const { return m_expression.cols(); }
00059     inline Index outerStride() const { return m_expression.outerStride(); }
00060     inline Index innerStride() const { return m_expression.innerStride(); }
00061 
00062     inline const CoeffReturnType coeff(Index row, Index col) const
00063     {
00064       return m_expression.coeff(row, col);
00065     }
00066 
00067     inline Scalar& coeffRef(Index row, Index col)
00068     {
00069       return m_expression.const_cast_derived().coeffRef(row, col);
00070     }
00071 
00072     inline const CoeffReturnType coeff(Index index) const
00073     {
00074       return m_expression.coeff(index);
00075     }
00076 
00077     inline Scalar& coeffRef(Index index)
00078     {
00079       return m_expression.const_cast_derived().coeffRef(index);
00080     }
00081 
00082     template<int LoadMode>
00083     inline const PacketScalar packet(Index row, Index col) const
00084     {
00085       return m_expression.template packet<Aligned>(row, col);
00086     }
00087 
00088     template<int LoadMode>
00089     inline void writePacket(Index row, Index col, const PacketScalar& x)
00090     {
00091       m_expression.const_cast_derived().template writePacket<Aligned>(row, col, x);
00092     }
00093 
00094     template<int LoadMode>
00095     inline const PacketScalar packet(Index index) const
00096     {
00097       return m_expression.template packet<Aligned>(index);
00098     }
00099 
00100     template<int LoadMode>
00101     inline void writePacket(Index index, const PacketScalar& x)
00102     {
00103       m_expression.const_cast_derived().template writePacket<Aligned>(index, x);
00104     }
00105 
00106     operator const ExpressionType&() const { return m_expression; }
00107 
00108   protected:
00109     const ExpressionType& m_expression;
00110 
00111   private:
00112     ForceAlignedAccess& operator=(const ForceAlignedAccess&);
00113 };
00114 
00118 template<typename Derived>
00119 inline const ForceAlignedAccess<Derived>
00120 MatrixBase<Derived>::forceAlignedAccess() const
00121 {
00122   return ForceAlignedAccess<Derived>(derived());
00123 }
00124 
00128 template<typename Derived>
00129 inline ForceAlignedAccess<Derived>
00130 MatrixBase<Derived>::forceAlignedAccess()
00131 {
00132   return ForceAlignedAccess<Derived>(derived());
00133 }
00134 
00138 template<typename Derived>
00139 template<bool Enable>
00140 inline typename internal::add_const_on_value_type<typename internal::conditional<Enable,ForceAlignedAccess<Derived>,Derived&>::type>::type
00141 MatrixBase<Derived>::forceAlignedAccessIf() const
00142 {
00143   return derived();
00144 }
00145 
00149 template<typename Derived>
00150 template<bool Enable>
00151 inline typename internal::conditional<Enable,ForceAlignedAccess<Derived>,Derived&>::type
00152 MatrixBase<Derived>::forceAlignedAccessIf()
00153 {
00154   return derived();
00155 }
00156 
00157 #endif // EIGEN_FORCEALIGNEDACCESS_H


libicr
Author(s): Robert Krug
autogenerated on Mon Jan 6 2014 11:32:40