Sha256: f3e68290cad5fbbba0ecf8284fa238a52072108e3368c0632f8c90816b41dc91

Contents?: true

Size: 1.66 KB

Versions: 23

Compression:

Stored size: 1.66 KB

Contents

// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// Copyright (C) 2008-2014 Gael Guennebaud <gael.guennebaud@inria.fr>
//
// 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/.

#ifndef EIGEN_SPARSEREDUX_H
#define EIGEN_SPARSEREDUX_H

namespace Eigen { 

template<typename Derived>
typename internal::traits<Derived>::Scalar
SparseMatrixBase<Derived>::sum() const
{
  eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix");
  Scalar res(0);
  internal::evaluator<Derived> thisEval(derived());
  for (Index j=0; j<outerSize(); ++j)
    for (typename internal::evaluator<Derived>::InnerIterator iter(thisEval,j); iter; ++iter)
      res += iter.value();
  return res;
}

template<typename _Scalar, int _Options, typename _Index>
typename internal::traits<SparseMatrix<_Scalar,_Options,_Index> >::Scalar
SparseMatrix<_Scalar,_Options,_Index>::sum() const
{
  eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix");
  if(this->isCompressed())
    return Matrix<Scalar,1,Dynamic>::Map(m_data.valuePtr(), m_data.size()).sum();
  else
    return Base::sum();
}

template<typename _Scalar, int _Options, typename _Index>
typename internal::traits<SparseVector<_Scalar,_Options, _Index> >::Scalar
SparseVector<_Scalar,_Options,_Index>::sum() const
{
  eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix");
  return Matrix<Scalar,1,Dynamic>::Map(m_data.valuePtr(), m_data.size()).sum();
}

} // end namespace Eigen

#endif // EIGEN_SPARSEREDUX_H

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
tomoto-0.5.1 vendor/eigen/Eigen/src/SparseCore/SparseRedux.h
tomoto-0.5.0 vendor/eigen/Eigen/src/SparseCore/SparseRedux.h
tomoto-0.4.1 vendor/eigen/Eigen/src/SparseCore/SparseRedux.h
umappp-0.2.0 vendor/Eigen/src/SparseCore/SparseRedux.h
tomoto-0.4.0 vendor/eigen/Eigen/src/SparseCore/SparseRedux.h
tomoto-0.3.3 vendor/eigen/Eigen/src/SparseCore/SparseRedux.h
tomoto-0.3.2 vendor/eigen/Eigen/src/SparseCore/SparseRedux.h
tomoto-0.3.1 vendor/eigen/Eigen/src/SparseCore/SparseRedux.h
umappp-0.1.6 vendor/Eigen/src/SparseCore/SparseRedux.h
umappp-0.1.5 vendor/Eigen/src/SparseCore/SparseRedux.h
umappp-0.1.4 vendor/Eigen/src/SparseCore/SparseRedux.h
umappp-0.1.3 vendor/Eigen/src/SparseCore/SparseRedux.h
umappp-0.1.2 vendor/Eigen/src/SparseCore/SparseRedux.h
tomoto-0.3.0 vendor/eigen/Eigen/src/SparseCore/SparseRedux.h
tomoto-0.2.3 vendor/eigen/Eigen/src/SparseCore/SparseRedux.h
tomoto-0.2.2 vendor/eigen/Eigen/src/SparseCore/SparseRedux.h
tomoto-0.2.1 vendor/eigen/Eigen/src/SparseCore/SparseRedux.h
tomoto-0.2.0 vendor/eigen/Eigen/src/SparseCore/SparseRedux.h
tomoto-0.1.4 vendor/eigen/Eigen/src/SparseCore/SparseRedux.h
tomoto-0.1.3 vendor/eigen/Eigen/src/SparseCore/SparseRedux.h