summaryrefslogtreecommitdiff
path: root/js/Sources/RAND_f.js
blob: 901c2e9d40c1fbf1d306cbe38ec595cb4ff0010d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* autogenerated from "macros/Sources/RAND_f.sci" */
function RAND_f() {
    RAND_f.prototype.define = function RAND_f() {
        a = 0;
        b = 1;
        dt = 0;
        out = 1;
        flag = 0;
        model = scicos_model();
        model.sim = "rndblk";
        model.out = out;
        model.evtin = 1;
        model.dstate = [[int(rand()*(10^7-1))],[0*a.slice()]];
        model.rpar = [[a.slice()],[b.slice()]];
        model.ipar = flag;
        model.blocktype = "d";
        model.dep_ut = [false,false];
        exprs = [[string(flag)],[sci2exp(a.slice())],[sci2exp(b.slice())],[string(model.dstate[1-1])]];
        gr_i = [];
        this.x = standard_define([3,2],model,exprs,gr_i);
    }
    RAND_f.prototype.details = function RAND_f() {
        return this.x;
    }
    RAND_f.prototype.get = function RAND_f() {
    }
    RAND_f.prototype.set = function RAND_f() {
        this.x = arg1;
        graphics = arg1.graphics;
        exprs = graphics.exprs;
        model = arg1.model;
        if (size(exprs,"*")==5) {
            exprs = exprs.slice(1-1,3);
        }
        if (size(exprs,"*")==3) {
            exprs = [[exprs],[string(model.dstate[1-1])]];
        }
        while (true) {
            [ok,flag,a,b,seed_c,exprs] = scicos_getvalue([["Set Random generator block parameters"],["flag = 0 : Uniform distribution A is min and A+B max"],["flag = 1 : Normal distribution A is mean and B deviation"],[" "],["A and B must be vector with equal sizes"],["seed is the seed of random number generator (integer<2**31)"]],[["flag"],["A"],["B"],["seed"]],list("vec",1,"vec",-1,"vec","size(%2,\'*\')","vec",1),exprs);
            if (!ok) {
                break;
            }
            if (flag!=0&&flag!=1) {
                message("flag must be equal to 1 or 0");
            } else {
                nout = size(a,"*");
                graphics.exprs = exprs;
                model.out = nout;
                model.ipar = flag;
                model.rpar = [[a.slice()],[b.slice()]];
                model.dstate = [[seed_c],[0*a.slice()]];
                this.x.graphics = graphics;
                this.x.model = model;
                break;
            }
        }
    }
}