Changeset 2706f1e in tol


Ignore:
Timestamp:
Aug 26, 2009, 9:52:06 AM (17 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
fe617e57
Parents:
0fcdd1d
Message:

New API for convertIfNeeded* functions

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

File:
1 edited

Legend:

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

    r0fcdd1d r2706f1e  
    133133
    134134////////////////////////////////////////////////////////////////////////////////
    135   int BVMat::convertIfNeeded2cRs(const BVMat&  A,  const BVMat&  B,
    136                                        BVMat*& A_,       BVMat*& B_,
    137                                  const char* fName, bool forze)
    138 //Matrix instances
    139 ////////////////////////////////////////////////////////////////////////////////
    140 {
    141   if(!autoConvert_) { return(-1); }
    142   A_ = (BVMat*)&A;
    143   B_ = (BVMat*)&B;
    144   if(forze || !((A.code_==ESC_blasRdense)&&(B.code_==ESC_blasRdense)))
    145   {
    146     if(A.code_!=ESC_chlmRsparse)
    147     {
    148       warn_convert2cRs(fName,A);
    149       A_ = new BVMat(A,ESC_chlmRsparse);
    150     }
    151     if(B.code_!=ESC_chlmRsparse)
    152     {
    153       warn_convert2cRs(fName,B);
    154       B_ = new BVMat(B,ESC_chlmRsparse);
    155     }
    156   }
    157   return(0);
    158 }
    159  
    160 ////////////////////////////////////////////////////////////////////////////////
    161135  int BVMat::convertIfNeeded_cRt2cRs(const BVMat&  A,  const BVMat&  B,
    162136                                           BVMat*& A_,       BVMat*& B_,
    … …  
    168142  A_ = (BVMat*)&A;
    169143  B_ = (BVMat*)&B;
    170   if(A.code_==ESC_chlmRtriplet)
     144  int result = 0;
     145  if((A.code_==ESC_chlmRsparse) && (B.code_==ESC_chlmRtriplet))
     146  {
     147    warn_convert2cRs(fName,B);
     148    B_ = new BVMat(B,ESC_chlmRsparse);
     149    result = 1;
     150  }
     151  else if((B.code_==ESC_chlmRsparse) && (A.code_==ESC_chlmRtriplet))
    171152  {
    172153    warn_convert2cRs(fName,A);
    173154    A_ = new BVMat(A,ESC_chlmRsparse);
    174   }
    175   if(B.code_==ESC_chlmRtriplet)
     155    result = 1;
     156  }
     157  else
     158  {
     159    if(forze && (A.code_!=ESC_chlmRsparse))
     160    {
     161      A_=new BVMat(A,ESC_chlmRsparse);
     162      result = 1;
     163    }
     164    if(forze && (B.code_!=ESC_chlmRsparse))
     165    {
     166      B_=new BVMat(B,ESC_chlmRsparse);
     167      result = 1;
     168    }
     169  }
     170  return(result);
     171}
     172
     173////////////////////////////////////////////////////////////////////////////////
     174  int BVMat::convertIfNeeded_cRt2cRs(const BVMat&  A,  BVMat*& A_,
     175                                     const char* fName)
     176//Matrix instances
     177////////////////////////////////////////////////////////////////////////////////
     178{
     179  if(!autoConvert_) { return(-1); }
     180  A_ = (BVMat*)&A;
     181  if(A.code_==ESC_chlmRtriplet)
    176182  {
    177     warn_convert2cRs(fName,B);
    178     B_ = new BVMat(B,ESC_chlmRsparse);
     183    warn_convert2cRs(fName,A);
     184    A_ = new BVMat(A, ESC_chlmRsparse);
    179185  }
    180186  return(0);
    … …  
    182188 
    183189////////////////////////////////////////////////////////////////////////////////
    184   int BVMat::convertIfNeeded2bRd(const BVMat&  A,  const BVMat&  B,
    185                                        BVMat*& A_,       BVMat*& B_,
    186                                  const char* fName, bool forze)
     190  int BVMat::convertIfNeeded_all2cRs(const BVMat&  A,  const BVMat&  B,
     191                                           BVMat*& A_,       BVMat*& B_,
     192                                     const char* fName, bool forze)
    187193//Matrix instances
    188194////////////////////////////////////////////////////////////////////////////////
    … …  
    191197  A_ = (BVMat*)&A;
    192198  B_ = (BVMat*)&B;
     199  int result = 0;
     200  if((A.code_==ESC_chlmRsparse) && (B.code_!=ESC_chlmRsparse))
     201  {
     202    warn_convert2cRs(fName,B);
     203    B_ = new BVMat(B, ESC_chlmRsparse);
     204    result = 1;
     205  }
     206  else if((B.code_==ESC_chlmRsparse) && (A.code_!=ESC_chlmRsparse))
     207  {
     208    warn_convert2cRs(fName,B);
     209    A_ = new BVMat(A, ESC_chlmRsparse);
     210    result = 1;
     211  }
     212  else
     213  {
     214    if(forze && (A.code_!=ESC_chlmRsparse))
     215    {
     216      A_=new BVMat(A,ESC_chlmRsparse);
     217      result = 1;
     218    }
     219    if(forze && (B.code_!=ESC_chlmRsparse))
     220    {
     221      B_=new BVMat(B,ESC_chlmRsparse);
     222      result = 1;
     223    }
     224  }
     225  return(result);
     226}
     227 
     228////////////////////////////////////////////////////////////////////////////////
     229  int BVMat::convertIfNeeded_all2cRs(const BVMat&  A,  BVMat*& A_,
     230                                     const char* fName)
     231//Matrix instances
     232////////////////////////////////////////////////////////////////////////////////
     233{
     234  if(!autoConvert_) { return(-1); }
     235  A_ = (BVMat*)&A;
     236  if(A.code_!=ESC_chlmRsparse)
     237  {
     238    warn_convert2cRs(fName,A);
     239    A_ = new BVMat(A, ESC_chlmRsparse);
     240  }
     241  return(0);
     242}
     243 
     244
     245////////////////////////////////////////////////////////////////////////////////
     246  int BVMat::convertIfNeeded_all2bRd(const BVMat&  A,  const BVMat&  B,
     247                                           BVMat*& A_,       BVMat*& B_,
     248                                     const char* fName, bool forze)
     249//Matrix instances
     250////////////////////////////////////////////////////////////////////////////////
     251{
     252  if(!autoConvert_) { return(-1); }
     253  A_ = (BVMat*)&A;
     254  B_ = (BVMat*)&B;
     255  int result = 0;
    193256  if((A.code_==ESC_blasRdense) && (B.code_!=ESC_blasRdense))
    194257  {
    195258    warn_convert2bRd(fName,B);
    196259    B_ = new BVMat(B, ESC_blasRdense);
     260    result = 1;
    197261  }
    198262  else if((B.code_==ESC_blasRdense) && (A.code_!=ESC_blasRdense))
    … …  
    200264    warn_convert2bRd(fName,A);
    201265    A_ = new BVMat(A, ESC_blasRdense);
     266    result = 1;
    202267  }
    203268  else
    204269  {
    205     if(forze||(A.code_==ESC_chlmRtriplet)) { A_=new BVMat(A,ESC_chlmRsparse); }
    206     if(forze||(B.code_==ESC_chlmRtriplet)) { B_=new BVMat(B,ESC_chlmRsparse); }
    207   }
    208   return(0);
    209 }
    210 
    211 ////////////////////////////////////////////////////////////////////////////////
    212   int BVMat::convertIfNeeded2bRd(const BVMat&  A,  BVMat*& A_,
    213                                  const char* fName)
     270    if(forze && (A.code_!=ESC_blasRdense))
     271    {
     272      A_=new BVMat(A,ESC_blasRdense);
     273      result = 1;
     274    }
     275    if(forze && (B.code_!=ESC_blasRdense))
     276    {
     277      B_=new BVMat(B,ESC_blasRdense);
     278      result = 1;
     279    }
     280  }
     281  return(result);
     282}
     283
     284////////////////////////////////////////////////////////////////////////////////
     285  int BVMat::convertIfNeeded_all2bRd(const BVMat&  A,  BVMat*& A_,
     286                                     const char* fName)
    214287//Matrix instances
    215288////////////////////////////////////////////////////////////////////////////////
    … …  
    9351008  }
    9361009  BVMat* A__, *B__;
    937   convertIfNeeded2cRs(A_,B_,A__,B__,"|");
     1010  if((A_.code_!=ESC_blasRdense)||(B_.code_!=ESC_blasRdense))
     1011  {
     1012    convertIfNeeded_all2cRs(A_,B_,A__,B__,"|",true);
     1013  }
     1014  else
     1015  {
     1016    A__=(BVMat*)&A_;
     1017    B__=(BVMat*)&B_;
     1018  }
    9381019  BVMat &A = *A__,  &B = *B__;
    9391020  int cC = cA+cB;
    … …  
    9891070  }
    9901071  BVMat* A__, *B__;
    991   convertIfNeeded2cRs(A_,B_,A__,B__,"<<");
     1072  if((A_.code_!=ESC_blasRdense)||(B_.code_!=ESC_blasRdense))
     1073  {
     1074    convertIfNeeded_all2cRs(A_,B_,A__,B__,"<<",true);
     1075  }
     1076  else
     1077  {
     1078    A__=(BVMat*)&A_;
     1079    B__=(BVMat*)&B_;
     1080  }
    9921081  BVMat &A = *A__,  &B = *B__;
    9931082  int j;
Note: See TracChangeset for help on using the changeset viewer.