Comparing version 1.0.5 to 1.0.6
@@ -36,2 +36,6 @@ import { Decimal } from 'decimal.js'; | ||
static true(): ComplexDecimal; | ||
static toLogical(value: ComplexDecimal): ComplexDecimal; | ||
static and(left: ComplexDecimal, right: ComplexDecimal): ComplexDecimal; | ||
static or(left: ComplexDecimal, right: ComplexDecimal): ComplexDecimal; | ||
static not(right: ComplexDecimal): ComplexDecimal; | ||
static zero(): ComplexDecimal; | ||
@@ -38,0 +42,0 @@ static one(): ComplexDecimal; |
@@ -31,2 +31,3 @@ import { ComplexDecimal } from "./complex-decimal"; | ||
static clone(M: MultiArray): MultiArray; | ||
static toLogical(M: MultiArray): ComplexDecimal; | ||
static map(M: MultiArray, f: Function): MultiArray; | ||
@@ -33,0 +34,0 @@ static expandRange(startNode: ComplexDecimal, stopNode: ComplexDecimal, strideNode?: ComplexDecimal | null): MultiArray; |
@@ -33,2 +33,4 @@ export declare class Tensor { | ||
static ne(left: any, right: any): any; | ||
static and(left: any, right: any): any; | ||
static or(left: any, right: any): any; | ||
} |
{ | ||
"name": "mathjslab", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "MathJSLab - Interpreter with language syntax like MATLAB/Octave", | ||
@@ -14,2 +14,3 @@ "main": "dist/mathjslab.js", | ||
"Octave", | ||
"MathML", | ||
"interpreter", | ||
@@ -35,3 +36,2 @@ "parser", | ||
"update": "npx ncu -u", | ||
"tscbuild": "tsc -p tsconfig.build.json", | ||
"prebuild:parser": "rimraf src/parser.js", | ||
@@ -42,4 +42,3 @@ "build:parser": "jison src/parser.jison -o src/parser.js", | ||
"clean": "rimraf dist src/parser.js", | ||
"publish-mathlabjs": "npm publish --access public", | ||
"test:decimal": "ts-node-dev --respawn --transpile-only test/decimal-test.ts" | ||
"publish-mathjslab": "npm publish --access public" | ||
}, | ||
@@ -50,4 +49,3 @@ "dependencies": { | ||
"devDependencies": { | ||
"@types/decimal.js": "^7.4.0", | ||
"@types/node": "^20.5.0", | ||
"@types/node": "^20.5.1", | ||
"@types/webpack": "^5.28.1", | ||
@@ -58,4 +56,2 @@ "jison": "^0.4.18", | ||
"ts-node": "^10.9.1", | ||
"ts-node-dev": "^2.0.0", | ||
"tsconfig-paths": "^4.2.0", | ||
"typescript": "^5.1.6", | ||
@@ -62,0 +58,0 @@ "webpack": "^5.88.2", |
@@ -10,3 +10,3 @@ # MathJSLab | ||
It can run in browser environment and implements an arbitrary precision arithmetics using | ||
[decimal.js](https://www.npmjs.com/package/decimal.js) package. The package | ||
[decimal.js](https://www.npmjs.com/package/decimal.js) package. This package | ||
has functions to generate [MathML](https://www.w3.org/Math/) code of | ||
@@ -16,5 +16,9 @@ expressions parsed too. | ||
This software is intended for educational purposes to provide teachers and | ||
students with a CAD calculation tool that is capable of running in a browser | ||
environment. So it can be easily used on different devices. | ||
students with a computer aided calculation tool that is capable of running in | ||
a browser environment. So it can be easily adapted and used on different devices | ||
and environments. | ||
A functional [demo](https://mathjslab.netlify.app/) use of this package in a Web | ||
application can be found [here](https://github.com/sergiolindau/mathjslab-calculator). | ||
## Installation | ||
@@ -21,0 +25,0 @@ |
@@ -205,4 +205,4 @@ import { Decimal } from 'decimal.js'; | ||
return left_prec.re[cmp](right_prec.re) ? | ||
new ComplexDecimal(1, 0, 'logical') : | ||
new ComplexDecimal(0, 0, 'logical'); | ||
ComplexDecimal.true() : | ||
ComplexDecimal.false(); | ||
} | ||
@@ -213,9 +213,9 @@ let left_abs = ComplexDecimal.toMaxPrecisionDecimal(ComplexDecimal.abs(left).re); | ||
return left_abs[cmp](right_abs) ? | ||
new ComplexDecimal(1, 0, 'logical') : | ||
new ComplexDecimal(0, 0, 'logical'); | ||
ComplexDecimal.true() : | ||
ComplexDecimal.false(); | ||
} | ||
else { | ||
return ComplexDecimal.toMaxPrecisionDecimal(ComplexDecimal.arg(left).re)[cmp](ComplexDecimal.toMaxPrecisionDecimal(ComplexDecimal.arg(right).re)) ? | ||
new ComplexDecimal(1, 0, 'logical') : | ||
new ComplexDecimal(0, 0, 'logical'); | ||
ComplexDecimal.true() : | ||
ComplexDecimal.false(); | ||
} | ||
@@ -248,2 +248,32 @@ } | ||
static toLogical(value: ComplexDecimal): ComplexDecimal { | ||
let value_prec = ComplexDecimal.toMaxPrecision(value); | ||
return (!value_prec.re.eq(0) || !value_prec.im.eq(0)) ? | ||
ComplexDecimal.true() : | ||
ComplexDecimal.false(); | ||
} | ||
static and(left: ComplexDecimal, right: ComplexDecimal): ComplexDecimal { | ||
let left_prec = ComplexDecimal.toMaxPrecision(left); | ||
let right_prec = ComplexDecimal.toMaxPrecision(right); | ||
return ((!left_prec.re.eq(0) || !left_prec.im.eq(0)) && (!right_prec.re.eq(0) || !right_prec.im.eq(0))) ? | ||
ComplexDecimal.true() : | ||
ComplexDecimal.false(); | ||
} | ||
static or(left: ComplexDecimal, right: ComplexDecimal): ComplexDecimal { | ||
let left_prec = ComplexDecimal.toMaxPrecision(left); | ||
let right_prec = ComplexDecimal.toMaxPrecision(right); | ||
return ((!left_prec.re.eq(0) || !left_prec.im.eq(0)) || (!right_prec.re.eq(0) || !right_prec.im.eq(0))) ? | ||
ComplexDecimal.true() : | ||
ComplexDecimal.false(); | ||
} | ||
static not(right: ComplexDecimal): ComplexDecimal { | ||
let right_prec = ComplexDecimal.toMaxPrecision(right); | ||
return ((!right_prec.re.eq(0) || !right_prec.im.eq(0))) ? | ||
ComplexDecimal.false() : | ||
ComplexDecimal.true(); | ||
} | ||
static zero(): ComplexDecimal { | ||
@@ -250,0 +280,0 @@ return new ComplexDecimal(0, 0); |
@@ -157,2 +157,4 @@ /** | ||
'!=': Tensor.ne, | ||
'&&': Tensor.and, | ||
'||': Tensor.or, | ||
}; | ||
@@ -159,0 +161,0 @@ |
@@ -184,2 +184,14 @@ import Decimal from "decimal.js"; | ||
static toLogical(M: MultiArray): ComplexDecimal { | ||
for (var i = 0; i < M.dim[0]; i++) { | ||
for (var j = 0; j < M.dim[1]; j++) { | ||
const value = ComplexDecimal.toMaxPrecision(M.array[i][j]); | ||
if (value.re.eq(0) && value.im.eq(0)) { | ||
return ComplexDecimal.false(); | ||
} | ||
} | ||
} | ||
return ComplexDecimal.true(); | ||
} | ||
static map(M: MultiArray, f: Function): MultiArray { | ||
@@ -186,0 +198,0 @@ var result = new MultiArray(M.dim.slice()) |
@@ -177,2 +177,31 @@ import { ComplexDecimal } from './complex-decimal'; | ||
static and(left: any, right: any): any { | ||
if (('re' in left) && ('re' in right)) { | ||
return ComplexDecimal.and(left, right); | ||
} | ||
else if (('re' in left) && ('array' in right)) { | ||
return ComplexDecimal.and(left, MultiArray.toLogical(right)); | ||
} | ||
else if (('array' in left) && ('re' in right)) { | ||
return ComplexDecimal.and(MultiArray.toLogical(left), right); | ||
} | ||
else if (('array' in left) && ('array' in right)) { | ||
return ComplexDecimal.and(MultiArray.toLogical(left), MultiArray.toLogical(right)); | ||
} | ||
} | ||
static or(left: any, right: any): any { | ||
if (('re' in left) && ('re' in right)) { | ||
return ComplexDecimal.or(left, right); | ||
} | ||
else if (('re' in left) && ('array' in right)) { | ||
return ComplexDecimal.or(left, MultiArray.toLogical(right)); | ||
} | ||
else if (('array' in left) && ('re' in right)) { | ||
return ComplexDecimal.or(MultiArray.toLogical(left), right); | ||
} | ||
else if (('array' in left) && ('array' in right)) { | ||
return ComplexDecimal.or(MultiArray.toLogical(left), MultiArray.toLogical(right)); | ||
} | ||
} | ||
} |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
316098
9
3704
84
29