summaryrefslogtreecommitdiff
path: root/js/Linear/TCLSS_f.js
blob: 7be4b9721bbebfcb9fee4d11e57f16c2c9d862c4 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/* autogenerated from "macros/Linear/TCLSS_f.sci" */
function TCLSS_f() {
    TCLSS_f.prototype.define = function TCLSS_f() {
        this.x0 = 0;
        this.A = 0;
        this.B = 1;
        this.C = 1;
        this.D = 0;
        in1 = 1;
        nx = size(this.x0,"*");
        out = 1;
        this.model = scicos_model();
        this.model.sim = list(new ScilabString(["tcslti"]), new ScilabDouble([1]));
        this.model.in1 = [[in1],[nx]];
        this.model.out = new ScilabDouble([out]);
        this.model.evtin = new ScilabDouble([1]);
        this.model.state = new ScilabDouble([this.x0]);
        this.model.rpar = [[this.A.slice()],[this.B.slice()],[this.C.slice()],[this.D.slice()]];
        this.model.blocktype = new ScilabString(["c"]);
        this.model.dep_ut = [false,true];
        exprs = [[strcat(sci2exp(this.A))],[strcat(sci2exp(this.B))],[strcat(sci2exp(this.C))],[strcat(sci2exp(this.D))],[strcat(sci2exp(this.x0))]];
        gr_i = [];
        this.x = standard_define([3,2],this.model,exprs,gr_i);
        return new BasicBlock(this.x);
    }
    TCLSS_f.prototype.details = function TCLSS_f() {
        return this.x;
    }
    TCLSS_f.prototype.get = function TCLSS_f() {
        var options = {
            A:["A matrix",this.A],
            B:["B matrix",this.B],
            C:["C matrix",this.C],
            D:["D matrix",this.D],
            x0:["Initial state",this.x0],
        }
        return options;
    }
    TCLSS_f.prototype.set = function TCLSS_f() {
        this.A = parseFloat(arguments[0]["A"])
        this.B = parseFloat(arguments[0]["B"])
        this.C = parseFloat(arguments[0]["C"])
        this.D = parseFloat(arguments[0]["D"])
        this.x0 = parseFloat(arguments[0]["x0"])
        this.x = arg1;
        graphics = arg1.graphics;
        exprs = graphics.exprs;
        this.model = arg1.model;
        if (size(exprs,"*")==7) {
            exprs = exprs[[1:4,7]-1];
        }
        while (true) {
            [ok,this.A,this.B,this.C,this.D,this.x0,exprs] = scicos_getvalue("Set continuous linear system parameters",["A matrix","B matrix","C matrix","D matrix","Initial state"],list("mat",[-1,-1],"mat",["size(%1,2)","-1"],"mat",["-1","size(%1,2)"],"mat",[-1,-1],"vec","size(%1,2)"),exprs);
            if (!ok) {
                break;
            }
            out = size(this.C,1);
            if (out==0) {
                out = [];
            }
            in1 = size(this.B,2);
            if (in1==0) {
                in1 = [];
            }
            [ms,ns] = size(this.A);
            if (ms!=ns) {
                message("A matrix must be square");
            } else {
                [this.model,graphics,ok] = check_io(this.model,graphics,[[in1],[ms]],out,1,[]);
                if (ok) {
                    graphics.exprs = exprs;
                    rpar = [[this.A.slice()],[this.B.slice()],[this.C.slice()],[this.D.slice()]];
                    if (this.D!=[]) {
                        if (norm(this.D,1)!=0) {
                            mmm = [true,true];
                        } else {
                            mmm = [false,true];
                        }
                        if (or(this.model.dep_ut!=mmm)) {
                            this.model.dep_ut = mmm;
                        }
                    } else {
                        this.model.dep_ut = [false,true];
                    }
                    this.model.state = this.x0.slice();
                    this.model.rpar = rpar;
                    if (this.D!=[]) {
                        this.model.sim = list(new ScilabString(["tcslti"]), new ScilabDouble([1]));
                    } else {
                        this.model.sim = list(new ScilabString(["tcsltj"]), new ScilabDouble([1]));
                    }
                    this.x.graphics = graphics;
                    this.x.model = this.model;
                    break;
                }
            }
        }
        return new BasicBlock(this.x);
    }
}