Changeset 5ad65fa in tol


Ignore:
Timestamp:
Nov 23, 2010, 8:43:03 AM (16 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
33d1a19
Parents:
0ccafc7
Message:

New built-in function MaxColByRow

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol/btol/matrix_type/matgra.cpp

    r0ccafc7 r5ad65fa  
    68016801
    68026802
     6803  //--------------------------------------------------------------------
     6804  DeclareContensClass(BMat, BMatTemporary, BMatMaxColByRow);
     6805  DefExtOpr(1, BMatMaxColByRow, "MaxColByRow", 1, 1, "Matrix",
     6806  "(Matrix mat)",
     6807  I2("For each row returns two columns: first one has the index of the "
     6808     "column with the maximum value inside these row, and second one "
     6809     "the maximum value. Unknown values are skipped.",
     6810     "Devuelve dos columnas para cada fila: la primera con el índice "
     6811     "de la columna de máximo valor dentro de esa fila, y la segunda "
     6812     "con dicho valor máximo. Los valores omitidos no se tienen en "
     6813     "cuenta."),
     6814     BOperClassify::Statistic_);
     6815  void BMatMaxColByRow::CalcContens()
     6816//--------------------------------------------------------------------
     6817{
     6818  BMat& m = Mat(Arg(1));
     6819  int r = m.Rows();
     6820  int c = m.Columns();
     6821  int i, j;
     6822  contens_.Alloc(r,2);
     6823  for(i=0; i<r; i++)
     6824  {
     6825    BDat& mi  = contens_.Get(i,0);
     6826    BDat& max = contens_.Get(i,1);
     6827    max = BDat::NegInf();
     6828    for(j=0; j<c; j++)
     6829    {
     6830      if(max < m(i,j))
     6831      {
     6832        mi = j+1;
     6833        max = m(i,j);
     6834      }
     6835    }
     6836  }
     6837}
     6838
    68036839//--------------------------------------------------------------------
    68046840DeclareContensClass(BMat, BMatTemporary, BMatForMat);
Note: See TracChangeset for help on using the changeset viewer.