Skip to content

Commit

Permalink
Avoid PLAIN_LIST
Browse files Browse the repository at this point in the history
Using generic list access is slightly slower, but this should never be
the bottleneck compared to the linear algebra.
  • Loading branch information
fingolfin committed Aug 5, 2022
1 parent 7f42885 commit 4f17557
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/cvec.c
Original file line number Diff line number Diff line change
Expand Up @@ -3733,7 +3733,6 @@ static Obj CLEANROWKERNEL( Obj self, Obj basis, Obj vec, Obj extend, Obj dec )
vectors : matrix of basis vectors in semi echelon form
must be a cmat here!
pivots : integer list of pivot columns of basis matrix
will be made into a plain list rep.
vec : vector of same length as basis vectors
must be a cvec here
extend : either true or false, indicating, whether the basis is extended
Expand Down Expand Up @@ -3765,10 +3764,8 @@ static Obj CLEANROWKERNEL( Obj self, Obj basis, Obj vec, Obj extend, Obj dec )
Int newpiv;
int fnzcounter = 0;

PLAIN_LIST(pivots);
if (TNUM_OBJ(pivots) < FIRST_PLIST_TNUM ||
TNUM_OBJ(pivots) > LAST_PLIST_TNUM) {
return OurErrorBreakQuit("CLEANROWKERNEL: pivots is not in plist rep");
if (!IS_POSS_LIST(pivots)) {
return OurErrorBreakQuit("CLEANROWKERNEL: pivots must be a list of positive integers");
}

if (dec == Fail)
Expand Down Expand Up @@ -3797,7 +3794,7 @@ static Obj CLEANROWKERNEL( Obj self, Obj basis, Obj vec, Obj extend, Obj dec )
Int c;
if (cldec) decdec = DATA_CVEC(dec);
for (j = 1;j <= len;j++) {
Int piv = INT_INTOBJ(ELM_PLIST(pivots,j));
Int piv = INT_INTOBJ(ELM_LIST(pivots,j));
if (++fnzcounter >= 10) {
firstnz = CVEC_Firstnzp(fi,vecvec,vlen);
fnzcounter = 0;
Expand Down Expand Up @@ -3833,7 +3830,7 @@ static Obj CLEANROWKERNEL( Obj self, Obj basis, Obj vec, Obj extend, Obj dec )
Word *decdec = 0L;
if (cldec) decdec = DATA_CVEC(dec);
for (j = 1;j <= len;j++) {
Int piv = INT_INTOBJ(ELM_PLIST(pivots,j));
Int piv = INT_INTOBJ(ELM_LIST(pivots,j));
if (++fnzcounter >= 10) {
firstnz = CVEC_Firstnzq(fi,vecvec,vlen,wordlen);
fnzcounter = 0;
Expand Down

0 comments on commit 4f17557

Please sign in to comment.