Skip to content

Commit d749405

Browse files
committed
Add types
1 parent c99c48a commit d749405

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

types/index.d.ts

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2222,6 +2222,79 @@ export interface MathJsInstance extends MathJsFactory {
22222222
>
22232223
): T
22242224

2225+
/**
2226+
* Broadcast a matrix or array to a specified size.
2227+
*
2228+
* The input collection is conceptually expanded to match the given dimensions,
2229+
* following broadcasting rules. The returned object is a new matrix or array
2230+
* with the requested size; the original input is not modified.
2231+
*
2232+
* @param x The matrix or array to broadcast.
2233+
* @param size The target size for each dimension of the broadcasted result.
2234+
* @returns A matrix or array with the specified size, containing broadcasted values.
2235+
* @param x The matrix or array to broadcast.
2236+
* @param size The target size of the broadcasted output, specified as an array of dimension lengths.
2237+
* @returns A new matrix or array with the requested size, containing the broadcasted values of `x`.
2238+
*/
2239+
broadcastTo(
2240+
x: Matrix,
2241+
size: number[] | BigNumber[] | Matrix<number> | Matrix<BigNumber>
2242+
): Matrix
2243+
broadcastTo(
2244+
x: MathArray,
2245+
size: number[] | BigNumber[] | Matrix<number> | Matrix<BigNumber>
2246+
): MathArray
2247+
2248+
/**
2249+
* Calculate the broadcasted size of one or more matrices or arrays.
2250+
* Always returns an Array containing numbers.
2251+
*
2252+
* Syntax:
2253+
*
2254+
* math.broadcastSizes(x, y)
2255+
* math.broadcastSizes(x, y, ...)
2256+
*
2257+
* Examples:
2258+
*
2259+
* math.broadcastSizes([2, 3]) // returns [2, 3]
2260+
* math.broadcastSizes([2, 3], [3]) // returns [2, 3]
2261+
* math.broadcastSizes([1, 2, 3], [[1, 2, 3]]) // returns [1, 2, 3]
2262+
*
2263+
* See also:
2264+
*
2265+
* size, reshape, squeeze, broadcastTo
2266+
*
2267+
* @param {...(Array|Matrix)} x One or more matrices or arrays
2268+
* @return {number[]} A vector with the broadcasted size.
2269+
*/
2270+
broadcastSizes(...args: Array<MathCollection | Matrix>): number[]
2271+
2272+
/**
2273+
* Broadcast multiple matrices together.
2274+
* Return an array of matrices with the broadcasted sizes.
2275+
*
2276+
* Syntax:
2277+
*
2278+
* math.broadcastMatrices(x, y)
2279+
* math.broadcastMatrices(x, y, ...)
2280+
*
2281+
* Examples:
2282+
*
2283+
* math.broadcastMatrices([1, 2], [[3], [4]]) // returns [[[1, 2], [1, 2]], [[3, 3], [4, 4]]]
2284+
* math.broadcastMatrices([2, 3]) // returns [[2, 3]]
2285+
* math.broadcastMatrices([2, 3], [3, 1]) // returns [[2, 3], [3, 1]]
2286+
*
2287+
* See also:
2288+
*
2289+
* size, reshape, broadcastSizes, broadcastTo
2290+
*
2291+
* @param {...(Array|Matrix)} args One or more matrices or arrays
2292+
* @returns {(Array|Matrix)[]} An array of matrices with the broadcasted sizes.
2293+
*/
2294+
broadcastMatrices(
2295+
...args: Array<MathCollection | Matrix>
2296+
): Array<MathCollection | Matrix>
2297+
22252298
/**
22262299
* Create a matrix filled with ones. The created matrix can have one or
22272300
* multiple dimensions.

0 commit comments

Comments
 (0)