1c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// This file is part of Eigen, a lightweight C++ template library 2c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// for linear algebra. 3c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// 4c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// Copyright (C) 2009-2010 Gael Guennebaud <gael.guennebaud@inria.fr> 5c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// 6c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// This Source Code Form is subject to the terms of the Mozilla 7c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// Public License v. 2.0. If a copy of the MPL was not distributed 8c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 10c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath#ifndef EIGEN_ARRAYWRAPPER_H 11c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath#define EIGEN_ARRAYWRAPPER_H 12c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 13c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathnamespace Eigen { 14c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 15c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \class ArrayWrapper 16c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * \ingroup Core_Module 17c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * 18c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * \brief Expression of a mathematical vector or matrix as an array object 19c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * 20c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * This class is the return type of MatrixBase::array(), and most of the time 21c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * this is the only way it is use. 22c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * 23c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * \sa MatrixBase::array(), class MatrixWrapper 24c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath */ 25c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 26c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathnamespace internal { 27c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename ExpressionType> 28c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathstruct traits<ArrayWrapper<ExpressionType> > 29c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath : public traits<typename remove_all<typename ExpressionType::Nested>::type > 30c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{ 31c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath typedef ArrayXpr XprKind; 32c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}; 33c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath} 34c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 35c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename ExpressionType> 36c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathclass ArrayWrapper : public ArrayBase<ArrayWrapper<ExpressionType> > 37c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{ 38c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath public: 39c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath typedef ArrayBase<ArrayWrapper> Base; 40c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath EIGEN_DENSE_PUBLIC_INTERFACE(ArrayWrapper) 41c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath EIGEN_INHERIT_ASSIGNMENT_OPERATORS(ArrayWrapper) 42c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 43c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath typedef typename internal::conditional< 44c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath internal::is_lvalue<ExpressionType>::value, 45c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath Scalar, 46c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath const Scalar 47c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath >::type ScalarWithConstIfNotLvalue; 48c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 49c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath typedef typename internal::nested<ExpressionType>::type NestedExpressionType; 50c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 51c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline ArrayWrapper(ExpressionType& matrix) : m_expression(matrix) {} 52c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 53c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline Index rows() const { return m_expression.rows(); } 54c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline Index cols() const { return m_expression.cols(); } 55c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline Index outerStride() const { return m_expression.outerStride(); } 56c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline Index innerStride() const { return m_expression.innerStride(); } 57c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 58c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline ScalarWithConstIfNotLvalue* data() { return m_expression.data(); } 59c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline const Scalar* data() const { return m_expression.data(); } 60c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 61c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline CoeffReturnType coeff(Index row, Index col) const 62c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 63c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath return m_expression.coeff(row, col); 64c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 65c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 66c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline Scalar& coeffRef(Index row, Index col) 67c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 68c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath return m_expression.const_cast_derived().coeffRef(row, col); 69c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 70c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 71c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline const Scalar& coeffRef(Index row, Index col) const 72c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 73c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath return m_expression.const_cast_derived().coeffRef(row, col); 74c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 75c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 76c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline CoeffReturnType coeff(Index index) const 77c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 78c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath return m_expression.coeff(index); 79c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 80c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 81c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline Scalar& coeffRef(Index index) 82c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 83c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath return m_expression.const_cast_derived().coeffRef(index); 84c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 85c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 86c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline const Scalar& coeffRef(Index index) const 87c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 88c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath return m_expression.const_cast_derived().coeffRef(index); 89c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 90c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 91c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath template<int LoadMode> 92c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline const PacketScalar packet(Index row, Index col) const 93c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 94c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath return m_expression.template packet<LoadMode>(row, col); 95c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 96c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 97c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath template<int LoadMode> 98c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline void writePacket(Index row, Index col, const PacketScalar& x) 99c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 100c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath m_expression.const_cast_derived().template writePacket<LoadMode>(row, col, x); 101c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 102c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 103c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath template<int LoadMode> 104c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline const PacketScalar packet(Index index) const 105c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 106c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath return m_expression.template packet<LoadMode>(index); 107c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 108c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 109c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath template<int LoadMode> 110c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline void writePacket(Index index, const PacketScalar& x) 111c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 112c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath m_expression.const_cast_derived().template writePacket<LoadMode>(index, x); 113c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 114c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 115c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath template<typename Dest> 116c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline void evalTo(Dest& dst) const { dst = m_expression; } 117c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 118c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath const typename internal::remove_all<NestedExpressionType>::type& 119c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath nestedExpression() const 120c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 121c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath return m_expression; 122c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 123c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 124c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath protected: 125c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath NestedExpressionType m_expression; 126c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}; 127c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 128c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \class MatrixWrapper 129c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * \ingroup Core_Module 130c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * 131c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * \brief Expression of an array as a mathematical vector or matrix 132c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * 133c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * This class is the return type of ArrayBase::matrix(), and most of the time 134c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * this is the only way it is use. 135c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * 136c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * \sa MatrixBase::matrix(), class ArrayWrapper 137c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath */ 138c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 139c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathnamespace internal { 140c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename ExpressionType> 141c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathstruct traits<MatrixWrapper<ExpressionType> > 142c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath : public traits<typename remove_all<typename ExpressionType::Nested>::type > 143c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{ 144c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath typedef MatrixXpr XprKind; 145c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}; 146c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath} 147c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 148c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename ExpressionType> 149c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathclass MatrixWrapper : public MatrixBase<MatrixWrapper<ExpressionType> > 150c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{ 151c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath public: 152c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath typedef MatrixBase<MatrixWrapper<ExpressionType> > Base; 153c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath EIGEN_DENSE_PUBLIC_INTERFACE(MatrixWrapper) 154c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath EIGEN_INHERIT_ASSIGNMENT_OPERATORS(MatrixWrapper) 155c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 156c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath typedef typename internal::conditional< 157c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath internal::is_lvalue<ExpressionType>::value, 158c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath Scalar, 159c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath const Scalar 160c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath >::type ScalarWithConstIfNotLvalue; 161c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 162c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath typedef typename internal::nested<ExpressionType>::type NestedExpressionType; 163c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 164c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline MatrixWrapper(ExpressionType& matrix) : m_expression(matrix) {} 165c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 166c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline Index rows() const { return m_expression.rows(); } 167c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline Index cols() const { return m_expression.cols(); } 168c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline Index outerStride() const { return m_expression.outerStride(); } 169c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline Index innerStride() const { return m_expression.innerStride(); } 170c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 171c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline ScalarWithConstIfNotLvalue* data() { return m_expression.data(); } 172c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline const Scalar* data() const { return m_expression.data(); } 173c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 174c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline CoeffReturnType coeff(Index row, Index col) const 175c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 176c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath return m_expression.coeff(row, col); 177c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 178c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 179c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline Scalar& coeffRef(Index row, Index col) 180c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 181c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath return m_expression.const_cast_derived().coeffRef(row, col); 182c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 183c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 184c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline const Scalar& coeffRef(Index row, Index col) const 185c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 186c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath return m_expression.derived().coeffRef(row, col); 187c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 188c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 189c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline CoeffReturnType coeff(Index index) const 190c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 191c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath return m_expression.coeff(index); 192c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 193c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 194c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline Scalar& coeffRef(Index index) 195c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 196c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath return m_expression.const_cast_derived().coeffRef(index); 197c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 198c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 199c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline const Scalar& coeffRef(Index index) const 200c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 201c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath return m_expression.const_cast_derived().coeffRef(index); 202c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 203c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 204c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath template<int LoadMode> 205c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline const PacketScalar packet(Index row, Index col) const 206c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 207c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath return m_expression.template packet<LoadMode>(row, col); 208c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 209c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 210c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath template<int LoadMode> 211c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline void writePacket(Index row, Index col, const PacketScalar& x) 212c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 213c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath m_expression.const_cast_derived().template writePacket<LoadMode>(row, col, x); 214c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 215c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 216c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath template<int LoadMode> 217c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline const PacketScalar packet(Index index) const 218c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 219c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath return m_expression.template packet<LoadMode>(index); 220c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 221c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 222c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath template<int LoadMode> 223c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath inline void writePacket(Index index, const PacketScalar& x) 224c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 225c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath m_expression.const_cast_derived().template writePacket<LoadMode>(index, x); 226c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 227c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 228c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath const typename internal::remove_all<NestedExpressionType>::type& 229c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath nestedExpression() const 230c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 231c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath return m_expression; 232c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 233c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 234c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath protected: 235c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath NestedExpressionType m_expression; 236c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}; 237c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 238c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath} // end namespace Eigen 239c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 240c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath#endif // EIGEN_ARRAYWRAPPER_H 241