Product.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) 2008-2011 Gael Guennebaud <gael.guennebaud@inria.fr>
00005 //
00006 // This Source Code Form is subject to the terms of the Mozilla Public
00007 // License, v. 2.0. If a copy of the MPL was not distributed with this
00008 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
00009 
00010 #ifndef EIGEN_PRODUCT_H
00011 #define EIGEN_PRODUCT_H
00012 
00013 template<typename Lhs, typename Rhs> class Product;
00014 template<typename Lhs, typename Rhs, typename StorageKind> class ProductImpl;
00015 
00028 namespace internal {
00029 template<typename Lhs, typename Rhs>
00030 struct traits<Product<Lhs, Rhs> >
00031 {
00032   typedef MatrixXpr XprKind;
00033   typedef typename remove_all<Lhs>::type LhsCleaned;
00034   typedef typename remove_all<Rhs>::type RhsCleaned;
00035   typedef typename scalar_product_traits<typename traits<LhsCleaned>::Scalar, typename traits<RhsCleaned>::Scalar>::ReturnType Scalar;
00036   typedef typename promote_storage_type<typename traits<LhsCleaned>::StorageKind,
00037                                         typename traits<RhsCleaned>::StorageKind>::ret StorageKind;
00038   typedef typename promote_index_type<typename traits<LhsCleaned>::Index,
00039                                       typename traits<RhsCleaned>::Index>::type Index;
00040   enum {
00041     RowsAtCompileTime = LhsCleaned::RowsAtCompileTime,
00042     ColsAtCompileTime = RhsCleaned::ColsAtCompileTime,
00043     MaxRowsAtCompileTime = LhsCleaned::MaxRowsAtCompileTime,
00044     MaxColsAtCompileTime = RhsCleaned::MaxColsAtCompileTime,
00045     Flags = (MaxRowsAtCompileTime==1 ? RowMajorBit : 0), // TODO should be no storage order
00046     CoeffReadCost = 0 // TODO CoeffReadCost should not be part of the expression traits
00047   };
00048 };
00049 } // end namespace internal
00050 
00051 
00052 template<typename Lhs, typename Rhs>
00053 class Product : public ProductImpl<Lhs,Rhs,typename internal::promote_storage_type<typename internal::traits<Lhs>::StorageKind,
00054                                                                             typename internal::traits<Rhs>::StorageKind>::ret>
00055 {
00056   public:
00057     
00058     typedef typename ProductImpl<
00059         Lhs, Rhs,
00060         typename internal::promote_storage_type<typename Lhs::StorageKind,
00061                                                 typename Rhs::StorageKind>::ret>::Base Base;
00062     EIGEN_GENERIC_PUBLIC_INTERFACE(Product)
00063 
00064     typedef typename Lhs::Nested LhsNested;
00065     typedef typename Rhs::Nested RhsNested;
00066     typedef typename internal::remove_all<LhsNested>::type LhsNestedCleaned;
00067     typedef typename internal::remove_all<RhsNested>::type RhsNestedCleaned;
00068 
00069     Product(const Lhs& lhs, const Rhs& rhs) : m_lhs(lhs), m_rhs(rhs)
00070     {
00071       eigen_assert(lhs.cols() == rhs.rows()
00072         && "invalid matrix product"
00073         && "if you wanted a coeff-wise or a dot product use the respective explicit functions");
00074     }
00075 
00076     inline Index rows() const { return m_lhs.rows(); }
00077     inline Index cols() const { return m_rhs.cols(); }
00078 
00079     const LhsNestedCleaned& lhs() const { return m_lhs; }
00080     const RhsNestedCleaned& rhs() const { return m_rhs; }
00081 
00082   protected:
00083 
00084     const LhsNested m_lhs;
00085     const RhsNested m_rhs;
00086 };
00087 
00088 template<typename Lhs, typename Rhs>
00089 class ProductImpl<Lhs,Rhs,Dense> : public internal::dense_xpr_base<Product<Lhs,Rhs> >::type
00090 {
00091     typedef Product<Lhs, Rhs> Derived;
00092   public:
00093 
00094     typedef typename internal::dense_xpr_base<Product<Lhs, Rhs> >::type Base;
00095     EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
00096 };
00097 
00098 #endif // EIGEN_PRODUCT_H


win_eigen
Author(s): Daniel Stonier
autogenerated on Wed Sep 16 2015 07:11:37