Bug 605 - SparseMatrix index type of short int fails to compile
SparseMatrix index type of short int fails to compile
Status: RESOLVED FIXED
Product: Eigen
Classification: Unclassified
Component: Sparse
unspecified
All All
: Lowest minor
Assigned To: Nobody
:
Depends on:
Blocks: 3.2
  Show dependency treegraph
 
Reported: 2013-05-29 18:32 UTC by Roy Stogner
Modified: 2013-06-10 10:12 UTC (History)
2 users (show)



Attachments

Description Roy Stogner 2013-05-29 18:32:35 UTC
Constructing a Eigen::SparseMatrix<Real, Eigen::RowMajor, short> and then attempting to call diagonal() on the result fails:

/opt/apps/ossw/libraries/eigen/eigen-3.1.3/include/eigen3/Eigen/src/Core/Diagonal.h:77: error: call of overloaded 'min(short int, int)' is ambiguous

The arithmetic on rows()+/-value() at that line promotes the results from short to int, which is then (on a typical system) different from and not std::min comparable with short.

The same error appears to exist in 3.1.91 (mercurial changeset ab987ecbac8c), the newest version I could find, at line 78.
Comment 1 Roy Stogner 2013-05-29 18:33:58 UTC
I meant to mark this as the lowest importance; anyone who isn't starved for RAM can work around the bug by just using int as their index type.
Comment 2 Gael Guennebaud 2013-06-10 00:18:46 UTC
cannot reproduce with:

#include <Eigen/Sparse>
int main(){
  Eigen::SparseMatrix<double, Eigen::RowMajor, short> m(10,10);
  m.diagonal();
  return 0;
}

Tested with various versions of gcc, clang and Eigen.
Comment 3 Roy Stogner 2013-06-10 01:57:49 UTC
Hmmm... I can't reproduce the error with that test either, and I can't see any reason why not.  I'm double-checking to make sure the environment I'm currently using still fails in my full code; assuming it does then I'll try to distill that into a short enough test case to post.
Comment 4 Roy Stogner 2013-06-10 08:45:19 UTC
The error (if it is a library error) only seems to trigger when I try to assign the diagonal:

#include <Eigen/Sparse>

int main(){
  Eigen::SparseMatrix<double, Eigen::RowMajor, short> m(10,10);
  Eigen::Matrix<double, Eigen::Dynamic, 1> v(10);
  v = m.diagonal();
  return 0;
}
Comment 5 Christoph Hertzberg 2013-06-10 08:50:54 UTC
(In reply to comment #2)
> cannot reproduce with:
> 
> #include <Eigen/Sparse>
> int main(){
>   Eigen::SparseMatrix<double, Eigen::RowMajor, short> m(10,10);
>   m.diagonal();
>   return 0;
> }


If you call the offending rows-method, you'll get the reported (or similar) error:
>   m.diagonal().rows();
Comment 6 Gael Guennebaud 2013-06-10 10:12:22 UTC
https://bitbucket.org/eigen/eigen/commits/f69804538dde/
Changeset:   f69804538dde
User:        ggael
Date:        2013-06-10 10:11:29
Summary:     Fix bug 605: ambiguous call to std::min when calling .diagonal() on a sparse matrix with non default index type

Note You need to log in before you can comment on or make changes to this bug.