Skip to content
Snippets Groups Projects
Commit 27613921 authored by Jonathan Lambrechts's avatar Jonathan Lambrechts
Browse files

Solver : linearSystemCSR : faster access to matrix entries when sorted

(10 times faster for a typical CG matrix on p6 tet)
parent 9e76055a
No related branches found
No related tags found
No related merge requests found
...@@ -55,7 +55,30 @@ class linearSystemCSR : public linearSystem<scalar> { ...@@ -55,7 +55,30 @@ class linearSystemCSR : public linearSystem<scalar> {
INDEX_TYPE position = jptr[il]; INDEX_TYPE position = jptr[il];
if(something[il]) { if (sorted) { // use bisection and direct adressing if sorted
int p0 = jptr[il];
int p1 = jptr[il+1];
while (p1-p0 > 20) {
position = ((p0+p1)/2);
if (ai[position] > ic)
p1 = position;
else if (ai[position] < ic)
p0 = position + 1;
else {
a[position] += val;
return;
}
}
for (position = p0; position < p1; position++) {
if (ai[position] >= ic) {
if (ai[position] == ic){
a[position] += val;
return;
}
break;
}
}
} else if(something[il]) {
while(1){ while(1){
if(ai[position] == ic){ if(ai[position] == ic){
a[position] += val; a[position] += val;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment