Changeset c81695b in tol


Ignore:
Timestamp:
Dec 21, 2010, 6:18:34 PM (16 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
137d85f
Parents:
a666186
Message:

Refs #1042

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

File:
1 edited

Legend:

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

    ra666186 rc81695b  
    68016801
    68026802
    6803   //--------------------------------------------------------------------
     6803//--------------------------------------------------------------------
    68046804  DeclareContensClass(BMat, BMatTemporary, BMatMaxColByRow);
    68056805  DefExtOpr(1, BMatMaxColByRow, "MaxColByRow", 1, 1, "Matrix",
    … …  
    68366836  }
    68376837}
     6838
    68386839
    68396840//--------------------------------------------------------------------
    … …  
    69036904
    69046905//--------------------------------------------------------------------
     6906DeclareContensClass(BMat, BMatTemporary, BMatEvalMat);
     6907DefExtOpr(1, BMatEvalMat, "EvalMat", 2, 2, "Matrix Code",
     6908  "(Matrix m, Code fun)",
     6909  I2("Returns a matrix with the evaluations of a given Real to Real "
     6910     "function in each cell of specified matrix.\n"
     6911  "Example : \n"
     6912  ,
     6913  "Devuelve una matriz con las evaluaciones de una función dada de "
     6914  "Real a Real en cada celda de la matriz especificada.\n"
     6915  "Ejemplo : \n")+
     6916  "Matrix EvalMat(X, gsl_sf_log_erfc );",
     6917  BOperClassify::MatrixAlgebra_);
     6918//--------------------------------------------------------------------
     6919void BMatEvalMat::CalcContens()
     6920//--------------------------------------------------------------------
     6921{
     6922  BMat& M = Mat(Arg(1));
     6923  BCode&  code = Code(Arg(2));
     6924  int k;
     6925  int s = M.Data().Size();
     6926  BStandardOperator* opr = (BStandardOperator*)code.Operator();
     6927  if(!opr)
     6928  {
     6929    Error(I2("<fun> argument of function EvalMat has no operator",
     6930             "El argumento <fun> de la función EvalMat no tiene operador"));
     6931    return;
     6932  }
     6933  if((opr->Grammar()!= GraReal()) ||
     6934     (opr->NumArg()!=1)||
     6935     (opr->GrammarForArg(1)!=GraReal()))
     6936  {
     6937    Error(I2("<fun> argument of function EvalMat ",
     6938             "El argumento <fun> de la función EvalMat ")+"\n"+
     6939          opr->Grammar()->Name()+" "+code.Name()+opr->Arguments()+"\n"+
     6940          I2("should be declared as ",
     6941             "debería estar declarada como ")+"\n"+
     6942          "Real "+code.Name()+"(Real x) \n");
     6943    return;
     6944  }
     6945
     6946  contens_.Alloc(M.Rows(), M.Columns());
     6947  const double* x = (const double*)M.Data().Buffer();
     6948  double* y = (double*)contens_.GetData().GetBuffer();
     6949
     6950  BSyntaxObject* ev;
     6951  for(k=0; k<s; k++, x++, y++)
     6952  {
     6953    BContensDat* x_ = new BContensDat("",*x);
     6954    BList* args = NCons(x_);
     6955    ev = opr->Evaluator(args);
     6956    if(ev)
     6957    {
     6958      *y = Real(ev);
     6959      DESTROY(ev);
     6960    }
     6961  } 
     6962}
     6963
     6964
     6965//--------------------------------------------------------------------
    69056966DeclareContensClass(BMat, BMatTemporary, BMatReplace);
    69066967DefExtOpr(1, BMatReplace, "MatReplace", 3, 3, "Matrix Matrix Matrix",
Note: See TracChangeset for help on using the changeset viewer.