~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to extern/Eigen3/Eigen/src/Core/ForceAlignedAccess.h

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// This file is part of Eigen, a lightweight C++ template library
 
2
// for linear algebra.
 
3
//
 
4
// Copyright (C) 2009-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
 
5
//
 
6
// Eigen is free software; you can redistribute it and/or
 
7
// modify it under the terms of the GNU Lesser General Public
 
8
// License as published by the Free Software Foundation; either
 
9
// version 3 of the License, or (at your option) any later version.
 
10
//
 
11
// Alternatively, you can redistribute it and/or
 
12
// modify it under the terms of the GNU General Public License as
 
13
// published by the Free Software Foundation; either version 2 of
 
14
// the License, or (at your option) any later version.
 
15
//
 
16
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
 
17
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
18
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
 
19
// GNU General Public License for more details.
 
20
//
 
21
// You should have received a copy of the GNU Lesser General Public
 
22
// License and a copy of the GNU General Public License along with
 
23
// Eigen. If not, see <http://www.gnu.org/licenses/>.
 
24
 
 
25
#ifndef EIGEN_FORCEALIGNEDACCESS_H
 
26
#define EIGEN_FORCEALIGNEDACCESS_H
 
27
 
 
28
/** \class ForceAlignedAccess
 
29
  * \ingroup Core_Module
 
30
  *
 
31
  * \brief Enforce aligned packet loads and stores regardless of what is requested
 
32
  *
 
33
  * \param ExpressionType the type of the object of which we are forcing aligned packet access
 
34
  *
 
35
  * This class is the return type of MatrixBase::forceAlignedAccess()
 
36
  * and most of the time this is the only way it is used.
 
37
  *
 
38
  * \sa MatrixBase::forceAlignedAccess()
 
39
  */
 
40
 
 
41
namespace internal {
 
42
template<typename ExpressionType>
 
43
struct traits<ForceAlignedAccess<ExpressionType> > : public traits<ExpressionType>
 
44
{};
 
45
}
 
46
 
 
47
template<typename ExpressionType> class ForceAlignedAccess
 
48
  : public internal::dense_xpr_base< ForceAlignedAccess<ExpressionType> >::type
 
49
{
 
50
  public:
 
51
 
 
52
    typedef typename internal::dense_xpr_base<ForceAlignedAccess>::type Base;
 
53
    EIGEN_DENSE_PUBLIC_INTERFACE(ForceAlignedAccess)
 
54
 
 
55
    inline ForceAlignedAccess(const ExpressionType& matrix) : m_expression(matrix) {}
 
56
 
 
57
    inline Index rows() const { return m_expression.rows(); }
 
58
    inline Index cols() const { return m_expression.cols(); }
 
59
    inline Index outerStride() const { return m_expression.outerStride(); }
 
60
    inline Index innerStride() const { return m_expression.innerStride(); }
 
61
 
 
62
    inline const CoeffReturnType coeff(Index row, Index col) const
 
63
    {
 
64
      return m_expression.coeff(row, col);
 
65
    }
 
66
 
 
67
    inline Scalar& coeffRef(Index row, Index col)
 
68
    {
 
69
      return m_expression.const_cast_derived().coeffRef(row, col);
 
70
    }
 
71
 
 
72
    inline const CoeffReturnType coeff(Index index) const
 
73
    {
 
74
      return m_expression.coeff(index);
 
75
    }
 
76
 
 
77
    inline Scalar& coeffRef(Index index)
 
78
    {
 
79
      return m_expression.const_cast_derived().coeffRef(index);
 
80
    }
 
81
 
 
82
    template<int LoadMode>
 
83
    inline const PacketScalar packet(Index row, Index col) const
 
84
    {
 
85
      return m_expression.template packet<Aligned>(row, col);
 
86
    }
 
87
 
 
88
    template<int LoadMode>
 
89
    inline void writePacket(Index row, Index col, const PacketScalar& x)
 
90
    {
 
91
      m_expression.const_cast_derived().template writePacket<Aligned>(row, col, x);
 
92
    }
 
93
 
 
94
    template<int LoadMode>
 
95
    inline const PacketScalar packet(Index index) const
 
96
    {
 
97
      return m_expression.template packet<Aligned>(index);
 
98
    }
 
99
 
 
100
    template<int LoadMode>
 
101
    inline void writePacket(Index index, const PacketScalar& x)
 
102
    {
 
103
      m_expression.const_cast_derived().template writePacket<Aligned>(index, x);
 
104
    }
 
105
 
 
106
    operator const ExpressionType&() const { return m_expression; }
 
107
 
 
108
  protected:
 
109
    const ExpressionType& m_expression;
 
110
 
 
111
  private:
 
112
    ForceAlignedAccess& operator=(const ForceAlignedAccess&);
 
113
};
 
114
 
 
115
/** \returns an expression of *this with forced aligned access
 
116
  * \sa forceAlignedAccessIf(),class ForceAlignedAccess
 
117
  */
 
118
template<typename Derived>
 
119
inline const ForceAlignedAccess<Derived>
 
120
MatrixBase<Derived>::forceAlignedAccess() const
 
121
{
 
122
  return ForceAlignedAccess<Derived>(derived());
 
123
}
 
124
 
 
125
/** \returns an expression of *this with forced aligned access
 
126
  * \sa forceAlignedAccessIf(), class ForceAlignedAccess
 
127
  */
 
128
template<typename Derived>
 
129
inline ForceAlignedAccess<Derived>
 
130
MatrixBase<Derived>::forceAlignedAccess()
 
131
{
 
132
  return ForceAlignedAccess<Derived>(derived());
 
133
}
 
134
 
 
135
/** \returns an expression of *this with forced aligned access if \a Enable is true.
 
136
  * \sa forceAlignedAccess(), class ForceAlignedAccess
 
137
  */
 
138
template<typename Derived>
 
139
template<bool Enable>
 
140
inline typename internal::add_const_on_value_type<typename internal::conditional<Enable,ForceAlignedAccess<Derived>,Derived&>::type>::type
 
141
MatrixBase<Derived>::forceAlignedAccessIf() const
 
142
{
 
143
  return derived();
 
144
}
 
145
 
 
146
/** \returns an expression of *this with forced aligned access if \a Enable is true.
 
147
  * \sa forceAlignedAccess(), class ForceAlignedAccess
 
148
  */
 
149
template<typename Derived>
 
150
template<bool Enable>
 
151
inline typename internal::conditional<Enable,ForceAlignedAccess<Derived>,Derived&>::type
 
152
MatrixBase<Derived>::forceAlignedAccessIf()
 
153
{
 
154
  return derived();
 
155
}
 
156
 
 
157
#endif // EIGEN_FORCEALIGNEDACCESS_H