Changeset 6ff8ce3 in tol


Ignore:
Timestamp:
Jan 9, 2012, 9:46:38 AM (15 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
612d116
Parents:
a49be3d
Message:

Refs #1387
Vectorized functions gsl_M_cdf_beta_P and gsl_M_cdf_beta_Pinv in order to get faster simulations of truncated beta distributions

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol/btol/bgsl/tolgsl_usrapi_real.cpp

    ra49be3d r6ff8ce3  
    167167#include <gsl/gsl_randist.h>
    168168#include <gsl/gsl_cdf.h>
     169#include <tol/tol_bmatgra.h>
    169170
    170171
    … …  
    180181  DefIntOpr(ORD, BDat_##NAME, #NAME, MINARG, MAXARG, LISTARGS, DESC, BOperClassify::RealArythmetic_GSL_);
    181182
     183#define DecDefIntOprMatGsl(ORD, NAME, MINARG, MAXARG, LISTARGS, DESC)   \
     184  DeclareContensClass(BMat, BMatTemporary, BMat_##NAME); \
     185  DefIntOpr(ORD, BMat_##NAME, #NAME, MINARG, MAXARG, LISTARGS, DESC, BOperClassify::RealArythmetic_GSL_);
     186
    182187#define  ErrorGslFVer(GSLFVER, funName) \
    183188  Error(I2("Needed GSL version ", "Se necesita la version de GSL ") << GSLFVER<< \
    … …  
    43464351}
    43474352
     4353#define dMat(arg) ((DMat&)Mat(arg))
     4354#define b2dMat(M) ((DMat&)(M))
     4355
     4356//--------------------------------------------------------------------
     4357  DecDefIntOprMatGsl(1, gsl_M_cdf_beta_P, 3, 3,
     4358  "(Matrix P, Matrix a, Matrix b)",
     4359  "[GSL: GNU Scientific Library] [C2_ProbDistFun] [The Beta Distribution]\n"
     4360  "GSL chapter: Random Number Distributions \n"
     4361  "  http://www.gnu.org/software/gsl/manual/html_node/Random-Number-Distributions.html\n"
     4362  "You can see a description of correspondent C function at GSL manual page: \n"
     4363  "  http://www.gnu.org/software/gsl/manual/html_node/The-Beta-Distribution.html\n"
     4364  "Mathematical concepts about this function are exposed at : \n"
     4365  "  http://en.wikipedia.org/wiki/Beta_distribution");
     4366  void BMat_gsl_M_cdf_beta_P::CalcContens()
     4367//--------------------------------------------------------------------
     4368{
     4369  DMat& P = dMat(Arg(1));
     4370  DMat& A = dMat(Arg(2));
     4371  DMat& B = dMat(Arg(3));
     4372  double *p, *a, *b, *q;
     4373  int i;
     4374  int r = P.Rows();
     4375  int c = P.Columns();
     4376  int n = r*c;
     4377  b2dMat(contens_) = P;
     4378  p = P.GetData().GetBuffer();
     4379  a = A.GetData().GetBuffer();
     4380  b = B.GetData().GetBuffer();
     4381  q = b2dMat(contens_).GetData().GetBuffer();
     4382  for(i=0; i<r; i++, p++, a++, b++, q++)
     4383  {
     4384    *q = gsl_cdf_beta_P(*p, *a, *b);
     4385  }
     4386}
     4387
     4388//--------------------------------------------------------------------
     4389  DecDefIntOprMatGsl(1, gsl_M_cdf_beta_Pinv, 3, 3,
     4390  "(Matrix P, Matrix a, Matrix b)",
     4391  "[GSL: GNU Scientific Library] [C2_ProbDistFun] [The Beta Distribution]\n"
     4392  "GSL chapter: Random Number Distributions \n"
     4393  "  http://www.gnu.org/software/gsl/manual/html_node/Random-Number-Distributions.html\n"
     4394  "You can see a description of correspondent C function at GSL manual page: \n"
     4395  "  http://www.gnu.org/software/gsl/manual/html_node/The-Beta-Distribution.html\n"
     4396  "Mathematical concepts about this function are exposed at : \n"
     4397  "  http://en.wikipedia.org/wiki/Beta_distribution");
     4398  void BMat_gsl_M_cdf_beta_Pinv::CalcContens()
     4399//--------------------------------------------------------------------
     4400{
     4401  DMat& P = dMat(Arg(1));
     4402  DMat& A = dMat(Arg(2));
     4403  DMat& B = dMat(Arg(3));
     4404  double *p, *a, *b, *q;
     4405  int i;
     4406  int r = P.Rows();
     4407  int c = P.Columns();
     4408  int n = r*c;
     4409  b2dMat(contens_) = P;
     4410  p = P.GetData().GetBuffer();
     4411  a = A.GetData().GetBuffer();
     4412  b = B.GetData().GetBuffer();
     4413  q = b2dMat(contens_).GetData().GetBuffer();
     4414  for(i=0; i<r; i++, p++, a++, b++, q++)
     4415  {
     4416    *q = gsl_cdf_beta_Pinv(*p, *a, *b);
     4417  }
     4418}
     4419
    43484420//--------------------------------------------------------------------
    43494421  DecDefIntOprDatGsl(1, gsl_cdf_beta_Q, 3, 3,
Note: See TracChangeset for help on using the changeset viewer.