-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
67 changed files
with
8,988 additions
and
1,452 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[include] | ||
./*.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var MxVector_1 = require("./mxarray/MxVector"); | ||
exports.MxVector = MxVector_1.MxVector; | ||
var MxNdArray_1 = require("./mxarray/MxNdArray"); | ||
exports.MxNDArray = MxNdArray_1.MxNDArray; | ||
// declare var wi:any; | ||
var MatlabRuntime = /** @class */ (function () { | ||
function MatlabRuntime(wis) { | ||
this.started = false; | ||
this.wi = wis; | ||
this.started = true; | ||
} | ||
MatlabRuntime.prototype.startRuntime = function (wis) { | ||
this.wi = wis; | ||
this.started = true; | ||
}; | ||
MatlabRuntime.prototype.checkForStartedRuntime = function () { | ||
if (!this.started) { | ||
throw new Error("Please initialize Matlab Runtime"); | ||
} | ||
}; | ||
MatlabRuntime.prototype.isRuntimeStarted = function () { | ||
return this.started; | ||
}; | ||
MatlabRuntime.prototype.horzcat = function (args) { | ||
return this.concat(2, args); | ||
}; | ||
MatlabRuntime.prototype.vertcat = function (args) { | ||
return this.concat(1, args); | ||
}; | ||
MatlabRuntime.prototype.concat = function (dim, args) { | ||
var _this = this; | ||
this.checkForStartedRuntime(); | ||
var input_vec = this.wi.create_mxvector(args.length, 5); | ||
args.forEach(function (arr, idx) { | ||
_this.wi.set_array_index_i32(input_vec, idx + 1, arr.arr_ptr); | ||
}); | ||
return new MxNdArray_1.MxNDArray(this.wi, this.wi.concat(dim, input_vec)); | ||
}; | ||
MatlabRuntime.prototype.reshape = function (arr, dims) { | ||
return arr.reshape(dims); | ||
}; | ||
MatlabRuntime.prototype.colon = function (start, stepEnd, end) { | ||
this.checkForStartedRuntime(); | ||
var input_vec; | ||
if (typeof end == "undefined") { | ||
var dim_1 = this.wi.create_mxvector(1); | ||
var dim_2 = this.wi.create_mxvector(1); | ||
input_vec = this.wi.create_mxvector(2, 5); | ||
this.wi.set_array_index_f64(dim_1, 1, start); | ||
this.wi.set_array_index_f64(dim_2, 1, stepEnd); | ||
this.wi.set_array_index_i32(input_vec, 1, dim_1); | ||
this.wi.set_array_index_i32(input_vec, 2, dim_2); | ||
} | ||
else { | ||
var dim_1 = this.wi.create_mxvector(1); | ||
var dim_2 = this.wi.create_mxvector(1); | ||
var dim_3 = this.wi.create_mxvector(1); | ||
input_vec = this.wi.create_mxvector(3, 5); | ||
var param_arr = this.wi.create_mxvector(3, 5); | ||
this.wi.set_array_index_f64(dim_1, 1, start); | ||
this.wi.set_array_index_f64(dim_2, 1, stepEnd); | ||
this.wi.set_array_index_f64(dim_3, 1, end); | ||
this.wi.set_array_index_i32(input_vec, 1, dim_1); | ||
this.wi.set_array_index_i32(input_vec, 2, dim_2); | ||
this.wi.set_array_index_i32(input_vec, 3, dim_3); | ||
} | ||
return new MxNdArray_1.MxNDArray(this.wi, this.wi.colon(input_vec)); | ||
}; | ||
MatlabRuntime.prototype.size = function (arr) { | ||
this.checkForStartedRuntime(); | ||
return arr.size(); | ||
}; | ||
MatlabRuntime.prototype.numel = function (arr) { | ||
this.checkForStartedRuntime(); | ||
return arr.numel(); | ||
}; | ||
MatlabRuntime.prototype.length = function (arr) { | ||
this.checkForStartedRuntime(); | ||
return arr.length(); | ||
}; | ||
MatlabRuntime.prototype.isrow = function (arr) { | ||
this.checkForStartedRuntime(); | ||
return arr.isrow(); | ||
}; | ||
MatlabRuntime.prototype.iscolumn = function (arr) { | ||
this.checkForStartedRuntime(); | ||
return arr.iscolumn(); | ||
}; | ||
MatlabRuntime.prototype.ismatrix = function (arr) { | ||
this.checkForStartedRuntime(); | ||
return arr.ismatrix(); | ||
}; | ||
MatlabRuntime.prototype.isvector = function (arr) { | ||
this.checkForStartedRuntime(); | ||
return arr.isvector(); | ||
}; | ||
MatlabRuntime.prototype.isempty = function (arr) { | ||
this.checkForStartedRuntime(); | ||
return arr.isempty(); | ||
}; | ||
MatlabRuntime.prototype.clone = function (arr) { | ||
this.checkForStartedRuntime(); | ||
return arr.clone(); | ||
}; | ||
return MatlabRuntime; | ||
}()); | ||
exports.MatlabRuntime = MatlabRuntime; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,80 @@ | ||
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class MxArray { | ||
getContents() { | ||
return new Float64Array(this.wi.mem, this.arr_ptr, this.numel()); | ||
var MxObject_1 = require("./MxObject"); | ||
var MxArray = /** @class */ (function (_super) { | ||
__extends(MxArray, _super); | ||
function MxArray() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
set_index(ind, val) { | ||
return this.wi.set_array_index_f64(this.arr_ptr, ind, val); | ||
} | ||
get_index(ind) { | ||
return this.wi.get_array_index_f64(this.arr_ptr, ind); | ||
} | ||
numel() { | ||
return this.wi.numel(this.arr_ptr); | ||
} | ||
ndims() { | ||
return this.wi.ndims(this.arr_ptr); | ||
} | ||
length() { | ||
return this.wi.length(this.arr_ptr); | ||
} | ||
isrow() { | ||
return this.wi.isrow(this.arr_ptr) === 1; | ||
} | ||
iscolumn() { | ||
return this.wi.isvector(this.arr_ptr) === 1; | ||
} | ||
ismatrix() { | ||
return this.wi.ismatrix(this.arr_ptr) === 1; | ||
} | ||
isvector() { | ||
return this.wi.isvector(this.arr_ptr) === 1; | ||
} | ||
isempty() { | ||
return this.wi.isempty(this.arr_ptr) === 1; | ||
} | ||
} | ||
MxArray.prototype.set_index = function (ind, val) { | ||
if (ind === void 0) { ind = -1; } | ||
if (val === void 0) { val = NaN; } | ||
return this._wi.set_array_index_f64(this._arr_ptr, ind, val); | ||
}; | ||
MxArray.prototype.get_index = function (ind) { | ||
if (ind === void 0) { ind = -1; } | ||
return this._wi.get_array_index_f64(this._arr_ptr, ind); | ||
}; | ||
MxArray.prototype.get_indices = function (indices) { | ||
var _this = this; | ||
var indices_arr_ptr = this._wi.create_mxvector(indices.length, 5); // Create mxvector with int type | ||
indices.forEach(function (dimArr, indDim) { | ||
var index_arr_ptr = _this._wi.create_mxvector(dimArr.length); | ||
dimArr.forEach(function (val, indVal) { | ||
_this._wi.set_array_index_f64(index_arr_ptr, indVal + 1, val); | ||
}); | ||
_this._wi.set_array_index_i32(indices_arr_ptr, indDim + 1, index_arr_ptr); | ||
}); | ||
return this._wi.get_f64(this._arr_ptr, indices_arr_ptr); | ||
}; | ||
MxArray.prototype.get = function (indices) { | ||
if (typeof indices === 'number') { | ||
return this._wi.get_array_index_f64(this._arr_ptr, indices); | ||
} | ||
else if (indices.length === 1 && indices[0].length == 1) { | ||
return this._wi.get_array_index_f64(this._arr_ptr, indices[0][0]); | ||
} | ||
else { | ||
return this.get_indices(indices); | ||
} | ||
}; | ||
MxArray.prototype.set = function (indices, values) { | ||
if (indices.length == 0 && values.length == 0) { | ||
return this._wi.clone(this._arr_ptr); | ||
} | ||
else if (indices.length === 1 && indices[0].length == 1 && values.length == 1) { | ||
this._wi.set_array_index_f64(this._arr_ptr, indices[0][0], values[0]); | ||
} | ||
else { | ||
this.set_indices(indices, values); | ||
} | ||
}; | ||
MxArray.prototype.set_indices = function (indices, values) { | ||
var _this = this; | ||
var indices_arr_ptr = this._wi.create_mxvector(indices.length, 5); // Create mxvector with int type | ||
indices.forEach(function (dimArr, indDim) { | ||
var index_arr_ptr = _this._wi.create_mxvector(dimArr.length); | ||
_this._wi.set_array_index_i32(indices_arr_ptr, indDim + 1, index_arr_ptr); | ||
dimArr.forEach(function (val, indVal) { | ||
_this._wi.set_array_index_f64(index_arr_ptr, indVal + 1, val); | ||
}); | ||
}); | ||
var indices_val_arr_ptr = this._wi.create_mxvector(values.length); | ||
values.forEach(function (val, ind) { | ||
_this._wi.set_array_index_f64(indices_val_arr_ptr, ind + 1, val); | ||
}); | ||
this._wi.set_f64(this._arr_ptr, indices_arr_ptr, indices_val_arr_ptr); | ||
}; | ||
return MxArray; | ||
}(MxObject_1.MxObject)); | ||
exports.MxArray = MxArray; | ||
//# sourceMappingURL=MxArray.js.map |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.