arrayfun<T,A extends unknown[],U,>(): matrix<U>
Applies a function to each element of a array or matrix.
This function applies the provided function to each element of a array or matrix. The first argument is the input array or matrix, the second is the function to apply, followed by any additional parameters required by the function.
Apply Math.log to each element of an array
Apply Math.log to each element of an array
import { assertEquals } from "jsr:@std/assert"; assertEquals(arrayfun([1.4, 2.3, 3], Math.log), [0.33647223662121284, 0.832909122935104, 1.0986122886681096]);
Apply the sign function to an array
Apply the sign function to an array
import { assertEquals } from "jsr:@std/assert"; import { sign } from "../../index.ts"; assertEquals(arrayfun([1.4, 0, -10], sign), [1, 0, -1]);
Apply Math.pow to each element of a matrix
Apply Math.pow to each element of a matrix
import { assertEquals } from "jsr:@std/assert"; assertEquals(arrayfun([[5, 6], [1, 3]], Math.pow, 3), [[125, 216], [1, 27]]);
arrayfun<T,A extends unknown[],U,>(): array<U>
Applies a function to each element of a array or matrix.
This function applies the provided function to each element of a array or matrix. The first argument is the input array or matrix, the second is the function to apply, followed by any additional parameters required by the function.
Apply Math.log to each element of an array
Apply Math.log to each element of an array
import { assertEquals } from "jsr:@std/assert"; assertEquals(arrayfun([1.4, 2.3, 3], Math.log), [0.33647223662121284, 0.832909122935104, 1.0986122886681096]);
Apply the sign function to an array
Apply the sign function to an array
import { assertEquals } from "jsr:@std/assert"; import { sign } from "../../index.ts"; assertEquals(arrayfun([1.4, 0, -10], sign), [1, 0, -1]);
Apply Math.pow to each element of a matrix
Apply Math.pow to each element of a matrix
import { assertEquals } from "jsr:@std/assert"; assertEquals(arrayfun([[5, 6], [1, 3]], Math.pow, 3), [[125, 216], [1, 27]]);
arrayfun<T,A extends unknown[],U,>(x: T,fun: (element: T,...args: A,) => U,...funArgs: A,): U
Applies a function to each element of a array or matrix.
This function applies the provided function to each element of a array or matrix. The first argument is the input array or matrix, the second is the function to apply, followed by any additional parameters required by the function.
Apply Math.log to each element of an array
Apply Math.log to each element of an array
import { assertEquals } from "jsr:@std/assert"; assertEquals(arrayfun([1.4, 2.3, 3], Math.log), [0.33647223662121284, 0.832909122935104, 1.0986122886681096]);
Apply the sign function to an array
Apply the sign function to an array
import { assertEquals } from "jsr:@std/assert"; import { sign } from "../../index.ts"; assertEquals(arrayfun([1.4, 0, -10], sign), [1, 0, -1]);
Apply Math.pow to each element of a matrix
Apply Math.pow to each element of a matrix
import { assertEquals } from "jsr:@std/assert"; assertEquals(arrayfun([[5, 6], [1, 3]], Math.pow, 3), [[125, 216], [1, 27]]);
The result of applying the function to each element of the input. Returns a array, matrix, or single value based on input.
arrayfun<T,A extends unknown[],U,>():
Applies a function to each element of a array or matrix.
This function applies the provided function to each element of a array or matrix. The first argument is the input array or matrix, the second is the function to apply, followed by any additional parameters required by the function.
Apply Math.log to each element of an array
Apply Math.log to each element of an array
import { assertEquals } from "jsr:@std/assert"; assertEquals(arrayfun([1.4, 2.3, 3], Math.log), [0.33647223662121284, 0.832909122935104, 1.0986122886681096]);
Apply the sign function to an array
Apply the sign function to an array
import { assertEquals } from "jsr:@std/assert"; import { sign } from "../../index.ts"; assertEquals(arrayfun([1.4, 0, -10], sign), [1, 0, -1]);
Apply Math.pow to each element of a matrix
Apply Math.pow to each element of a matrix
import { assertEquals } from "jsr:@std/assert"; assertEquals(arrayfun([[5, 6], [1, 3]], Math.pow, 3), [[125, 216], [1, 27]]);