Changeset b77a57a in tol


Ignore:
Timestamp:
Jan 27, 2009, 10:24:25 AM (18 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
c2dbd4c
Parents:
ee5da7f
Message:

New method SubDiag

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

Location:
tol/btol/vmatrix_type
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • tol/btol/vmatrix_type/tol_bvmat.h

    ree5da7f rb77a57a  
    454454  int SubCols (const BArray<int>& rows, BVMat& aux) const;
    455455  int SubBand (int from, int until, BVMat& aux) const;
     456  int SubDiag(int numDiag, BVMat& aux) const;
     457
    456458  BVMat  Sub     (int i, int j, int r, int c  ) const;
    457459  BVMat  SubCells(const BArray<int>& rows, const BArray<int>& cols) const;
    … …  
    459461  BVMat  SubCols (const BArray<int>& cols ) const;
    460462  BVMat  SubBand (int from, int until) const;
     463  BVMat  SubDiag (int numDiag) const;
    461464 
    462465  static void cRs_ensure_packed(cholmod_sparse_struct* sp);
  • tol/btol/vmatrix_type/vmat_convert.cpp

    ree5da7f rb77a57a  
    12341234    break;
    12351235  default:
    1236     err_cannot_apply("SubBand",I2("(Not implemenmted)",
     1236    err_cannot_apply("SubBand",I2("(Not implemented)",
    12371237                   "(Metodo no implementado)"),*this);
    12381238    return(-2); }
    … …  
    12511251};
    12521252
     1253
     1254////////////////////////////////////////////////////////////////////////////////
     1255  int BVMat::SubDiag(int numDiag, BVMat& aux) const
     1256//Matrix algebra operator
     1257//Extracts cell (i,j) matching i-j=numDiag
     1258////////////////////////////////////////////////////////////////////////////////
     1259{
     1260  int fail = 0;
     1261  int rows = Rows();
     1262  int cols = Columns();
     1263  int dMin = -rows+1;
     1264  int dMax =  cols-1;
     1265  bool outOfRange = (numDiag<dMin)||(numDiag>dMax);
     1266  if(!outOfRange)
     1267  {
     1268    BVMat band;
     1269    fail = SubBand(numDiag, numDiag, band);
     1270    if(!fail)
     1271    {
     1272      int i0 = (numDiag>=0)?0:-numDiag;
     1273      int j0 = (numDiag<=0)?0:+numDiag;
     1274      int len = Minimum(rows-i0,cols-j0);
     1275      assert(len>0);
     1276      int k;
     1277      aux.BlasRDense(1,len);
     1278      double* x = (double*)(aux.s_.blasRdense_->x);
     1279      for(k=0; k<len; k++)
     1280      {
     1281        x[k] = band.GetCell(k+numDiag,k);
     1282      }
     1283    }
     1284  }
     1285  else
     1286  {
     1287    err_cannot_apply("SubDiag",I2("(Diagonal number out of range)",
     1288                     "(Número de diagonal fuera de rango)")+
     1289                     "["+dMin+","+dMax+"]",*this);
     1290    fail = -3;
     1291  }
     1292  return(fail);
     1293};
     1294
     1295////////////////////////////////////////////////////////////////////////////////
     1296  BVMat BVMat::SubDiag(int numDiag) const
     1297//Matrix algebra operator
     1298//Extracts cell (i,j) matching i-j=numDiag
     1299////////////////////////////////////////////////////////////////////////////////
     1300{
     1301  BVMat aux;
     1302  SubDiag(numDiag, aux);
     1303  return(aux);
     1304}
  • tol/btol/vmatrix_type/vmatgra.cpp

    ree5da7f rb77a57a  
    996996  I2("Extracts the selected consecutive diagonals. Main diagonal is "
    997997     "referenced as 0, lower ones are negative numbers and upper ones "
    998      "positive.",
     998     "positive. Returned matrix has same dimensions than incoming one.",
    999999     "Extrae las diagonales consecutivas seleccionadas. La diagonal "
    10001000     "principal se referencia como 0, las inferiores como números "
    1001      "negativos y las superiores como positivos."),
     1001     "negativos y las superiores como positivos. La matriz devuelta "
     1002     "tiene las mismas dimensiones que la entrante."),
    10021003    BOperClassify::MatrixAlgebra_);
    10031004//--------------------------------------------------------------------
    … …  
    10131014  assert(contens_.Check());
    10141015}
     1016
     1017
     1018//--------------------------------------------------------------------
     1019DeclareContensClass(BVMat, BVMatTemporary, BVMatSubDiag);
     1020DefExtOpr(1, BVMatSubDiag, "SubDiag", 1, 1,
     1021  "VMatrix Real ",
     1022  "(VMatrix m [, Real diagNumber=0])",
     1023  I2("Extracts the selected diagonal as a row matrix. Main diagonal is "
     1024     "referenced as 0, lower ones are negative numbers and upper ones "
     1025     "positive.",
     1026     "Extrae la diagonales seleccionada como una matriz fila. La diagonal "
     1027     "principal se referencia como 0, las inferiores como números "
     1028     "negativos y las superiores como positivos."),
     1029    BOperClassify::MatrixAlgebra_);
     1030//--------------------------------------------------------------------
     1031void BVMatSubDiag::CalcContens()
     1032//--------------------------------------------------------------------
     1033{
     1034  BVMat& M = VMat(Arg(1));
     1035  int diagNum = 0;
     1036  if(Arg(2)) { diagNum = (int)Real(Arg(2)); }
     1037  M.SubDiag(diagNum,contens_);
     1038  assert(contens_.Check());
     1039}
     1040
    10151041
    10161042/*------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.