Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mathjslab

Package Overview
Dependencies
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mathjslab - npm Package Compare versions

Comparing version 1.1.22 to 1.1.23

3

CHANGES.md

@@ -5,2 +5,5 @@ # Release notes

## 1.1.23
- Logical indexing.
## 1.1.22

@@ -7,0 +10,0 @@ - Fix `end` in ranges. The `colon_item` parser rule has been removed and the `end` descriptor in ranges has been created in the `primary_expr` rule.

@@ -229,3 +229,5 @@ /**

readonly getItems: typeof MultiArray.getItems;
readonly getItemsLogical: typeof MultiArray.getItemsLogical;
readonly setItems: typeof MultiArray.setItems;
readonly setItemsLogical: typeof MultiArray.setItemsLogical;
readonly expandRange: typeof MultiArray.expandRange;

@@ -232,0 +234,0 @@ readonly firstRow: typeof MultiArray.firstRow;

@@ -252,2 +252,3 @@ import { ComplexDecimal } from './complex-decimal';

static setItems(nameTable: TNameTable, id: string, args: any[], right: MultiArray): void;
static setItemsLogical(nameTable: TNameTable, id: string, arg: ComplexDecimal[], right: MultiArray): void;
/**

@@ -261,2 +262,3 @@ * Get selected items from MultiArray by linear indices or subscripts.

static getItems(M: MultiArray, id: string, indexList: (ComplexDecimal | MultiArray)[]): MultiArray | ComplexDecimal;
static getItemsLogical(M: MultiArray, id: string, items: MultiArray): MultiArray;
/**

@@ -263,0 +265,0 @@ * Matrix product.

10

package.json
{
"name": "mathjslab",
"version": "1.1.22",
"version": "1.1.23",
"description": "MathJSLab - An interpreter with language syntax like MATLAB®/Octave. ISBN 978-65-00-82338-7",

@@ -58,7 +58,7 @@ "main": "lib/mathjslab.js",

"devDependencies": {
"@types/debug": "^4.1.11",
"@types/jest": "29.5.7",
"@types/node": "^20.8.10",
"@types/debug": "^4.1.12",
"@types/jest": "29.5.8",
"@types/node": "^20.9.0",
"@types/supertest": "^2.0.16",
"@types/webpack": "^5.28.4",
"@types/webpack": "^5.28.5",
"@typescript-eslint/eslint-plugin": "^6.10.0",

@@ -65,0 +65,0 @@ "eslint": "^8.53.0",

@@ -353,3 +353,5 @@ /**

public readonly getItems = MultiArray.getItems;
public readonly getItemsLogical = MultiArray.getItemsLogical;
public readonly setItems = MultiArray.setItems;
public readonly setItemsLogical = MultiArray.setItemsLogical;
public readonly expandRange = MultiArray.expandRange;

@@ -742,2 +744,3 @@ public readonly firstRow = MultiArray.firstRow;

}
/**

@@ -1024,22 +1027,26 @@ * Validate left hand side of assignment node.

/* Indexed matrix reference on left hand side with operator. */
this.setItems(
this.nameTable,
id,
args.map((arg: any) => this.linearize(this.reduceIfReturnList(this.Evaluator(arg)))),
this.toTensor(
this.reduceIfReturnList(
this.Evaluator(
this.nodeOp(
op,
this.getItems(this.nameTable[id].expr, id, args),
this.toTensor(this.reduceIfReturnList(this.Evaluator(right.selector(assignment.length, n)))),
if (tree.args.length === 1) {
/* Test logical indexing. */
} else {
this.setItems(
this.nameTable,
id,
args.map((arg: any) => this.linearize(this.reduceIfReturnList(this.Evaluator(arg)))),
this.toTensor(
this.reduceIfReturnList(
this.Evaluator(
this.nodeOp(
op,
this.getItems(this.nameTable[id].expr, id, args),
this.toTensor(this.reduceIfReturnList(this.Evaluator(right.selector(assignment.length, n)))),
),
false,
fname,
),
false,
fname,
),
),
),
);
this.nodeList(resultList, this.nodeOp('=', this.nodeName(id), this.nameTable[id].expr));
continue;
);
this.nodeList(resultList, this.nodeOp('=', this.nodeName(id), this.nameTable[id].expr));
continue;
}
} else {

@@ -1069,8 +1076,30 @@ throw new EvalError(`in computed assignment ${id}(index) OP= X, ${id} cannot be a function.`);

/* Indexed matrix reference on left hand side. */
this.setItems(
this.nameTable,
id,
args.map((arg: any, i: number) => this.linearize(this.reduceIfReturnList(this.Evaluator(arg)))),
this.toTensor(this.reduceIfReturnList(this.Evaluator(right.selector(assignment.length, n)))),
);
if (args.length === 1) {
/* Test logical indexing. */
const arg0 = this.reduceIfReturnList(this.Evaluator(args[0], local, fname));
if (this.isTensor(arg0) && arg0.type === ComplexDecimal.numberClass.logical) {
/* Logical indexing. */
this.setItemsLogical(
this.nameTable,
id,
this.linearize(arg0),
this.toTensor(this.reduceIfReturnList(this.Evaluator(right.selector(assignment.length, n)))),
);
} else {
/* Not logical indexing. */
this.setItems(
this.nameTable,
id,
[this.linearize(arg0)],
this.toTensor(this.reduceIfReturnList(this.Evaluator(right.selector(assignment.length, n)))),
);
}
} else {
this.setItems(
this.nameTable,
id,
args.map((arg: any, i: number) => this.linearize(this.reduceIfReturnList(this.Evaluator(arg)))),
this.toTensor(this.reduceIfReturnList(this.Evaluator(right.selector(assignment.length, n)))),
);
}
this.nodeList(resultList, this.nodeOp('=', this.nodeName(id), this.nameTable[id].expr));

@@ -1235,11 +1264,24 @@ continue;

/* Defined indexed matrix reference. */
const result = this.getItems(
temp,
tree.expr.id,
tree.args.map((arg: any, i: number) => {
arg.parent = tree;
arg.index = i;
return this.reduceIfReturnList(this.Evaluator(arg, local, fname));
}),
);
let result: ComplexDecimal | MultiArray;
if (tree.args.length === 1) {
/* Test logical indexing. */
const arg0 = this.reduceIfReturnList(this.Evaluator(tree.args[0], local, fname));
if (this.isTensor(arg0) && arg0.type === ComplexDecimal.numberClass.logical) {
/* Logical indexing. */
result = this.getItemsLogical(temp, tree.expr.id, arg0);
} else {
/* Not logical indexing. */
result = this.getItems(temp, tree.expr.id, [arg0]);
}
} else {
result = this.getItems(
temp,
tree.expr.id,
tree.args.map((arg: any, i: number) => {
arg.parent = tree;
arg.index = i;
return this.reduceIfReturnList(this.Evaluator(arg, local, fname));
}),
);
}
result.parent = tree;

@@ -1246,0 +1288,0 @@ return result;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc