vectorfun<T>(): T | T[]
Applies a function to each vector column or row of a matrix.
This function applies a given function to each vector (column or row) of a matrix based on the specified dimension. For arrays: applies function directly and returns the result. For matrices: applies function to each row/column and returns array of results.
Apply function along rows of a matrix
Apply function along rows of a matrix
import { assertEquals } from "jsr:@std/assert"; const mean = (a: number[]): number => a.reduce((sum, num) => sum + num, 0) / a.length; assertEquals(vectorfun(0, [[5, 6, 5], [7, 8, -1]], mean), [5.333333333333333, 4.666666666666667]);
Apply function along columns of a matrix
Apply function along columns of a matrix
import { assertEquals } from "jsr:@std/assert"; const mean = (a: number[]): number => a.reduce((sum, num) => sum + num, 0) / a.length; assertEquals(vectorfun(1, [[5, 6, 5], [7, 8, -1]], mean), [6, 7, 2]);
Applying function on a single array
Applying function on a single array
import { assertEquals } from "jsr:@std/assert"; const sum = (arr: number[]): number => arr.reduce((sum, num) => sum + num, 0); assertEquals(vectorfun(0, [1, 2, 3, 4], sum), 10);
vectorfun<T,A1,>(): T | T[]
Applies a function to each vector column or row of a matrix.
This function applies a given function to each vector (column or row) of a matrix based on the specified dimension. For arrays: applies function directly and returns the result. For matrices: applies function to each row/column and returns array of results.
Apply function along rows of a matrix
Apply function along rows of a matrix
import { assertEquals } from "jsr:@std/assert"; const mean = (a: number[]): number => a.reduce((sum, num) => sum + num, 0) / a.length; assertEquals(vectorfun(0, [[5, 6, 5], [7, 8, -1]], mean), [5.333333333333333, 4.666666666666667]);
Apply function along columns of a matrix
Apply function along columns of a matrix
import { assertEquals } from "jsr:@std/assert"; const mean = (a: number[]): number => a.reduce((sum, num) => sum + num, 0) / a.length; assertEquals(vectorfun(1, [[5, 6, 5], [7, 8, -1]], mean), [6, 7, 2]);
Applying function on a single array
Applying function on a single array
import { assertEquals } from "jsr:@std/assert"; const sum = (arr: number[]): number => arr.reduce((sum, num) => sum + num, 0); assertEquals(vectorfun(0, [1, 2, 3, 4], sum), 10);
vectorfun<T,A1,A2,>(): T | T[]
Applies a function to each vector column or row of a matrix.
This function applies a given function to each vector (column or row) of a matrix based on the specified dimension. For arrays: applies function directly and returns the result. For matrices: applies function to each row/column and returns array of results.
Apply function along rows of a matrix
Apply function along rows of a matrix
import { assertEquals } from "jsr:@std/assert"; const mean = (a: number[]): number => a.reduce((sum, num) => sum + num, 0) / a.length; assertEquals(vectorfun(0, [[5, 6, 5], [7, 8, -1]], mean), [5.333333333333333, 4.666666666666667]);
Apply function along columns of a matrix
Apply function along columns of a matrix
import { assertEquals } from "jsr:@std/assert"; const mean = (a: number[]): number => a.reduce((sum, num) => sum + num, 0) / a.length; assertEquals(vectorfun(1, [[5, 6, 5], [7, 8, -1]], mean), [6, 7, 2]);
Applying function on a single array
Applying function on a single array
import { assertEquals } from "jsr:@std/assert"; const sum = (arr: number[]): number => arr.reduce((sum, num) => sum + num, 0); assertEquals(vectorfun(0, [1, 2, 3, 4], sum), 10);
vectorfun<T,A1,A2,A3,>(dim: 0 | 1,fun: () => T,arg1: A1,arg2: A2,arg3: A3,): T | T[]
Applies a function to each vector column or row of a matrix.
This function applies a given function to each vector (column or row) of a matrix based on the specified dimension. For arrays: applies function directly and returns the result. For matrices: applies function to each row/column and returns array of results.
Apply function along rows of a matrix
Apply function along rows of a matrix
import { assertEquals } from "jsr:@std/assert"; const mean = (a: number[]): number => a.reduce((sum, num) => sum + num, 0) / a.length; assertEquals(vectorfun(0, [[5, 6, 5], [7, 8, -1]], mean), [5.333333333333333, 4.666666666666667]);
Apply function along columns of a matrix
Apply function along columns of a matrix
import { assertEquals } from "jsr:@std/assert"; const mean = (a: number[]): number => a.reduce((sum, num) => sum + num, 0) / a.length; assertEquals(vectorfun(1, [[5, 6, 5], [7, 8, -1]], mean), [6, 7, 2]);
Applying function on a single array
Applying function on a single array
import { assertEquals } from "jsr:@std/assert"; const sum = (arr: number[]): number => arr.reduce((sum, num) => sum + num, 0); assertEquals(vectorfun(0, [1, 2, 3, 4], sum), 10);