Make loadMarket use the sparse-matrix index type, thus enabling loading huge matrices.

This commit is contained in:
Gael Guennebaud 2014-07-31 16:43:19 +02:00
parent ba694ce8cf
commit d79516660c

View File

@ -133,6 +133,7 @@ template<typename SparseMatrixType>
bool loadMarket(SparseMatrixType& mat, const std::string& filename)
{
typedef typename SparseMatrixType::Scalar Scalar;
typedef typename SparseMatrixType::Index Index;
std::ifstream input(filename.c_str(),std::ios::in);
if(!input)
return false;
@ -142,11 +143,11 @@ bool loadMarket(SparseMatrixType& mat, const std::string& filename)
bool readsizes = false;
typedef Triplet<Scalar,int> T;
typedef Triplet<Scalar,Index> T;
std::vector<T> elements;
int M(-1), N(-1), NNZ(-1);
int count = 0;
Index M(-1), N(-1), NNZ(-1);
Index count = 0;
while(input.getline(buffer, maxBuffersize))
{
// skip comments
@ -169,7 +170,7 @@ bool loadMarket(SparseMatrixType& mat, const std::string& filename)
}
else
{
int i(-1), j(-1);
Index i(-1), j(-1);
Scalar value;
if( internal::GetMarketLine(line, M, N, i, j, value) )
{