Changeset 04e6eaf in tol


Ignore:
Timestamp:
Sep 19, 2012, 8:48:20 AM (14 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
43cd166
Parents:
45b1fd8
Message:

Ensuring positiveness of matrix dimensions

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

File:
1 edited

Legend:

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

    r45b1fd8 r04e6eaf  
    320320{
    321321  BVMat& v = VMat(Arg(1));
    322   int nrow = (int)Real(Arg(2));
    323   int ncol = (int)Real(Arg(3));
     322  int nrow = max(0,(int)Real(Arg(2)));
     323  int ncol = max(0,(int)Real(Arg(3)));
    324324  int row0 = (int)Real(Arg(4))-1;
    325325  int col0 = (int)Real(Arg(5))-1;
    … …  
    342342//--------------------------------------------------------------------
    343343{
    344   int nrow = (int)Real(Arg(1));
     344  int nrow = max(0,(int)Real(Arg(1)));
    345345  BSet& items = Set(Arg(2));
    346346  contens_.MergeRows(nrow, items);
    … …  
    562562{
    563563  BSyntaxObject* ijx_ = Arg(1);
    564   int nrow = (int)Real(Arg(2));
    565   int ncol = (int)Real(Arg(3));
     564  int nrow = max(0,(int)Real(Arg(2)));
     565  int ncol = max(0,(int)Real(Arg(3)));
    566566  BMatrix<double> ijx;
    567567  if(ijx_->Grammar()==GraMatrix())
    … …  
    681681{
    682682  BMatrix<double>& ijx = (BMatrix<double>&)Mat(Arg(1));
    683   int nrow = (int)Real(Arg(2));
    684   int ncol = (int)Real(Arg(3));
     683  int nrow = max(0,(int)Real(Arg(2)));
     684  int ncol = max(0,(int)Real(Arg(3)));
    685685  contens_.DMat2tripletUnique(ijx,nrow,ncol);
    686686}
    … …  
    725725{
    726726  BPolyn<BDat>& pol = Pol(Arg(1));
    727   register int r = (BInt)Real(Arg(2));
    728   register int c = (BInt)Real(Arg(3));
     727  register int r = max(0,(BInt)Real(Arg(2)));
     728  register int c = max(0,(BInt)Real(Arg(3)));
    729729  contens_.BPol2sparse(pol, r, c);
    730730  assert(contens_.Check());
    … …  
    744744//--------------------------------------------------------------------
    745745{
    746   int r = (BInt)Real(Arg(1));
    747   int c = (BInt)Real(Arg(2));
     746  int r = max(0,(BInt)Real(Arg(1)));
     747  int c = max(0,(BInt)Real(Arg(2)));
    748748  double v = Real(Arg(3));
    749749  contens_.BlasRDense(r,c, v);
    … …  
    765765//--------------------------------------------------------------------
    766766{
    767   int nrow = (int)Real(Arg(1));
     767  int nrow = max(0,(int)Real(Arg(1)));
    768768  int ncol = nrow;
    769769  BVMat::ECode code = BVMat::ESC_chlmRsparse;
    770   if(Arg(2)) { ncol = (int)Real(Arg(2)); }
     770  if(Arg(2)) { ncol = max(0,(int)Real(Arg(2))); }
    771771  if(Arg(3)) { code = BVMat::FindCodeName(Text(Arg(3))); }
    772772  contens_.Zeros(nrow,ncol,code);
    … …  
    796796//--------------------------------------------------------------------
    797797{
    798   int nrow = (int)Real(Arg(1));
     798  int nrow = max(0,(int)Real(Arg(1)));
    799799  int ncol = nrow;
    800   if(Arg(2)) { ncol=(int)Real(Arg(2)); }
     800  if(Arg(2)) { ncol=max(0,(int)Real(Arg(2))); }
    801801  if(!Arg(3))
    802802  {
    … …  
    805805  else
    806806  {
    807     int diag = (int)Real(Arg(3));
     807    int diag = max(0,(int)Real(Arg(3)));
    808808    BSyntaxObject* x_ = Arg(4);
    809809    bool isReal = !x_;
    … …  
    24692469//--------------------------------------------------------------------
    24702470{
    2471   int    nrow = (int)Real(Arg(1));
    2472   int    ncol = (int)Real(Arg(2));
     2471  int    nrow = max(0,(int)Real(Arg(1)));
     2472  int    ncol = max(0,(int)Real(Arg(2)));
    24732473  double min  = Real(Arg(3));
    24742474  double max  = Real(Arg(4));
    … …  
    25012501//--------------------------------------------------------------------
    25022502{
    2503   int    nrow = (int)Real(Arg(1));
    2504   int    ncol = (int)Real(Arg(2));
     2503  int    nrow = max(0,(int)Real(Arg(1)));
     2504  int    ncol = max(0,(int)Real(Arg(2)));
    25052505  double nu   = Real(Arg(3));
    25062506  double sig  = Real(Arg(4));
    … …  
    25432543  int burn = 0;
    25442544  double borderDistance = 0.001;
    2545   if(Arg(4)) { ncol = (int)Real(Arg(4)); }
     2545  if(Arg(4)) { max(0,ncol = (int)Real(Arg(4))); }
    25462546  if(Arg(5)) { burn = (int)Real(Arg(5)); }
    25472547  if(Arg(6)) { burn = (int)Real(Arg(6)); }
Note: See TracChangeset for help on using the changeset viewer.