Skip to content

Commit

Permalink
fix: #3259 function symbolicEqual missing in the TypeScript definit…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
josdejong committed Sep 4, 2024
1 parent 6b743d0 commit 4d91f10
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Fix: improve the type definitions of `ConstantNode` to support all data
types (#3257). Thanks @smith120bh.
- Fix: #3259 function `symbolicEqual` missing in the TypeScript definitions.
- Docs: fix broken links on the Configuration page. Thanks @vassudanagunta.

# 2024-08-27, 13.1.1
Expand Down
16 changes: 16 additions & 0 deletions test/typescript-tests/testTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,22 @@ Chaining examples
MathJsChain<MathNode>
>()

// symbolicEqual
assert.strictEqual(
math.symbolicEqual(math.parse('x*y'), math.parse('y*x')),
true
)
assert.strictEqual(
math.symbolicEqual(math.parse('x*y'), math.parse('y*x'), {
exactFractions: true
}),
true
)
assert.strictEqual(
math.chain(math.parse('x*y')).symbolicEqual(math.parse('y*x')).done(),
true
)

// slu
expectTypeOf(
math
Expand Down
18 changes: 18 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,15 @@ export interface MathJsInstance extends MathJsFactory {
simplifyConstant(expr: MathNode | string, options?: SimplifyOptions): MathNode
simplifyCore(expr: MathNode | string, options?: SimplifyOptions): MathNode

/**
* Attempts to determine if two expressions are symbolically equal.
*/
symbolicEqual(
expr1: MathNode,
expr2: MathNode,
options?: SimplifyOptions
): boolean

/**
* Replaces variable nodes with their scoped values
* @param node Tree to replace variable nodes in
Expand Down Expand Up @@ -4888,6 +4897,15 @@ export interface MathJsChain<TValue> {
options?: SimplifyOptions
): MathJsChain<MathNode>

/**
* Attempts to determine if two expressions are symbolically equal.
*/
symbolicEqual(
this: MathJsChain<MathNode>,
expr2: MathNode,
options?: SimplifyOptions
): MathJsChain<boolean>

/**
* Calculate the Sparse Matrix LU decomposition with full pivoting.
* Sparse Matrix A is decomposed in two matrices (L, U) and two
Expand Down

0 comments on commit 4d91f10

Please sign in to comment.