Changeset 7154de3 in tol


Ignore:
Timestamp:
Sep 21, 2009, 8:00:11 PM (17 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
54586aa
Parents:
08b6ebc
Message:

Avoiding invalid access to empty columns of sparse matrices

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@1415 be4846ae-f051-483a-831f-b64e7d08527f

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol/btol/vmatrix_type/vmat.cpp

    r08b6ebc r7154de3  
    479479    k1 = ((int*)s_.chlmRsparse_->p)[j+1];
    480480    i0 = ((int*)s_.chlmRsparse_->i)+k0;
    481     found = (int*) bsearch(&i, i0, k1-k0, sizeof(int), intCmp_);
     481    if(k0<k1)
     482    {
     483      found = (int*) bsearch(&i, i0, k1-k0, sizeof(int), intCmp_);
     484    }
     485    else
     486    {
     487      found = NULL;
     488    }
    482489    if(!found)
    483490    {
    … …  
    619626    k1y = ((int*)s_.chlmRsparse_->p)[jy+1];
    620627    i0y = ((int*)s_.chlmRsparse_->i)+k0y;
    621     iy = (int*) bsearch(&i0,i0y, k1y-k0y, sizeof(int), intCmp_);
     628    if(k0y<k1y)
     629    {
     630      iy = (int*) bsearch(&i0,i0y, k1y-k0y, sizeof(int), intCmp_);
     631    }
    622632    ky = k0y+(iy-i0y);
    623633    y = ((double*)s_.chlmRsparse_->x)+ky;
    … …  
    682692    cholmod_free_triplet (&tr_new, common_);
    683693  }
    684 /*
    685   for(jx=0; jx<cx; jx++)
    686   {
    687     jy = j0+jx;
    688     x = ((double*)x_.s_.blasRdense_->x) + (rx*jx);
    689     k0y = ((int*)s_.chlmRsparse_->p)[jy];
    690     k1y = ((int*)s_.chlmRsparse_->p)[jy+1];
    691     i0y = ((int*)s_.chlmRsparse_->i)+k0y;
    692     iy = (int*) bsearch(&i0,i0y, k1y-k0y, sizeof(int), intCmp_);
    693     ky = k0y+(iy-i0y);
    694     y = ((double*)s_.chlmRsparse_->x)+ky;
    695     for(; (ky<k1y)&&(*iy<i0+rx); ky++, y++, iy++)
    696     {
    697       *y = x[*iy-i0];
    698     }
    699   }
    700 */
    701694  return(accessCode);
    702695};
    703 
    704 /*
    705 ////////////////////////////////////////////////////////////////////////////////
    706   int BVMat::cRs_cRs_PutBlock(int i0, int j0, const BVMat& x, int& accessCode)
    707 ////////////////////////////////////////////////////////////////////////////////
    708 {
    709   //
    710   int rx=x.Rows();
    711   int cx=x.Columns();
    712   int r=Rows();
    713   int c=Columns();
    714   double* y;
    715   double* x;
    716   int ix, jx, kx, k0y, k1y, k0x, k1x;
    717   int *i0y, *found_y, *i0x;
    718   cRs_ensure_packed(  s_.chlmRsparse_);
    719   cRs_ensure_packed(x.s_.chlmRsparse_);
    720   for(jx=0; jx<cx; jx++)
    721   {
    722     jy = j0+jx;
    723     k0y = ((int*)s_.chlmRsparse_->p)[jy];
    724     k1y = ((int*)s_.chlmRsparse_->p)[jy+1];
    725     i0y = ((int*)s_.chlmRsparse_->i)+k0y;
    726     found_y = (int*) bsearch(&i0y, i0y, k1y-k0y, sizeof(int), intCmp_);
    727     k0x = ((int*)x.s_.chlmRsparse_->p)[jx];
    728     k1x = ((int*)x.s_.chlmRsparse_->p)[jx+1];
    729     i0x = ((int*)x.s_.chlmRsparse_->i)+k0x;
    730     for(kx=k0x; kx<k1x; kx++)
    731     {
    732       if(found_y[kx]!=i0x[kx]+i0)
    733       {
    734       }
    735     }
    736   }
    737 
    738 };
    739 */
    740696
    741697
Note: See TracChangeset for help on using the changeset viewer.