Changeset 2bae2a0 in tol


Ignore:
Timestamp:
Feb 12, 2009, 5:25:37 PM (18 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
724ff2f
Parents:
0066614
Message:

New parameter of configuration BVMat::autoConvert_

In method cRs_bRd_PutBlock, error message " ... has not a non zero cell ... " is replaced by a warning and matrix is modified to be dense in specified block

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

File:
1 edited

Legend:

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

    r0066614 r2bae2a0  
    4444BVMat::StrCholSol  BVMat::cholSol_        [BVMat::cholSol_numOpt];;
    4545BVMat::StrCholFac  BVMat::cholFac_        [BVMat::cholFac_numOpt];;
    46 cholmod_common    *BVMat::common_  = NULL;
    47 FILE              *BVMat::cholmod_print_file_=NULL;
    48 
     46cholmod_common    *BVMat::common_             = NULL;
     47FILE              *BVMat::cholmod_print_file_ = NULL;
     48BDat               BVMat::autoConvert_        = true;
    4949
    5050////////////////////////////////////////////////////////////////////////////////
    … …  
    5353
    5454static cholmod_common BVMat_cholmod_common;
     55
     56////////////////////////////////////////////////////////////////////////////////
     57BDat& BVMat::AutoConvert()
     58////////////////////////////////////////////////////////////////////////////////
     59{
     60  return(autoConvert_);
     61}
    5562
    5663////////////////////////////////////////////////////////////////////////////////
    … …  
    555562  double* y;
    556563  double* x;
    557   int jx, k0y, k1y, ky, jy;
     564  int i, k, jx, k0y, k1y, ky, jy;
    558565  int *i0y, *iy;
    559566  cRs_ensure_packed(  s_.chlmRsparse_);
    560   for(jx=0; jx<cx; jx++)
     567  int nfk = 0;
     568  BArray<int>    nfi(rx*cx);
     569  BArray<int>    nfj(rx*cx);
     570  BArray<double> nfx(rx*cx);
     571  for(jx=0; (jx<cx); jx++)
    561572  {
    562573    jy = j0+jx;
    … …  
    566577    i0y = ((int*)s_.chlmRsparse_->i)+k0y;
    567578    iy = (int*) bsearch(&i0,i0y, k1y-k0y, sizeof(int), intCmp_);
    568     if(!iy)
    569     {
    570       accessCode = -3;
    571       err_cannot_apply("PutVMatBlock",
    572         I2("(position ["+i0+","+jy+"] has not a non zero cell of sparse "
    573            "matrix to be modified)",
    574            "(la posición ["+i0+","+jy+"] no contiene una celda no nula de "
    575            "la matriz sparse a modificar)"),
    576         *this);
    577 
    578       return(accessCode);
    579     }
     579    ky = k0y+(iy-i0y);
     580    y = ((double*)s_.chlmRsparse_->x)+ky;
     581    for(k=0; k<rx; k++, ky++, y++)
     582    {
     583      if(!iy || ( (i = *iy-i0) !=k))
     584      {
     585        nfi[nfk]=i0+k;
     586        nfj[nfk]=jy;
     587        nfx[nfk]=x[k];
     588        nfk++;
     589      }
     590      else
     591      {
     592        *y = x[k];
     593      }
     594      if(iy)
     595      {
     596        assert((ky<k1y)&&(*iy<i0+rx));
     597        iy++;
     598      }
     599    }
     600  }
     601  if(nfk)
     602  {
     603    warn_cannot_apply("PutVMatBlock",
     604      I2("(There are "+nfk+" non stored cells of sparse "
     605         "matrix that will be be modified)",
     606         "(Existen "+nfk+" celdas no almacenadas de "
     607         "la matriz sparse que serán modificadas)"),
     608      *this);
     609    cholmod_R_triplet* tr_old =
     610      cholmod_sparse_to_triplet(s_.chlmRsparse_, common_);
     611    cholmod_R_triplet* tr_new =
     612      cholmod_allocate_triplet(r, c, tr_old->nzmax+nfk, 0, CHOLMOD_REAL, common_);
     613    tr_new->nnz = tr_new->nzmax;
     614    int*    i_old = (int*)   tr_old->i;
     615    int*    j_old = (int*)   tr_old->j;
     616    double* x_old = (double*)tr_old->x;
     617    int*    i_new = (int*)   tr_new->i;
     618    int*    j_new = (int*)   tr_new->j;
     619    double* x_new = (double*)tr_new->x;
     620    int c=0;
     621    for(k=0; k<tr_old->nzmax; k++)
     622    {
     623      i_new[c] = i_old[k];
     624      j_new[c] = j_old[k];
     625      x_new[c] = x_old[k];
     626      c++;
     627    }
     628    for(k=0; k<nfk; k++)
     629    {
     630      i_new[c] = nfi[k];
     631      j_new[c] = nfj[k];
     632      x_new[c] = nfx[k];
     633      c++;
     634    }
     635    cholmod_free_sparse (&s_.chlmRsparse_, common_);
     636    s_.chlmRsparse_ = cholmod_triplet_to_sparse
     637    (tr_new, tr_new->nnz, common_);
     638    cholmod_free_triplet (&tr_old, common_);
     639    cholmod_free_triplet (&tr_new, common_);
     640  }
     641/*
     642  for(jx=0; jx<cx; jx++)
     643  {
     644    jy = j0+jx;
     645    x = ((double*)x_.s_.blasRdense_->x) + (rx*jx);
     646    k0y = ((int*)s_.chlmRsparse_->p)[jy];
     647    k1y = ((int*)s_.chlmRsparse_->p)[jy+1];
     648    i0y = ((int*)s_.chlmRsparse_->i)+k0y;
     649    iy = (int*) bsearch(&i0,i0y, k1y-k0y, sizeof(int), intCmp_);
    580650    ky = k0y+(iy-i0y);
    581651    y = ((double*)s_.chlmRsparse_->x)+ky;
    … …  
    585655    }
    586656  }
     657*/
    587658  return(accessCode);
    588659};
Note: See TracChangeset for help on using the changeset viewer.