aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported/Eigen/src/SparseExtra/MarketIO.h
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2012-06-15 09:07:13 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2012-06-15 09:07:13 +0200
commit3fd2beebc8a3d118f508fe43efd4217c1bfa9c97 (patch)
tree31071ccbd98acfee71a94477db83e5744d8a0415 /unsupported/Eigen/src/SparseExtra/MarketIO.h
parentc858fb353f90673614da5acc3adac5dd18fdf9fc (diff)
Matrix-Market: fix perf issue and infinite loop
Diffstat (limited to 'unsupported/Eigen/src/SparseExtra/MarketIO.h')
-rw-r--r--unsupported/Eigen/src/SparseExtra/MarketIO.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/unsupported/Eigen/src/SparseExtra/MarketIO.h b/unsupported/Eigen/src/SparseExtra/MarketIO.h
index ddca225d7..9cfe1d9f5 100644
--- a/unsupported/Eigen/src/SparseExtra/MarketIO.h
+++ b/unsupported/Eigen/src/SparseExtra/MarketIO.h
@@ -156,6 +156,9 @@ bool loadMarket(SparseMatrixType& mat, const std::string& filename)
char buffer[maxBuffersize];
bool readsizes = false;
+
+ typedef Triplet<Scalar,int> T;
+ std::vector<T> elements;
int M(-1), N(-1), NNZ(-1);
int count = 0;
@@ -186,13 +189,13 @@ bool loadMarket(SparseMatrixType& mat, const std::string& filename)
if( internal::GetMarketLine(line, M, N, i, j, value) )
{
++ count;
- mat.insert(i,j) = value;
+ elements.push_back(T(i,j,value));
}
else
std::cerr << "Invalid read: " << i << "," << j << "\n";
}
}
- mat.makeCompressed();
+ mat.setFromTriplets(elements.begin(), elements.end());
if(count!=NNZ)
std::cerr << count << "!=" << NNZ << "\n";