Changeset 2307 in Sophya for trunk/SophyaPI/PIext/piacmd.cc


Ignore:
Timestamp:
Jan 8, 2003, 11:56:16 PM (23 years ago)
Author:
ansari
Message:

ajout fonction rand au RPNEvaluator - Reza 8/01/2003

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PIext/piacmd.cc

    r2306 r2307  
    1212#include "strutilxx.h"
    1313// #include "dlftypes.h"
     14#ifdef SANS_EVOLPLANCK
     15#include "nbrand.h"
     16#else
     17#include "srandgen.h"
     18#endif
    1419
    1520#include "pistdimgapp.h"
     
    465470usage += "  - sin(PI/6): pi 6 / sin \n";
    466471usage += "  - 1*2*...*5: 1 2 3 4 5 product \n";
    467 usage += "  - x = $x $y * \n";
     472usage += "  - x=x+y: x = $x $y * \n";
    468473usage += "  >>> Stack operations : \n";
    469474usage += "      print x<>y pop push (duplicate x) \n";
     
    478483usage += "  >>> F(X,Y): (x,y) --> F(x,y) \n";
    479484usage += "      pow atan2 \n";
     485usage += "  >>> F(): random number generators \n";
     486usage += "      rand (flat 0..1) norand (normal/gaussian) \n";
    480487usage += "  >>> Stack sum/product/mean/sigma/sigma^2 \n";
    481488usage += "      sum product mean sigma sigma2 sigmean (y->sigma x->mean) \n";
     489RegisterHelp(kw, usage, grp);
     490
     491kw = "autoiniranf";
     492usage  = "> Automatic random number generator initialisation\n";
     493usage += "   by Auto_Ini_Ranf(int lp) \n";
     494usage += "   Usage: autoiniranf";
    482495RegisterHelp(kw, usage, grp);
    483496
     
    490503usage += "  > shell myfile.csh [arg1] [arg2] [...]\n";
    491504usage += "    (where the first line of \"myfile.csh\" is \"#!/bin/csh\")\n";
     505RegisterHelp(kw, usage, grp);
     506
     507kw = "exitpiapp";
     508usage = "To end the piapp session (Interpreter's command)";
    492509RegisterHelp(kw, usage, grp);
    493510
     
    14011418      rpnstack.top() = atan2(x,y);
    14021419    }
     1420    // generateur aleatoire
     1421    else if (args[k] == "rand") {
     1422      double rnd = drand01();
     1423      rpnstack.push(rnd);
     1424    }
     1425    else if (args[k] == "norand") {
     1426      double rnd = GauRnd(0., 1.);
     1427      rpnstack.push(rnd);
     1428    }
    14031429    // Fonction a N arguments  - Somme, produit, etc ...
    14041430    else if ((args[k] == "sum") || (args[k] == "mean") || (args[k] == "sigmean") ||
     
    16681694  ExecFile(tokens[0], tokens);
    16691695  }
     1696else if (kw == "autoiniranf") {
     1697  Auto_Ini_Ranf(1);
     1698  return(0);
     1699}
     1700// ----> Sortie d'application
     1701else if (kw == "exitpiapp") {
     1702  mImgApp->Stop();
     1703  return(0);
     1704}
    16701705else if (kw == "shell") {
    16711706  if (tokens.size() < 1) { cout << "PIACmd::Interpret() Usage: shell cmdline" << endl;  return(0); }
Note: See TracChangeset for help on using the changeset viewer.