diff options
author | Adhitya Kamakshidasan | 2016-07-06 15:03:56 +0530 |
---|---|---|
committer | GitHub | 2016-07-06 15:03:56 +0530 |
commit | e150f2e19fe961f798b9da7184e054dcccfae7fa (patch) | |
tree | 48b56551ab5373266d0f0d99d4047f2a58832d45 | |
parent | 7176ab5e22017026afc6927b0edea21df3fa0931 (diff) | |
parent | b65a9a7a3babfe0935656ac3cd881a5105c82d60 (diff) | |
download | xcos-on-web-e150f2e19fe961f798b9da7184e054dcccfae7fa.tar.gz xcos-on-web-e150f2e19fe961f798b9da7184e054dcccfae7fa.tar.bz2 xcos-on-web-e150f2e19fe961f798b9da7184e054dcccfae7fa.zip |
Merge pull request #140 from Chhavi2208/master
Updated dependencies
-rw-r--r-- | data_structures_correct/DLRADAPT_f.js | 32 | ||||
-rw-r--r-- | dependencies.js | 44 | ||||
-rw-r--r-- | details.js | 23 |
3 files changed, 87 insertions, 12 deletions
diff --git a/data_structures_correct/DLRADAPT_f.js b/data_structures_correct/DLRADAPT_f.js new file mode 100644 index 0000000..8b68940 --- /dev/null +++ b/data_structures_correct/DLRADAPT_f.js @@ -0,0 +1,32 @@ +function DLRADAPT_f() { + + DLRADAPT_f.prototype.define = function DLRADAPT_f() { + this.p = [[0], [1]]; + this.rn = []; + this.rd = [[math.complex(0.2, 0.8), math.complex(0.2, -0.8)], [math.complex(0.3, 0.7), math.complex(0.3, -0.7)]]; + this.g = [[1], [1]]; + this.last_u = []; + this.last_y = [[0], [0]]; + + var model = scicos_model(); + model.sim = new ScilabString(["dlradp"]); + model.in = new ScilabDouble([1], [1]); + model.out = new ScilabDouble([1]); + model.evtin = new ScilabDouble([1]); + model.dstate = new ScilabDouble(...this.last_y); + model.rpar = new ScilabDouble(...this.p, ...real(colon_operator(this.rd)), ...math.im(colon_operator(this.rd)), ...this.g); + model.ipar = new ScilabDouble([0], [2], [2]); + model.blocktype = new ScilabString(["d"]); + model.firing = new ScilabDouble(); + model.dep_ut = new ScilabBoolean([true, false]); + + var exprs = new ScilabString([sci2exp(this.p)], [sci2exp(this.rn)], [sci2exp(this.rd, 0)], [sci2exp(this.g)], [sci2exp(this.last_u)], [sci2exp(this.last_y)]); + + var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"DLRADAPT_f\",sz(1),sz(2));"]); + this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); + return new BasicBlock(this.x); + } + DLRADAPT_f.prototype.details = function DLRADAPT_f() { + return this.x; + } +} diff --git a/dependencies.js b/dependencies.js index c34bf4e..dd2a087 100644 --- a/dependencies.js +++ b/dependencies.js @@ -841,3 +841,47 @@ function _str2code() { } return code; } + +function real() { + var matrix = arguments[0]; + var sz = math.size(matrix); + var res = []; + for (var i = 0; i < sz[0]; i++) { + for (var j = 0; j < sz[1]; j++) { + res.push([math.re(matrix[i][j])]); + } + } + return res; +} + +function imag() { + var matrix = arguments[0]; + var sz = math.size(matrix); + var res = []; + for (var i = 0; i < sz[0]; i++) { + for (var j = 0; j < sz[1]; j++) { + res.push([math.im(matrix[i][j])]); + } + } + return res; +} + +function _check() { + var param = arguments[0]; + if(typeof param == "object") { + var str = param.toString(); + str = str.substring(1, str.length - 1); + str = str.replace(/\B\+/,"+%i*"); + str = str.replace(/\B-/,"-%i*"); + str = param.toString().substring(0,1) + str; + str = str.replace(/ /g,''); + return str; + } + else if(typeof param == "string") { + // needs to be changed later + return param; + } + else { + return param; + } +} @@ -549,31 +549,30 @@ function BasicBlock() { } function sci2exp(c) { - if(c.scilabClass == "ScilabList") { + if (c.scilabClass == "ScilabList") { c = Object.create(c); c.scilabClass = ""; - if(c.length) { + if (c.length) { return "list(" + sci2exp(c) + ")"; - } - else { + } else { return "list()"; } - } - else if(typeof c.length === "undefined") { + } else if (typeof c.length === "undefined") { return c.toString(); - } - else if (c.length == 0) { + } else if (c.length == 0) { return "[]"; - } - else if (c.length == 1) + } else if (c.length == 1) return c.toString(); else { var result = "["; for (var i = 0; i < c.length; i++) { if (typeof c[i].length === 'undefined') { - result += c[i] + ","; + result += _check(c[i]) + ","; } else { - result += c[i][0] + ";"; + for (var j = 0; j < c[i].length - 1; j++) { + result += _check(c[i][j]) + ","; + } + result += _check(c[i][c[i].length - 1]) + ";"; } } result = result.substring(0, result.length - 1); |