diff --git a/Solver/linearSystemCSR.h b/Solver/linearSystemCSR.h index 9309816813d8f1afda70c30789e10ad78d212c7c..6387315df9151ae1ab9fab805cfef41ba6df79d2 100644 --- a/Solver/linearSystemCSR.h +++ b/Solver/linearSystemCSR.h @@ -55,7 +55,30 @@ class linearSystemCSR : public linearSystem<scalar> { 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){ if(ai[position] == ic){ a[position] += val;