2008-06-26 23:22:26 +00:00
// This file is part of Eigen, a lightweight C++ template library
2009-05-22 20:25:33 +02:00
// for linear algebra.
2008-06-26 23:22:26 +00:00
//
2014-06-23 10:40:03 +02:00
// Copyright (C) 2008-2014 Gael Guennebaud <gael.guennebaud@inria.fr>
2008-06-26 23:22:26 +00:00
//
2012-07-13 14:42:47 -04:00
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
2008-06-26 23:22:26 +00:00
# ifndef EIGEN_SPARSEMATRIXBASE_H
# define EIGEN_SPARSEMATRIXBASE_H
2012-04-15 11:06:28 +01:00
namespace Eigen {
2011-11-28 16:36:37 +01:00
/** \ingroup SparseCore_Module
2009-05-19 09:40:00 +02:00
*
* \ class SparseMatrixBase
*
* \ brief Base class of any sparse matrices or sparse expressions
*
2015-12-30 16:43:19 +01:00
* \ tparam Derived is the derived type , e . g . a sparse matrix type , or an expression , etc .
2009-05-19 09:40:00 +02:00
*
2011-02-13 22:50:57 +00:00
* This class can be extended with the help of the plugin mechanism described on the page
2016-08-30 11:10:08 +02:00
* \ ref TopicCustomizing_Plugins by defining the preprocessor symbol \ c EIGEN_SPARSEMATRIXBASE_PLUGIN .
2009-05-19 09:40:00 +02:00
*/
2015-10-29 03:55:39 -07:00
template < typename Derived > class SparseMatrixBase
: public EigenBase < Derived >
2008-06-26 23:22:26 +00:00
{
public :
2010-10-25 10:15:22 -04:00
typedef typename internal : : traits < Derived > : : Scalar Scalar ;
2015-04-24 09:44:24 +02:00
/** The numeric type of the expression' coefficients, e.g. float, double, int or std::complex<float>, etc.
*
* It is an alias for the Scalar type */
typedef Scalar value_type ;
2010-10-25 10:15:22 -04:00
typedef typename internal : : packet_traits < Scalar > : : type PacketScalar ;
typedef typename internal : : traits < Derived > : : StorageKind StorageKind ;
2017-01-03 11:25:41 +01:00
/** The integer type used to \b store indices within a SparseMatrix.
* For a \ c SparseMatrix < Scalar , Options , IndexType > it an alias of the third template parameter \ c IndexType . */
2014-12-04 22:48:53 +01:00
typedef typename internal : : traits < Derived > : : StorageIndex StorageIndex ;
2017-01-03 11:25:41 +01:00
2011-10-11 11:28:13 +02:00
typedef typename internal : : add_const_on_value_type_if_arithmetic <
typename internal : : packet_traits < Scalar > : : type
> : : type PacketReturnType ;
2010-05-30 16:00:58 -04:00
2009-11-17 16:04:19 +01:00
typedef SparseMatrixBase StorageBaseType ;
2015-10-29 03:55:39 -07:00
2014-12-04 22:48:53 +01:00
typedef Matrix < StorageIndex , Dynamic , 1 > IndexVector ;
typedef Matrix < Scalar , Dynamic , 1 > ScalarVector ;
2010-11-15 14:14:05 +01:00
template < typename OtherDerived >
2014-06-20 15:42:13 +02:00
Derived & operator = ( const EigenBase < OtherDerived > & other ) ;
2009-01-14 14:24:10 +00:00
2008-06-26 23:22:26 +00:00
enum {
2009-01-14 14:24:10 +00:00
2010-10-25 10:15:22 -04:00
RowsAtCompileTime = internal : : traits < Derived > : : RowsAtCompileTime ,
2009-01-14 14:24:10 +00:00
/**< The number of rows at compile-time. This is just a copy of the value provided
* by the \ a Derived type . If a value is not known at compile - time ,
* it is set to the \ a Dynamic constant .
* \ sa MatrixBase : : rows ( ) , MatrixBase : : cols ( ) , ColsAtCompileTime , SizeAtCompileTime */
2010-10-25 10:15:22 -04:00
ColsAtCompileTime = internal : : traits < Derived > : : ColsAtCompileTime ,
2009-01-14 14:24:10 +00:00
/**< The number of columns at compile-time. This is just a copy of the value provided
* by the \ a Derived type . If a value is not known at compile - time ,
* it is set to the \ a Dynamic constant .
* \ sa MatrixBase : : rows ( ) , MatrixBase : : cols ( ) , RowsAtCompileTime , SizeAtCompileTime */
2010-10-25 10:15:22 -04:00
SizeAtCompileTime = ( internal : : size_at_compile_time < internal : : traits < Derived > : : RowsAtCompileTime ,
internal : : traits < Derived > : : ColsAtCompileTime > : : ret ) ,
2009-01-14 14:24:10 +00:00
/**< This is equal to the number of coefficients, i.e. the number of
* rows times the number of columns , or to \ a Dynamic if this is not
* known at compile - time . \ sa RowsAtCompileTime , ColsAtCompileTime */
MaxRowsAtCompileTime = RowsAtCompileTime ,
MaxColsAtCompileTime = ColsAtCompileTime ,
2010-10-25 10:15:22 -04:00
MaxSizeAtCompileTime = ( internal : : size_at_compile_time < MaxRowsAtCompileTime ,
2009-01-14 14:24:10 +00:00
MaxColsAtCompileTime > : : ret ) ,
IsVectorAtCompileTime = RowsAtCompileTime = = 1 | | ColsAtCompileTime = = 1 ,
/**< This is set to true if either the number of rows or the number of
* columns is known at compile - time to be equal to 1. Indeed , in that case ,
* we are dealing with a column - vector ( if there is only one column ) or with
* a row - vector ( if there is only one row ) . */
2010-10-25 10:15:22 -04:00
Flags = internal : : traits < Derived > : : Flags ,
2009-01-14 14:24:10 +00:00
/**< This stores expression \ref flags flags which may or may not be inherited by new expressions
* constructed from this one . See the \ ref flags " list of flags " .
*/
2009-05-19 09:40:00 +02:00
2009-11-16 18:19:08 +01:00
IsRowMajor = Flags & RowMajorBit ? 1 : 0 ,
2013-07-16 09:49:01 +02:00
InnerSizeAtCompileTime = int ( IsVectorAtCompileTime ) ? int ( SizeAtCompileTime )
: int ( IsRowMajor ) ? int ( ColsAtCompileTime ) : int ( RowsAtCompileTime ) ,
2009-11-16 18:19:08 +01:00
# ifndef EIGEN_PARSED_BY_DOXYGEN
_HasDirectAccess = ( int ( Flags ) & DirectAccessBit ) ? 1 : 0 // workaround sunCC
# endif
2008-06-26 23:22:26 +00:00
} ;
2009-01-14 14:24:10 +00:00
/** \internal the return type of MatrixBase::adjoint() */
2010-10-25 22:13:49 +02:00
typedef typename internal : : conditional < NumTraits < Scalar > : : IsComplex ,
2011-01-07 05:16:01 -05:00
CwiseUnaryOp < internal : : scalar_conjugate_op < Scalar > , Eigen : : Transpose < const Derived > > ,
Transpose < const Derived >
2010-10-25 22:13:49 +02:00
> : : type AdjointReturnType ;
2014-09-23 14:28:23 +02:00
typedef Transpose < Derived > TransposeReturnType ;
typedef typename internal : : add_const < Transpose < const Derived > > : : type ConstTransposeReturnType ;
2009-01-14 14:24:10 +00:00
2014-07-19 15:19:10 +02:00
// FIXME storage order do not match evaluator storage order
2014-12-04 22:48:53 +01:00
typedef SparseMatrix < Scalar , Flags & RowMajorBit ? RowMajor : ColMajor , StorageIndex > PlainObject ;
2009-12-16 19:18:40 +01:00
2009-01-14 14:24:10 +00:00
# ifndef EIGEN_PARSED_BY_DOXYGEN
/** This is the "real scalar" type; if the \a Scalar type is already real numbers
* ( e . g . int , float or double ) then \ a RealScalar is just the same as \ a Scalar . If
* \ a Scalar is \ a std : : complex < T > then RealScalar is \ a T .
*
* \ sa class NumTraits
*/
typedef typename NumTraits < Scalar > : : Real RealScalar ;
2009-11-16 18:19:08 +01:00
/** \internal the return type of coeff()
*/
2010-10-25 22:13:49 +02:00
typedef typename internal : : conditional < _HasDirectAccess , const Scalar & , Scalar > : : type CoeffReturnType ;
2009-11-16 18:19:08 +01:00
2009-11-17 10:11:27 +01:00
/** \internal Represents a matrix with all coefficients equal to one another*/
2010-10-25 10:15:22 -04:00
typedef CwiseNullaryOp < internal : : scalar_constant_op < Scalar > , Matrix < Scalar , Dynamic , Dynamic > > ConstantReturnType ;
2009-11-17 10:11:27 +01:00
2014-09-23 14:28:23 +02:00
/** type of the equivalent dense matrix */
typedef Matrix < Scalar , RowsAtCompileTime , ColsAtCompileTime > DenseMatrixType ;
2009-01-14 14:24:10 +00:00
/** type of the equivalent square matrix */
2010-06-11 07:56:50 -04:00
typedef Matrix < Scalar , EIGEN_SIZE_MAX ( RowsAtCompileTime , ColsAtCompileTime ) ,
EIGEN_SIZE_MAX ( RowsAtCompileTime , ColsAtCompileTime ) > SquareMatrixType ;
2009-01-14 14:24:10 +00:00
2008-06-26 23:22:26 +00:00
inline const Derived & derived ( ) const { return * static_cast < const Derived * > ( this ) ; }
inline Derived & derived ( ) { return * static_cast < Derived * > ( this ) ; }
inline Derived & const_cast_derived ( ) const
{ return * static_cast < Derived * > ( const_cast < SparseMatrixBase * > ( this ) ) ; }
2015-10-29 21:05:52 +01:00
2016-06-02 22:19:55 +02:00
typedef EigenBase < Derived > Base ;
2016-06-02 22:16:37 +02:00
2009-01-14 14:24:10 +00:00
# endif // not EIGEN_PARSED_BY_DOXYGEN
2008-06-26 23:22:26 +00:00
2012-01-11 11:00:30 -05:00
# define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::SparseMatrixBase
2016-09-16 10:40:50 +02:00
# ifdef EIGEN_PARSED_BY_DOXYGEN
2016-09-16 11:23:19 +02:00
# define EIGEN_DOC_UNARY_ADDONS(METHOD,OP) /** <p>This method does not change the sparsity of \c *this: the OP is applied to explicitly stored coefficients only. \sa SparseCompressedBase::coeffs() </p> */
2016-09-16 11:26:25 +02:00
# define EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL /** <p> \warning This method returns a read-only expression for any sparse matrices. \sa \ref TutorialSparse_SubMatrices "Sparse block operations" </p> */
# define EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(COND) /** <p> \warning This method returns a read-write expression for COND sparse matrices only. Otherwise, the returned expression is read-only. \sa \ref TutorialSparse_SubMatrices "Sparse block operations" </p> */
2016-09-16 10:40:50 +02:00
# else
# define EIGEN_DOC_UNARY_ADDONS(X,Y)
2016-09-16 11:23:19 +02:00
# define EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL
# define EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(COND)
2016-09-16 10:40:50 +02:00
# endif
2012-01-11 11:00:30 -05:00
# include ".. / plugins / CommonCwiseUnaryOps.h"
# include ".. / plugins / CommonCwiseBinaryOps.h"
# include ".. / plugins / MatrixCwiseUnaryOps.h"
# include ".. / plugins / MatrixCwiseBinaryOps.h"
2012-11-16 09:02:50 +01:00
# include ".. / plugins / BlockMethods.h"
2012-01-11 11:00:30 -05:00
# ifdef EIGEN_SPARSEMATRIXBASE_PLUGIN
# include EIGEN_SPARSEMATRIXBASE_PLUGIN
# endif
# undef EIGEN_CURRENT_STORAGE_BASE_CLASS
2016-09-16 10:40:50 +02:00
# undef EIGEN_DOC_UNARY_ADDONS
2016-09-16 11:23:19 +02:00
# undef EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL
# undef EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF
2012-01-11 11:00:30 -05:00
2011-12-02 19:02:49 +01:00
/** \returns the number of rows. \sa cols() */
2015-02-13 18:57:41 +01:00
inline Index rows ( ) const { return derived ( ) . rows ( ) ; }
2011-12-02 19:02:49 +01:00
/** \returns the number of columns. \sa rows() */
2015-02-13 18:57:41 +01:00
inline Index cols ( ) const { return derived ( ) . cols ( ) ; }
2009-01-14 14:24:10 +00:00
/** \returns the number of coefficients, which is \a rows()*cols().
2011-12-02 19:02:49 +01:00
* \ sa rows ( ) , cols ( ) . */
2015-02-13 18:57:41 +01:00
inline Index size ( ) const { return rows ( ) * cols ( ) ; }
2009-01-14 14:24:10 +00:00
/** \returns true if either the number of rows or the number of columns is equal to 1.
* In other words , this function returns
* \ code rows ( ) = = 1 | | cols ( ) = = 1 \ endcode
* \ sa rows ( ) , cols ( ) , IsVectorAtCompileTime . */
inline bool isVector ( ) const { return rows ( ) = = 1 | | cols ( ) = = 1 ; }
/** \returns the size of the storage major dimension,
* i . e . , the number of columns for a columns major matrix , and the number of rows otherwise */
2015-02-13 18:57:41 +01:00
Index outerSize ( ) const { return ( int ( Flags ) & RowMajorBit ) ? this - > rows ( ) : this - > cols ( ) ; }
2009-01-14 14:24:10 +00:00
/** \returns the size of the inner dimension according to the storage order,
* i . e . , the number of rows for a columns major matrix , and the number of cols otherwise */
2015-02-13 18:57:41 +01:00
Index innerSize ( ) const { return ( int ( Flags ) & RowMajorBit ) ? this - > cols ( ) : this - > rows ( ) ; }
2008-06-26 23:22:26 +00:00
bool isRValue ( ) const { return m_isRValue ; }
2008-06-29 21:29:12 +00:00
Derived & markAsRValue ( ) { m_isRValue = true ; return derived ( ) ; }
2008-06-26 23:22:26 +00:00
2009-01-14 14:24:10 +00:00
SparseMatrixBase ( ) : m_isRValue ( false ) { /* TODO check flags */ }
2011-11-30 21:55:54 +01:00
2010-10-27 14:31:23 +02:00
template < typename OtherDerived >
2014-06-20 15:42:13 +02:00
Derived & operator = ( const ReturnByValue < OtherDerived > & other ) ;
2009-01-14 14:24:10 +00:00
2008-06-26 23:22:26 +00:00
template < typename OtherDerived >
2014-06-20 15:42:13 +02:00
inline Derived & operator = ( const SparseMatrixBase < OtherDerived > & other ) ;
inline Derived & operator = ( const Derived & other ) ;
2008-06-26 23:22:26 +00:00
2011-11-30 21:55:54 +01:00
protected :
2009-01-14 14:24:10 +00:00
2008-06-26 23:22:26 +00:00
template < typename OtherDerived >
2014-06-20 15:42:13 +02:00
inline Derived & assign ( const OtherDerived & other ) ;
2008-06-26 23:22:26 +00:00
2011-11-30 21:55:54 +01:00
template < typename OtherDerived >
2014-06-20 15:42:13 +02:00
inline void assignGeneric ( const OtherDerived & other ) ;
2011-11-30 21:55:54 +01:00
public :
2008-06-26 23:22:26 +00:00
friend std : : ostream & operator < < ( std : : ostream & s , const SparseMatrixBase & m )
{
2011-12-22 14:01:06 +01:00
typedef typename Derived : : Nested Nested ;
typedef typename internal : : remove_all < Nested > : : type NestedCleaned ;
2008-06-26 23:22:26 +00:00
if ( Flags & RowMajorBit )
{
2016-12-07 00:37:48 +01:00
Nested nm ( m . derived ( ) ) ;
2016-11-10 10:35:32 +01:00
internal : : evaluator < NestedCleaned > thisEval ( nm ) ;
2011-12-22 14:01:06 +01:00
for ( Index row = 0 ; row < nm . outerSize ( ) ; + + row )
2008-06-26 23:22:26 +00:00
{
2010-05-30 16:00:58 -04:00
Index col = 0 ;
2016-11-10 10:35:32 +01:00
for ( typename internal : : evaluator < NestedCleaned > : : InnerIterator it ( thisEval , row ) ; it ; + + it )
2008-06-26 23:22:26 +00:00
{
for ( ; col < it . index ( ) ; + + col )
s < < " 0 " ;
2008-08-21 18:40:56 +00:00
s < < it . value ( ) < < " " ;
2008-06-29 21:29:12 +00:00
+ + col ;
2008-06-26 23:22:26 +00:00
}
for ( ; col < m . cols ( ) ; + + col )
s < < " 0 " ;
s < < std : : endl ;
}
}
else
{
2016-12-07 00:37:48 +01:00
Nested nm ( m . derived ( ) ) ;
2016-11-10 10:35:32 +01:00
internal : : evaluator < NestedCleaned > thisEval ( nm ) ;
2008-09-02 15:28:49 +00:00
if ( m . cols ( ) = = 1 ) {
2010-05-30 16:00:58 -04:00
Index row = 0 ;
2016-11-10 10:35:32 +01:00
for ( typename internal : : evaluator < NestedCleaned > : : InnerIterator it ( thisEval , 0 ) ; it ; + + it )
2008-09-02 15:28:49 +00:00
{
for ( ; row < it . index ( ) ; + + row )
s < < " 0 " < < std : : endl ;
s < < it . value ( ) < < std : : endl ;
+ + row ;
}
for ( ; row < m . rows ( ) ; + + row )
s < < " 0 " < < std : : endl ;
}
else
{
2014-12-04 22:48:53 +01:00
SparseMatrix < Scalar , RowMajorBit , StorageIndex > trans = m ;
s < < static_cast < const SparseMatrixBase < SparseMatrix < Scalar , RowMajorBit , StorageIndex > > & > ( trans ) ;
2008-09-02 15:28:49 +00:00
}
2008-06-26 23:22:26 +00:00
}
return s ;
}
2009-01-14 14:24:10 +00:00
template < typename OtherDerived >
Derived & operator + = ( const SparseMatrixBase < OtherDerived > & other ) ;
template < typename OtherDerived >
Derived & operator - = ( const SparseMatrixBase < OtherDerived > & other ) ;
2015-06-24 17:55:00 +02:00
template < typename OtherDerived >
Derived & operator + = ( const DiagonalBase < OtherDerived > & other ) ;
template < typename OtherDerived >
Derived & operator - = ( const DiagonalBase < OtherDerived > & other ) ;
2009-01-14 14:24:10 +00:00
2016-12-14 17:53:47 +01:00
template < typename OtherDerived >
Derived & operator + = ( const EigenBase < OtherDerived > & other ) ;
template < typename OtherDerived >
Derived & operator - = ( const EigenBase < OtherDerived > & other ) ;
2009-12-16 19:18:40 +01:00
Derived & operator * = ( const Scalar & other ) ;
Derived & operator / = ( const Scalar & other ) ;
2015-11-04 17:42:07 +01:00
template < typename OtherDerived > struct CwiseProductDenseReturnType {
Relax mixing-type constraints for binary coefficient-wise operators:
- Replace internal::scalar_product_traits<A,B> by Eigen::ScalarBinaryOpTraits<A,B,OP>
- Remove the "functor_is_product_like" helper (was pretty ugly)
- Currently, OP is not used, but it is available to the user for fine grained tuning
- Currently, only the following operators have been generalized: *,/,+,-,=,*=,/=,+=,-=
- TODO: generalize all other binray operators (comparisons,pow,etc.)
- TODO: handle "scalar op array" operators (currently only * is handled)
- TODO: move the handling of the "void" scalar type to ScalarBinaryOpTraits
2016-06-06 15:11:41 +02:00
typedef CwiseBinaryOp < internal : : scalar_product_op < typename ScalarBinaryOpTraits <
2015-11-04 17:42:07 +01:00
typename internal : : traits < Derived > : : Scalar ,
typename internal : : traits < OtherDerived > : : Scalar
> : : ReturnType > ,
const Derived ,
const OtherDerived
> Type ;
} ;
2009-12-16 19:18:40 +01:00
template < typename OtherDerived >
2015-11-04 17:42:07 +01:00
EIGEN_STRONG_INLINE const typename CwiseProductDenseReturnType < OtherDerived > : : Type
2009-12-16 19:18:40 +01:00
cwiseProduct ( const MatrixBase < OtherDerived > & other ) const ;
2009-01-14 14:24:10 +00:00
2014-06-27 15:54:44 +02:00
// sparse * diagonal
template < typename OtherDerived >
const Product < Derived , OtherDerived >
operator * ( const DiagonalBase < OtherDerived > & other ) const
{ return Product < Derived , OtherDerived > ( derived ( ) , other . derived ( ) ) ; }
// diagonal * sparse
template < typename OtherDerived > friend
const Product < OtherDerived , Derived >
operator * ( const DiagonalBase < OtherDerived > & lhs , const SparseMatrixBase & rhs )
{ return Product < OtherDerived , Derived > ( lhs . derived ( ) , rhs . derived ( ) ) ; }
2014-07-01 11:50:20 +02:00
// sparse * sparse
template < typename OtherDerived >
2015-10-26 18:20:00 +01:00
const Product < Derived , OtherDerived , AliasFreeProduct >
2014-07-01 11:50:20 +02:00
operator * ( const SparseMatrixBase < OtherDerived > & other ) const ;
2014-07-01 17:53:18 +02:00
// sparse * dense
2009-01-14 17:41:55 +00:00
template < typename OtherDerived >
2014-07-01 17:53:18 +02:00
const Product < Derived , OtherDerived >
operator * ( const MatrixBase < OtherDerived > & other ) const
{ return Product < Derived , OtherDerived > ( derived ( ) , other . derived ( ) ) ; }
// dense * sparse
template < typename OtherDerived > friend
const Product < OtherDerived , Derived >
operator * ( const MatrixBase < OtherDerived > & lhs , const SparseMatrixBase & rhs )
{ return Product < OtherDerived , Derived > ( lhs . derived ( ) , rhs . derived ( ) ) ; }
2012-02-08 18:22:48 +01:00
2012-06-07 16:18:00 +02:00
/** \returns an expression of P H P^-1 where H is the matrix represented by \c *this */
2014-12-04 22:48:53 +01:00
SparseSymmetricPermutationProduct < Derived , Upper | Lower > twistedBy ( const PermutationMatrix < Dynamic , Dynamic , StorageIndex > & perm ) const
2012-02-08 18:22:48 +01:00
{
return SparseSymmetricPermutationProduct < Derived , Upper | Lower > ( derived ( ) , perm ) ;
}
2009-01-14 14:24:10 +00:00
template < typename OtherDerived >
Derived & operator * = ( const SparseMatrixBase < OtherDerived > & other ) ;
2009-04-05 16:30:10 +00:00
template < int Mode >
2014-10-07 18:29:28 +02:00
inline const TriangularView < const Derived , Mode > triangularView ( ) const ;
2015-03-09 21:29:46 +01:00
template < unsigned int UpLo > struct SelfAdjointViewReturnType { typedef SparseSelfAdjointView < Derived , UpLo > Type ; } ;
template < unsigned int UpLo > struct ConstSelfAdjointViewReturnType { typedef const SparseSelfAdjointView < const Derived , UpLo > Type ; } ;
2009-11-18 14:52:52 +01:00
2015-03-09 21:29:46 +01:00
template < unsigned int UpLo > inline
typename ConstSelfAdjointViewReturnType < UpLo > : : Type selfadjointView ( ) const ;
template < unsigned int UpLo > inline
typename SelfAdjointViewReturnType < UpLo > : : Type selfadjointView ( ) ;
2009-01-14 14:24:10 +00:00
template < typename OtherDerived > Scalar dot ( const MatrixBase < OtherDerived > & other ) const ;
template < typename OtherDerived > Scalar dot ( const SparseMatrixBase < OtherDerived > & other ) const ;
RealScalar squaredNorm ( ) const ;
RealScalar norm ( ) const ;
2013-01-11 17:27:12 +01:00
RealScalar blueNorm ( ) const ;
2009-01-14 14:24:10 +00:00
2014-09-23 14:28:23 +02:00
TransposeReturnType transpose ( ) { return TransposeReturnType ( derived ( ) ) ; }
const ConstTransposeReturnType transpose ( ) const { return ConstTransposeReturnType ( derived ( ) ) ; }
const AdjointReturnType adjoint ( ) const { return AdjointReturnType ( transpose ( ) ) ; }
2009-01-14 14:24:10 +00:00
2014-09-23 14:28:23 +02:00
DenseMatrixType toDense ( ) const
2013-06-10 00:06:40 +02:00
{
2014-09-23 14:28:23 +02:00
return DenseMatrixType ( derived ( ) ) ;
2013-06-10 00:06:40 +02:00
}
2009-01-14 14:24:10 +00:00
template < typename OtherDerived >
bool isApprox ( const SparseMatrixBase < OtherDerived > & other ,
2014-09-22 23:33:28 +02:00
const RealScalar & prec = NumTraits < Scalar > : : dummy_precision ( ) ) const ;
2009-01-14 14:24:10 +00:00
template < typename OtherDerived >
bool isApprox ( const MatrixBase < OtherDerived > & other ,
2012-06-28 21:01:02 +02:00
const RealScalar & prec = NumTraits < Scalar > : : dummy_precision ( ) ) const
2009-01-14 14:24:10 +00:00
{ return toDense ( ) . isApprox ( other , prec ) ; }
/** \returns the matrix or vector obtained by evaluating this expression.
*
* Notice that in the case of a plain matrix or vector ( not an expression ) this function just returns
* a const reference , in order to avoid a useless copy .
*/
2010-10-25 10:15:22 -04:00
inline const typename internal : : eval < Derived > : : type eval ( ) const
{ return typename internal : : eval < Derived > : : type ( derived ( ) ) ; }
2009-01-14 14:24:10 +00:00
Scalar sum ( ) const ;
2014-07-01 13:18:56 +02:00
inline const SparseView < Derived >
pruned ( const Scalar & reference = Scalar ( 0 ) , const RealScalar & epsilon = NumTraits < Scalar > : : dummy_precision ( ) ) const ;
2009-01-07 17:01:57 +00:00
2008-06-26 23:22:26 +00:00
protected :
bool m_isRValue ;
2014-12-04 22:48:53 +01:00
static inline StorageIndex convert_index ( const Index idx ) {
return internal : : convert_index < StorageIndex > ( idx ) ;
}
2015-06-24 17:55:00 +02:00
private :
template < typename Dest > void evalTo ( Dest & ) const ;
2008-06-26 23:22:26 +00:00
} ;
2012-04-15 11:06:28 +01:00
} // end namespace Eigen
2008-06-26 23:22:26 +00:00
# endif // EIGEN_SPARSEMATRIXBASE_H