Skip to content

Commit efe15f9

Browse files
authored
Merge branch 'develop' into faster-map-mulitple
2 parents 204db13 + cd6b4ba commit efe15f9

File tree

8 files changed

+50
-23
lines changed

8 files changed

+50
-23
lines changed

HISTORY.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
# History
22

3-
# unpublished changes since 14.8.0
3+
# unpublished changes since 14.8.1
4+
5+
- Fix: improve performance in functions like `map` when passing a unary
6+
function (#3546). Thanks @dvd101x.
7+
- Fix: improve the type definition of `abs(complex)` which returns a `number`
8+
(#3543). Thanks @joshkel.
9+
- Fix: add missing type definitions for `ctranspose` (#3545). Thanks @joshkel.
10+
- Fix: typos in code comments (#3544). Thanks @joshkel.
11+
12+
# 2025-09-26, 14.8.1
413

514
- Fix: #3538 `config` printing a warning when using `{ number: 'bigint' }`
615
(#3540).

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mathjs",
3-
"version": "14.8.0",
3+
"version": "14.8.1",
44
"description": "Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with different data types like numbers, big numbers, complex numbers, fractions, units, and matrices.",
55
"author": "Jos de Jong <wjosdejong@gmail.com> (https://github.com/josdejong)",
66
"homepage": "https://mathjs.org",

src/utils/optimizeCallback.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import { typeOf as _typeOf } from './is.js'
88
* @param {Function} callback The original callback function to simplify.
99
* @param {Array|Matrix} array The array that will be used with the callback function.
1010
* @param {string} name The name of the function that is using the callback.
11-
* @param {boolean} [isUnary=false] If true, the callback function is unary and will be optimized as such.
11+
* @param {boolean} isUnary If true, the callback function is unary and will be optimized as such.
1212
* @returns {Function} Returns a simplified version of the callback function.
1313
*/
14-
export function optimizeCallback (callback, array, name, isUnary = false) {
14+
export function optimizeCallback (callback, array, name, isUnary) {
1515
if (typed.isTypedFunction(callback)) {
1616
let numberOfArguments
1717
if (isUnary) {

src/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export const version = '14.8.0'
1+
export const version = '14.8.1'
22
// Note: This file is automatically generated when building math.js.
33
// Changes made in this file will be overwritten.

test/typescript-tests/testTypes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ Chaining examples
615615
MathJsChain<Fraction>
616616
>()
617617
expectTypeOf(math.chain(math.complex(1, 2)).abs()).toMatchTypeOf<
618-
MathJsChain<Complex>
618+
MathJsChain<number>
619619
>()
620620
expectTypeOf(math.chain([1, 2]).abs()).toMatchTypeOf<MathJsChain<MathArray>>()
621621
expectTypeOf(

test/unit-tests/function/matrix/ctranspose.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('ctranspose', function () {
1818
assert.deepStrictEqual(ctranspose(math.matrix([1, 2, 3]).toArray()), [1, 2, 3])
1919
})
2020

21-
it('should conjgate a complex vector', function () {
21+
it('should conjugate a complex vector', function () {
2222
const a = math.complex(1, 2)
2323
const b = math.complex(3, 4)
2424
const c = math.complex(5, 6)

types/index.d.ts

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ export interface MathJsInstance extends MathJsFactory {
10931093
* decomposition.
10941094
* @param order The Symbolic Ordering and Analysis order: 0 - Natural
10951095
* ordering, no permutation vector q is returned 1 - Matrix must be
1096-
* square, symbolic ordering and analisis is performed on M = A + A' 2 -
1096+
* square, symbolic ordering and analysis is performed on M = A + A' 2 -
10971097
* Symbolic ordering and analysis is performed on M = A' * A. Dense
10981098
* columns from A' are dropped, A recreated from A'. This is appropriate
10991099
* for LU factorization of non-symmetric matrices. 3 - Symbolic ordering
@@ -1126,6 +1126,7 @@ export interface MathJsInstance extends MathJsFactory {
11261126
* @param x A number or matrix for which to get the absolute value
11271127
* @returns Absolute value of x
11281128
*/
1129+
abs(x: Complex): number
11291130
abs<T extends MathType>(x: T): T
11301131

11311132
/**
@@ -1328,7 +1329,7 @@ export interface MathJsInstance extends MathJsFactory {
13281329
* @param args A list with numeric values or an Array or Matrix. Matrix
13291330
* and Array input is flattened and returns a single number for the
13301331
* whole matrix.
1331-
* @returns Returns the hypothenuse of the input values.
1332+
* @returns Returns the hypotenuse of the input values.
13321333
*/
13331334
hypot<T extends number | BigNumber>(...args: T[]): T
13341335
hypot<T extends number | BigNumber>(args: T[]): T
@@ -1546,7 +1547,7 @@ export interface MathJsInstance extends MathJsFactory {
15461547
* strings will be converted to a number. For complex numbers, both real
15471548
* and complex value are inverted.
15481549
* @param x Number to be inverted
1549-
* @returns Retursn the value with inverted sign
1550+
* @returns Returns the value with inverted sign
15501551
*/
15511552
unaryMinus<T extends MathType>(x: T): T
15521553

@@ -1757,7 +1758,7 @@ export interface MathJsInstance extends MathJsFactory {
17571758
************************************************************************/
17581759

17591760
/**
1760-
* Calculates: The eucledian distance between two points in 2 and 3
1761+
* Calculates: The Euclidean distance between two points in 2 and 3
17611762
* dimensional spaces. Distance between point and a line in 2 and 3
17621763
* dimensional spaces. Pairwise distance between a set of 2D or 3D
17631764
* points NOTE: When substituting coefficients of a line(a, b and c),
@@ -1897,6 +1898,14 @@ export interface MathJsInstance extends MathJsFactory {
18971898
*/
18981899
cross(x: MathCollection, y: MathCollection): MathCollection
18991900

1901+
/**
1902+
* Transpose and complex conjugate a matrix. All values of the matrix are
1903+
* reflected over its main diagonal and then the complex conjugate is taken.
1904+
* This is equivalent to complex conjugation for scalars and vectors.
1905+
* @param x Matrix to be ctransposed
1906+
*/
1907+
ctranspose(x: MathCollection): MathCollection
1908+
19001909
/**
19011910
* Calculate the determinant of a matrix.
19021911
* @param x A Matrix
@@ -2081,7 +2090,7 @@ export interface MathJsInstance extends MathJsFactory {
20812090

20822091
/**
20832092
* Calculate the inverse of a square matrix.
2084-
* @param x Matrix to be inversed
2093+
* @param x Matrix to be inverted
20852094
* @returns The inverse of x
20862095
*/
20872096
inv<T extends number | Complex | MathCollection>(x: T): NoLiteralType<T>
@@ -2190,7 +2199,7 @@ export interface MathJsInstance extends MathJsFactory {
21902199

21912200
/**
21922201
* Calculate the Moore–Penrose inverse of a matrix.
2193-
* @param x Matrix to be inversed
2202+
* @param x Matrix to be inverted
21942203
* @return The inverse of `x`.
21952204
*/
21962205
pinv<T extends MathType>(x: T): T
@@ -2457,7 +2466,7 @@ export interface MathJsInstance extends MathJsFactory {
24572466
* distributions
24582467
* @param q First vector
24592468
* @param p Second vector
2460-
* @returns Returns disance between q and p
2469+
* @returns Returns distance between q and p
24612470
*/
24622471
kldivergence(q: MathCollection, p: MathCollection): number
24632472

@@ -2474,7 +2483,7 @@ export interface MathJsInstance extends MathJsFactory {
24742483
* takes one array of integers as an argument. The following condition
24752484
* must be enforced: every ai <= 0
24762485
* @param a Integer number of objects in the subset
2477-
* @returns multinomial coefficent
2486+
* @returns multinomial coefficient
24782487
*/
24792488
multinomial<T extends number | BigNumber>(a: T[]): NoLiteralType<T>
24802489

@@ -2579,7 +2588,7 @@ export interface MathJsInstance extends MathJsFactory {
25792588
* Test element wise whether two matrices are equal. The function
25802589
* accepts both matrices and scalar values.
25812590
* @param x First matrix to compare
2582-
* @param y Second amtrix to compare
2591+
* @param y Second matrix to compare
25832592
* @returns Returns true when the input matrices have the same size and
25842593
* each of their elements is equal.
25852594
*/
@@ -2621,7 +2630,7 @@ export interface MathJsInstance extends MathJsFactory {
26212630
* compare values smaller than approximately 2.22e-16. For matrices, the
26222631
* function is evaluated element wise.
26232632
* @param x First value to compare
2624-
* @param y Second value to vcompare
2633+
* @param y Second value to compare
26252634
* @returns Returns true when x is larger than y, else returns false
26262635
*/
26272636
larger(x: MathType | string, y: MathType | string): boolean | MathCollection
@@ -2633,7 +2642,7 @@ export interface MathJsInstance extends MathJsFactory {
26332642
* to compare values smaller than approximately 2.22e-16. For matrices,
26342643
* the function is evaluated element wise.
26352644
* @param x First value to compare
2636-
* @param y Second value to vcompare
2645+
* @param y Second value to compare
26372646
* @returns Returns true when x is larger than or equal to y, else
26382647
* returns false
26392648
*/
@@ -2646,7 +2655,7 @@ export interface MathJsInstance extends MathJsFactory {
26462655
* to compare values smaller than approximately 2.22e-16. For matrices,
26472656
* the function is evaluated element wise.
26482657
* @param x First value to compare
2649-
* @param y Second value to vcompare
2658+
* @param y Second value to compare
26502659
* @returns Returns true when x is smaller than y, else returns false
26512660
*/
26522661
smaller(x: MathType | string, y: MathType | string): boolean | MathCollection
@@ -2658,7 +2667,7 @@ export interface MathJsInstance extends MathJsFactory {
26582667
* used to compare values smaller than approximately 2.22e-16. For
26592668
* matrices, the function is evaluated element wise.
26602669
* @param x First value to compare
2661-
* @param y Second value to vcompare
2670+
* @param y Second value to compare
26622671
* @returns Returns true when x is smaller than or equal to y, else
26632672
* returns false
26642673
*/
@@ -2692,7 +2701,7 @@ export interface MathJsInstance extends MathJsFactory {
26922701
* strictly, thus null is unequal with everything except null, and
26932702
* undefined is unequal with everything except undefined.
26942703
* @param x First value to compare
2695-
* @param y Second value to vcompare
2704+
* @param y Second value to compare
26962705
* @returns Returns true when the compared values are unequal, else
26972706
* returns false
26982707
*/
@@ -5076,6 +5085,7 @@ export interface MathJsChain<TValue> {
50765085
* Calculate the absolute value of a number. For matrices, the function
50775086
* is evaluated element wise.
50785087
*/
5088+
abs(this: MathJsChain<Complex>): MathJsChain<number>
50795089
abs<T extends MathType>(this: MathJsChain<T>): MathJsChain<T>
50805090

50815091
/**
@@ -5814,6 +5824,13 @@ export interface MathJsChain<TValue> {
58145824
y: MathCollection
58155825
): MathJsChain<MathCollection>
58165826

5827+
/**
5828+
* Transpose and complex conjugate a matrix. All values of the matrix are
5829+
* reflected over its main diagonal and then the complex conjugate is taken.
5830+
* This is equivalent to complex conjugation for scalars and vectors.
5831+
*/
5832+
ctranspose(this: MathJsChain<MathCollection>): MathJsChain<MathCollection>
5833+
58175834
/**
58185835
* Calculate the difference between adjacent elements of the chained matrix or array.
58195836
* @param dim The dimension to apply the difference on.
@@ -7300,6 +7317,7 @@ export const {
73007317
apply, // @deprecated prior name of mapSlices
73017318
concat,
73027319
cross,
7320+
ctranspose,
73037321
det,
73047322
diag,
73057323
dot,

0 commit comments

Comments
 (0)