@thi.ng/vectors
Advanced tools
12
api.d.ts
@@ -149,3 +149,5 @@ import type { ArrayLikeIterable, Fn, Fn0, Fn2, Fn3, Fn4, Fn6, Fn7, FnU2, ICopy, IEmpty, IEqualsDelta, ILength, NumericArray, Tuple, TypedArray } from "@thi.ng/api"; | ||
* @example | ||
* ```ts | ||
* ```ts tangle:../export/vec-api.ts | ||
* import { VEC2, VEC3, type Vec, type VecAPI } from "@thi.ng/vectors"; | ||
* | ||
* interface Particle { | ||
@@ -174,3 +176,5 @@ * pos: Vec; | ||
* | ||
* updateParticle(p2d, VEC2); | ||
* console.log( | ||
* updateParticle(p2d, VEC2) | ||
* ); | ||
* // [ 10.552, 24.969 ] | ||
@@ -184,3 +188,5 @@ * | ||
* | ||
* updateParticle(p3d, VEC3); | ||
* console.log( | ||
* updateParticle(p3d, VEC3) | ||
* ); | ||
* // [ 10, 24.969, 30.552 ] | ||
@@ -187,0 +193,0 @@ * ``` |
@@ -14,6 +14,8 @@ import type { NumericArray, TypedArrayTypeMap } from "@thi.ng/api"; | ||
* @example | ||
* ```ts | ||
* ```ts tangle:../export/map-buffer.ts | ||
* import { mapBuffer } from "@thi.ng/vectors"; | ||
* | ||
* mapBuffer("f32", new ArrayBuffer(32), 4, 2) | ||
* console.log( | ||
* mapBuffer("f32", new ArrayBuffer(32), 4, 2) | ||
* ); | ||
* // [ | ||
@@ -20,0 +22,0 @@ * // Float32Array [ 0, 0 ], |
# Change Log | ||
- **Last updated**: 2024-05-08T18:24:31Z | ||
- **Last updated**: 2024-06-21T19:34:38Z | ||
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub) | ||
@@ -12,2 +12,13 @@ | ||
## [7.11.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/vectors@7.11.0) (2024-06-21) | ||
#### 🚀 Features | ||
- add eqDist2/3() predicates ([5bda768](https://github.com/thi-ng/umbrella/commit/5bda768)) | ||
#### ♻️ Refactoring | ||
- rename various rest args to be more semantically meaningful ([8088a56](https://github.com/thi-ng/umbrella/commit/8088a56)) | ||
- enforce uniform naming convention of internal functions ([56992b2](https://github.com/thi-ng/umbrella/commit/56992b2)) | ||
### [7.10.23](https://github.com/thi-ng/umbrella/tree/@thi.ng/vectors@7.10.23) (2024-03-27) | ||
@@ -14,0 +25,0 @@ |
import type { FnU2 } from "@thi.ng/api"; | ||
import type { MultiVecOpVN, MultiVecOpVV, Template, VecOpVN, VecOpVV } from "../api.js"; | ||
/** @internal */ | ||
export declare const defaultOut: FnU2<string>; | ||
export declare const __defaultOut: FnU2<string>; | ||
/** @internal */ | ||
@@ -6,0 +6,0 @@ export declare const compile: (dim: number, tpl: Template, args: string, syms?: string, ret?: string, opJoin?: string, pre?: string, post?: string, strided?: boolean) => any; |
@@ -24,6 +24,6 @@ import { comp } from "@thi.ng/transducers/comp"; | ||
} from "./templates.js"; | ||
const lookup = (sym) => (i) => i > 1 ? `${sym}[i${sym}+${i}*s${sym}]` : i == 1 ? `${sym}[i${sym}+s${sym}]` : `${sym}[i${sym}]`; | ||
const indicesStrided = (sym) => map(lookup(sym), range()); | ||
const indices = (sym) => map((i) => `${sym}[${i}]`, range()); | ||
const assemble = (dim, tpl, syms, ret = "a", opJoin = "", pre = "", post = "", strided = false) => [ | ||
const __lookup = (sym) => (i) => i > 1 ? `${sym}[i${sym}+${i}*s${sym}]` : i == 1 ? `${sym}[i${sym}+s${sym}]` : `${sym}[i${sym}]`; | ||
const __indicesStrided = (sym) => map(__lookup(sym), range()); | ||
const __indices = (sym) => map((i) => `${sym}[${i}]`, range()); | ||
const __assemble = (dim, tpl, syms, ret = "a", opJoin = "", pre = "", post = "", strided = false) => [ | ||
pre, | ||
@@ -38,3 +38,3 @@ transduce( | ||
null, | ||
syms.split(",").map(strided ? indicesStrided : indices) | ||
syms.split(",").map(strided ? __indicesStrided : __indices) | ||
) | ||
@@ -45,3 +45,3 @@ ), | ||
]; | ||
const assembleG = (tpl, syms, ret = "a", pre, post, strided = false) => [ | ||
const __assembleG = (tpl, syms, ret = "a", pre, post, strided = false) => [ | ||
pre, | ||
@@ -56,3 +56,3 @@ "for(let i=a.length;--i>=0;) {", | ||
]; | ||
const assembleS = (tpl, syms = ARGS_VV, ret = "o", pre = DEFAULT_OUT, post) => [ | ||
const __assembleS = (tpl, syms = ARGS_VV, ret = "o", pre = DEFAULT_OUT, post) => [ | ||
pre, | ||
@@ -65,6 +65,6 @@ "while(k-->0) {", | ||
]; | ||
const defaultOut = (o, args) => `!${o} && (${o}=${args.split(",")[1]});`; | ||
const __defaultOut = (o, args) => `!${o} && (${o}=${args.split(",")[1]});`; | ||
const compile = (dim, tpl, args, syms = args, ret = "a", opJoin, pre, post, strided = false) => new Function( | ||
args, | ||
assemble(dim, tpl, syms, ret, opJoin, pre, post, strided).join("") | ||
__assemble(dim, tpl, syms, ret, opJoin, pre, post, strided).join("") | ||
); | ||
@@ -74,3 +74,3 @@ const compileHOF = (dim, fns, tpl, hofArgs, args, syms = args, ret = "a", opJoin = "", pre, post, strided = false) => { | ||
hofArgs, | ||
`return (${args})=>{${assemble( | ||
`return (${args})=>{${__assemble( | ||
dim, | ||
@@ -89,8 +89,8 @@ tpl, | ||
args, | ||
assembleG(tpl, syms, ret, pre, post, strided).join("") | ||
__assembleG(tpl, syms, ret, pre, post, strided).join("") | ||
); | ||
const compileS = (tpl, args, syms = args, ret, pre, post) => new Function(args, assembleS(tpl, syms, ret, pre, post).join("")); | ||
const compileS = (tpl, args, syms = args, ret, pre, post) => new Function(args, __assembleS(tpl, syms, ret, pre, post).join("")); | ||
const compileGHOF = (fns, tpl, hofArgs, args, syms = args, ret = "a", pre, post, strided = false) => new Function( | ||
hofArgs, | ||
`return (${args})=>{${assembleG( | ||
`return (${args})=>{${__assembleG( | ||
tpl, | ||
@@ -106,3 +106,3 @@ syms, | ||
syms = syms || args; | ||
pre = pre != null ? pre : defaultOut(ret, args); | ||
pre = pre != null ? pre : __defaultOut(ret, args); | ||
const fn = vop(dispatch); | ||
@@ -117,3 +117,3 @@ const $ = (dim) => fn.add(dim, compile(dim, tpl, args, syms, ret, "", pre)); | ||
syms = syms || args; | ||
pre = pre != null ? pre : defaultOut(ret, args); | ||
pre = pre != null ? pre : __defaultOut(ret, args); | ||
const fn = vop(dispatch); | ||
@@ -137,3 +137,3 @@ const $ = (dim) => fn.add( | ||
"", | ||
pre != null ? pre : defaultOut(ret, args), | ||
pre != null ? pre : __defaultOut(ret, args), | ||
"", | ||
@@ -147,5 +147,8 @@ true | ||
"op", | ||
`return (${args},k,${idxArgs})=>{${assembleS(tpl, syms, ret, pre).join( | ||
"" | ||
)}}` | ||
`return (${args},k,${idxArgs})=>{${__assembleS( | ||
tpl, | ||
syms, | ||
ret, | ||
pre | ||
).join("")}}` | ||
)(op), | ||
@@ -162,3 +165,3 @@ ...sizes.map( | ||
"", | ||
pre != null ? pre : defaultOut(ret, args), | ||
pre != null ? pre : __defaultOut(ret, args), | ||
"", | ||
@@ -174,2 +177,3 @@ true | ||
export { | ||
__defaultOut, | ||
compile, | ||
@@ -188,4 +192,3 @@ compileG, | ||
defOp, | ||
defOpS, | ||
defaultOut | ||
defOpS | ||
}; |
@@ -9,6 +9,8 @@ import type { DistanceFn } from "./api.js"; | ||
* @example | ||
* ```ts | ||
* ```ts tangle:../export/dist-braycurtis.ts | ||
* import { distBrayCurtis } from "@thi.ng/vectors"; | ||
* | ||
* distBrayCurtis([6, 7, 4], [10, 0, 6]) | ||
* console.log( | ||
* distBrayCurtis([6, 7, 4], [10, 0, 6]) | ||
* ); | ||
* // 0.393939... | ||
@@ -15,0 +17,0 @@ * ``` |
@@ -5,3 +5,3 @@ import { radians2 } from "./radians.js"; | ||
b = radians2([], b); | ||
return dist(a[0], a[1], b[0], b[1], r); | ||
return __dist(a[0], a[1], b[0], b[1], r); | ||
}; | ||
@@ -11,6 +11,6 @@ const distHaversineLonLat = (a, b, r = 6371) => { | ||
b = radians2([], b); | ||
return dist(a[1], a[0], b[1], b[0], r); | ||
return __dist(a[1], a[0], b[1], b[0], r); | ||
}; | ||
const distHaversine = distHaversineLonLat; | ||
const dist = (lat1, lon1, lat2, lon2, r) => { | ||
const __dist = (lat1, lon1, lat2, lon2, r) => { | ||
const dlat = 0.5 - Math.cos(lat2 - lat1) * 0.5; | ||
@@ -17,0 +17,0 @@ const dlon = (1 - Math.cos(lon2 - lon1)) * 0.5; |
@@ -9,3 +9,3 @@ import type { DistanceFn, ReadonlyVec } from "./api.js"; | ||
* @example | ||
* ```ts | ||
* ```ts tangle:../export/weighted-distance.ts | ||
* import { dist3, weightedDistance, ONE3, ZERO3 } from "@thi.ng/vectors"; | ||
@@ -17,7 +17,11 @@ * | ||
* // distance in XZ plane only | ||
* distXZ(ONE3, ZERO3); | ||
* console.log( | ||
* distXZ(ONE3, ZERO3) | ||
* ); | ||
* // 1.4142135623730951 | ||
* | ||
* // compare with full Eucledian distance | ||
* dist3(ONE3, ZERO3); | ||
* console.log( | ||
* dist3(ONE3, ZERO3) | ||
* ); | ||
* // 1.7320508075688772 | ||
@@ -24,0 +28,0 @@ * ``` |
@@ -9,6 +9,6 @@ import type { IVector } from "./api.js"; | ||
* @example | ||
* ```ts | ||
* ```ts tangle:../export/fill.ts | ||
* import { fill, Vec2 } from "@thi.ng/vectors"; | ||
* | ||
* fill( | ||
* const buf = fill( | ||
* new Vec2(new Float32Array(12)), | ||
@@ -18,3 +18,5 @@ * new Vec2([1, 2]), | ||
* 4 // stride | ||
* ) | ||
* ); | ||
* | ||
* console.log(buf); | ||
* // Float32Array [1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 0, 0] | ||
@@ -21,0 +23,0 @@ * ``` |
@@ -34,30 +34,30 @@ import type { NumericArray } from "@thi.ng/api"; | ||
* @example | ||
* ```ts | ||
* import { gvec, eqDelta } from "@thi.ng/vectors"; | ||
* ```ts tangle:../export/gvec.ts | ||
* import { gvec, add, copy, eqDelta } from "@thi.ng/vectors"; | ||
* | ||
* // 3D vector w/ component stride length of 4 | ||
* a = gvec([1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0], 3, 0, 4); | ||
* a[0] // 1 | ||
* a[1] // 2 | ||
* a[2] // 3 | ||
* let a = gvec([1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0], 3, 0, 4); | ||
* | ||
* a.stride | ||
* console.log(a[0], a[1], a[2]); | ||
* // 1 2 3 | ||
* | ||
* console.log(a.stride); | ||
* // 4 | ||
* | ||
* [...a] | ||
* console.log([...a]); | ||
* // [1, 2, 3] | ||
* | ||
* a.toString() | ||
* // "[1,2,3]" | ||
* console.log(a.toString()); | ||
* // "[1.000, 2.000, 3.000]" | ||
* | ||
* add([], a, a) | ||
* console.log(add([], a, a)); | ||
* // [2, 4, 6] | ||
* | ||
* copy(a) | ||
* console.log(copy(a)); | ||
* // [1, 2, 3] | ||
* | ||
* a.copyView() | ||
* console.log(a.copyView()); | ||
* // Proxy [ [ 1, 0, 2, 0, 3, 0 ], ... } | ||
* | ||
* eqDelta(a, [1, 2, 3]) | ||
* console.log(eqDelta(a, [1, 2, 3])); | ||
* // true | ||
@@ -64,0 +64,0 @@ * ``` |
@@ -31,3 +31,3 @@ import { EPS } from "@thi.ng/math/api"; | ||
]); | ||
const keys = memoizeO((size) => [ | ||
const __keys = memoizeO((size) => [ | ||
...map(String, range(size)), | ||
@@ -89,3 +89,3 @@ ...PROPS | ||
ownKeys() { | ||
return keys(size); | ||
return __keys(size); | ||
} | ||
@@ -92,0 +92,0 @@ }); |
@@ -22,3 +22,3 @@ import type { ReadonlyVec } from "./api.js"; | ||
* | ||
* ```ts | ||
* ```ts tangle:../export/hash.ts | ||
* import { hash } from "@thi.ng/vectors"; | ||
@@ -30,7 +30,9 @@ * import { | ||
* // integer grid coords | ||
* uniq = transduce(map(hash), conj(), range2d(0x1000, 0x1000)).size | ||
* let uniq = transduce(map(hash), conj(), range2d(0x1000, 0x1000)).size | ||
* | ||
* console.log(uniq); | ||
* // 16744420 | ||
* | ||
* // collision rate | ||
* (1 - uniq / (0x1000 ** 2)) * 100 | ||
* console.log((1 - uniq / (0x1000 ** 2)) * 100); | ||
* // 0.1955 % | ||
@@ -44,6 +46,8 @@ * | ||
* ).size | ||
* | ||
* console.log(uniq); | ||
* // 1001895 | ||
* | ||
* // collision rate | ||
* (1 - uniq / (1001 ** 2)) * 100 | ||
* console.log((1 - uniq / (1001 ** 2)) * 100); | ||
* // 0.0106 % | ||
@@ -50,0 +54,0 @@ * ``` |
@@ -7,3 +7,3 @@ import { floatToUintBits } from "@thi.ng/binary/float"; | ||
for (let i = v.length; i-- > 0; ) { | ||
hash4 = imul(H, hash4) + mix(hash4, floatToUintBits(v[i])) >>> 0; | ||
hash4 = imul(H, hash4) + __mix(hash4, floatToUintBits(v[i])) >>> 0; | ||
} | ||
@@ -15,3 +15,3 @@ return hash4; | ||
const M3 = 3864292196; | ||
const mix = (h, k) => { | ||
const __mix = (h, k) => { | ||
k = imul(rotateLeft(imul(k, M1) >>> 0, 15), M2) >>> 0; | ||
@@ -18,0 +18,0 @@ return (imul(rotateLeft(h ^ k, 13), 5) >>> 0) + M3 >>> 0; |
@@ -74,2 +74,3 @@ export * from "./api.js"; | ||
export * from "./eqdelta.js"; | ||
export * from "./eqdist.js"; | ||
export * from "./equals.js"; | ||
@@ -76,0 +77,0 @@ export * from "./every.js"; |
@@ -74,2 +74,3 @@ export * from "./api.js"; | ||
export * from "./eqdelta.js"; | ||
export * from "./eqdist.js"; | ||
export * from "./equals.js"; | ||
@@ -76,0 +77,0 @@ export * from "./every.js"; |
@@ -1,2 +0,2 @@ | ||
import type { ReadonlyVec, VecOpVV, Vec, VecOpVN, VecOpVVV, VecOpVVN } from "./api.js"; | ||
import type { ReadonlyVec, Vec, VecOpVN, VecOpVV, VecOpVVN, VecOpVVV } from "./api.js"; | ||
/** | ||
@@ -15,12 +15,18 @@ * Takes a vec op `fn`, output array (or null) and a combination of the | ||
* @example | ||
* ```ts | ||
* import { addN2, mapVectors, mixN2 } from "@thi.ng/vectors"; | ||
* ```ts tangle:../export/map-vectors.ts | ||
* import { add2, addN2, mapVectors, mixN2 } from "@thi.ng/vectors"; | ||
* | ||
* mapVectors(addN2, [], [[1, 2], [10, 20]], 100) | ||
* console.log( | ||
* mapVectors(addN2, [], [[1, 2], [10, 20]], 100) | ||
* ); | ||
* // [ [ 101, 102 ], [ 110, 120 ] ] | ||
* | ||
* mapVectors(add2, [], [[1, 2], [10, 20]], [[100, 200], [1000, 2000]]) | ||
* console.log( | ||
* mapVectors(add2, [], [[1, 2], [10, 20]], [[100, 200], [1000, 2000]]) | ||
* ); | ||
* // [ [ 101, 202 ], [ 1010, 2020 ] ] | ||
* | ||
* mapVectors(mixN2, null, [[1, 2], [100, 200]], [[10, 20], [1000, 2000]], 0.5) | ||
* console.log( | ||
* mapVectors(mixN2, null, [[1, 2], [100, 200]], [[10, 20], [1000, 2000]], 0.5) | ||
* ); | ||
* // [ [ 5.5, 11 ], [ 550, 1100 ] ] | ||
@@ -27,0 +33,0 @@ * ``` |
@@ -5,6 +5,6 @@ import { isNumber } from "@thi.ng/checks/is-number"; | ||
!out && (out = new Array(num)); | ||
c !== void 0 ? isNumber(c) ? mapVVN(fn, out, a, b, c) : mapVVV(fn, out, a, b, c) : isNumber(b) ? mapVN(fn, out, a, b) : mapVV(fn, out, a, b); | ||
c !== void 0 ? isNumber(c) ? __mapVVN(fn, out, a, b, c) : __mapVVV(fn, out, a, b, c) : isNumber(b) ? __mapVN(fn, out, a, b) : __mapVV(fn, out, a, b); | ||
return out; | ||
} | ||
const mapVN = (fn, out, a, b) => { | ||
const __mapVN = (fn, out, a, b) => { | ||
for (let i = 0, num = a.length; i < num; i++) { | ||
@@ -14,3 +14,3 @@ out[i] = fn(out[i] || [], a[i], b); | ||
}; | ||
const mapVV = (fn, out, a, b) => { | ||
const __mapVV = (fn, out, a, b) => { | ||
for (let i = 0, num = a.length; i < num; i++) { | ||
@@ -20,3 +20,3 @@ out[i] = fn(out[i] || [], a[i], b[i]); | ||
}; | ||
const mapVVN = (fn, out, a, b, c) => { | ||
const __mapVVN = (fn, out, a, b, c) => { | ||
for (let i = 0, num = a.length; i < num; i++) { | ||
@@ -26,3 +26,3 @@ out[i] = fn(out[i] || [], a[i], b[i], c); | ||
}; | ||
const mapVVV = (fn, out, a, b, c) => { | ||
const __mapVVV = (fn, out, a, b, c) => { | ||
for (let i = 0, num = a.length; i < num; i++) { | ||
@@ -29,0 +29,0 @@ out[i] = fn(out[i] || [], a[i], b[i], c[i]); |
22
map.d.ts
@@ -21,3 +21,3 @@ import type { IVector, VecOpV, VecOpVN, VecOpVV, VecOpVVN, VecOpVVV } from "./api.js"; | ||
* @example | ||
* ```ts | ||
* ```ts tangle:../export/mapvv.ts | ||
* import { add2, mapVV, Vec2 } from "@thi.ng/vectors"; | ||
@@ -27,3 +27,3 @@ * | ||
* // different strided data layouts | ||
* mapVV( | ||
* const res = mapVV( | ||
* // transformation function | ||
@@ -42,2 +42,4 @@ * add2, | ||
* ); | ||
* | ||
* console.log(res); | ||
* // [ 11, 22, 33, 44 ] | ||
@@ -52,3 +54,3 @@ * ``` | ||
* | ||
* ```ts | ||
* ```ts tangle:../export/map-vec2.ts | ||
* import { add2, Vec2 } from "@thi.ng/vectors"; | ||
@@ -69,3 +71,3 @@ * import { map, run, zip } from "@thi.ng/transducers"; | ||
* | ||
* out | ||
* console.log(out); | ||
* // [ 11, 22, 33, 44 ] | ||
@@ -89,3 +91,3 @@ * ``` | ||
* @example | ||
* ```ts | ||
* ```ts tangle:../export/mapv.ts | ||
* import { mapV, swapXY, Vec2 } from "@thi.ng/vectors"; | ||
@@ -95,10 +97,14 @@ * | ||
* // i.e. [x1, x2, x3, x4, y1, y2, y3, y4] | ||
* buf = [1, 3, 5, 7, 2, 4, 6, 8]; | ||
* const buf = [1, 3, 5, 7, 2, 4, 6, 8]; | ||
* | ||
* // use `swapXY` to swizzle each vector and use AOS for output | ||
* res = mapV(swapXY, new Vec2(), new Vec2(buf, 0, 4), 4, 2, 1); | ||
* const res = mapV(swapXY, new Vec2(), new Vec2(buf, 0, 4), 4, 2, 1); | ||
* | ||
* console.log(res); | ||
* // [ 2, 1, 4, 3, 6, 5, 8, 7 ] | ||
* | ||
* // unpack result for demonstration purposes | ||
* [...Vec2.iterator(res, 4)].map(v => [...v]); | ||
* console.log( | ||
* [...Vec2.iterator(res, 4)].map(v => [...v]) | ||
* ); | ||
* // [ [ 2, 1 ], [ 4, 3 ], [ 6, 5 ], [ 8, 7 ] ] | ||
@@ -105,0 +111,0 @@ * ``` |
@@ -10,6 +10,8 @@ import type { ReadonlyVec, Vec } from "./api.js"; | ||
* @example | ||
* ```ts | ||
* ```ts tangle:../export/mean.ts | ||
* import { mean } from "@thi.ng/vectors"; | ||
* | ||
* mean([], [[3, 10, 400], [4, 30, 100], [1, 40, 200], [2, 20, 300]]) | ||
* console.log( | ||
* mean([], [[3, 10, 400], [4, 30, 100], [1, 40, 200], [2, 20, 300]]) | ||
* ); | ||
* // [ 2.5, 25, 250 ] | ||
@@ -26,6 +28,8 @@ * ``` | ||
* @example | ||
* ```ts | ||
* ```ts tangle:../export/vmean.ts | ||
* import { vmean } from "@thi.ng/vectors"; | ||
* | ||
* vmean([5, 10, 15, 20]) | ||
* console.log( | ||
* vmean([5, 10, 15, 20]) | ||
* ); | ||
* // 12.5 | ||
@@ -32,0 +36,0 @@ * ``` |
@@ -8,6 +8,8 @@ import type { ReadonlyVec, Vec } from "./api.js"; | ||
* @example | ||
* ```ts | ||
* ```ts tangle:../export/median.ts | ||
* import { median } from "@thi.ng/vectors"; | ||
* | ||
* median([], [[3, 10, 400], [4, 30, 100], [1, 40, 200], [2, 20, 300]]) | ||
* console.log( | ||
* median([], [[3, 10, 400], [4, 30, 100], [1, 40, 200], [2, 20, 300]]) | ||
* ); | ||
* // [ 3, 30, 300 ] | ||
@@ -24,6 +26,8 @@ * ``` | ||
* @example | ||
* ```ts | ||
* ```ts tangle:../export/vmedian.ts | ||
* import { vmedian } from "@thi.ng/vectors"; | ||
* | ||
* vmedian([10, 20, 5, 15]) | ||
* console.log( | ||
* vmedian([10, 20, 5, 15]) | ||
* ); | ||
* // 10 | ||
@@ -30,0 +34,0 @@ * ``` |
@@ -8,6 +8,8 @@ import type { ReadonlyVec, Vec } from "./api.js"; | ||
* @example | ||
* ```ts | ||
* ```ts tangle:../export/ortho-normal3.ts | ||
* import { orthoNormal3 } from "@thi.ng/vectors"; | ||
* | ||
* orthoNormal3([], [0, 0, 0], [1, 0, 0], [0, 1, 0]) | ||
* console.log( | ||
* orthoNormal3([], [0, 0, 0], [1, 0, 0], [0, 1, 0]) | ||
* ); | ||
* // [0, 0, 1] | ||
@@ -14,0 +16,0 @@ * ``` |
{ | ||
"name": "@thi.ng/vectors", | ||
"version": "7.10.31", | ||
"version": "7.11.0", | ||
"description": "Optimized 2d/3d/4d and arbitrary length vector operations, support for memory mapping/layouts", | ||
@@ -13,3 +13,3 @@ "type": "module", | ||
}, | ||
"homepage": "https://github.com/thi-ng/umbrella/tree/develop/packages/vectors#readme", | ||
"homepage": "https://thi.ng/vectors", | ||
"funding": [ | ||
@@ -40,18 +40,18 @@ { | ||
"dependencies": { | ||
"@thi.ng/api": "^8.11.2", | ||
"@thi.ng/binary": "^3.4.25", | ||
"@thi.ng/checks": "^3.6.4", | ||
"@thi.ng/equiv": "^2.1.58", | ||
"@thi.ng/errors": "^2.5.7", | ||
"@thi.ng/math": "^5.10.13", | ||
"@thi.ng/memoize": "^3.3.4", | ||
"@thi.ng/random": "^3.8.0", | ||
"@thi.ng/strings": "^3.7.33", | ||
"@thi.ng/transducers": "^9.0.5" | ||
"@thi.ng/api": "^8.11.3", | ||
"@thi.ng/binary": "^3.4.26", | ||
"@thi.ng/checks": "^3.6.5", | ||
"@thi.ng/equiv": "^2.1.59", | ||
"@thi.ng/errors": "^2.5.8", | ||
"@thi.ng/math": "^5.11.0", | ||
"@thi.ng/memoize": "^3.3.5", | ||
"@thi.ng/random": "^3.8.1", | ||
"@thi.ng/strings": "^3.7.34", | ||
"@thi.ng/transducers": "^9.0.6" | ||
}, | ||
"devDependencies": { | ||
"@microsoft/api-extractor": "^7.43.2", | ||
"esbuild": "^0.21.1", | ||
"@microsoft/api-extractor": "^7.47.0", | ||
"esbuild": "^0.21.5", | ||
"typedoc": "^0.25.13", | ||
"typescript": "^5.4.5" | ||
"typescript": "^5.5.2" | ||
}, | ||
@@ -322,2 +322,5 @@ "keywords": [ | ||
}, | ||
"./eqdist": { | ||
"default": "./eqdist.js" | ||
}, | ||
"./equals": { | ||
@@ -788,3 +791,3 @@ "default": "./equals.js" | ||
}, | ||
"gitHead": "df34b4a9e650cc7323575356de207d78933bdcf3\n" | ||
"gitHead": "154c95cf9d6bab32174498ec3b5b5d87e42be7f9\n" | ||
} |
@@ -10,3 +10,3 @@ <!-- This file is generated - DO NOT EDIT! --> | ||
> [!NOTE] | ||
> This is one of 192 standalone projects, maintained as part | ||
> This is one of 193 standalone projects, maintained as part | ||
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo | ||
@@ -201,3 +201,3 @@ > and anti-framework. | ||
Package sizes (brotli'd, pre-treeshake): ESM: 13.88 KB | ||
Package sizes (brotli'd, pre-treeshake): ESM: 13.99 KB | ||
@@ -230,2 +230,3 @@ ## Dependencies | ||
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/ellipse-proximity.png" width="240"/> | Interactive visualization of closest points on ellipses | [Demo](https://demo.thi.ng/umbrella/ellipse-proximity/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/ellipse-proximity) | | ||
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/geom-csv-piechart.png" width="240"/> | Piechart visualization of CSV data | [Demo](https://demo.thi.ng/umbrella/geom-csv-piechart/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/geom-csv-piechart) | | ||
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/geom-knn.jpg" width="240"/> | Doodle w/ K-nearest neighbor search result visualization | [Demo](https://demo.thi.ng/umbrella/geom-knn/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/geom-knn) | | ||
@@ -232,0 +233,0 @@ | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/geom-knn-hash.jpg" width="240"/> | K-nearest neighbor search in an hash grid | [Demo](https://demo.thi.ng/umbrella/geom-knn-hash/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/geom-knn-hash) | |
@@ -6,3 +6,3 @@ import type { Vec } from "./api.js"; | ||
export declare const setC6: (out: Vec | null, a: number, b: number, c: number, d: number, e: number, f: number) => Vec; | ||
export declare const setC: (out: Vec | null, ...xs: number[]) => Vec; | ||
export declare const setC: (out: Vec | null, ...values: number[]) => Vec; | ||
//# sourceMappingURL=setc.d.ts.map |
@@ -5,6 +5,6 @@ const setC2 = (out, x, y) => (!out && (out = []), out[0] = x, out[1] = y, out); | ||
const setC6 = (out, a, b, c, d, e, f) => (!out && (out = []), out[0] = a, out[1] = b, out[2] = c, out[3] = d, out[4] = e, out[5] = f, out); | ||
const setC = (out, ...xs) => { | ||
!out && (out = []); | ||
for (let i = 0, n = xs.length; i < n; i++) { | ||
out[i] = xs[i]; | ||
const setC = (out, ...values) => { | ||
if (!out) return values; | ||
for (let i = 0, n = values.length; i < n; i++) { | ||
out[i] = values[i]; | ||
} | ||
@@ -11,0 +11,0 @@ return out; |
@@ -13,9 +13,13 @@ import type { Stringer } from "@thi.ng/strings"; | ||
* @example | ||
* ```ts | ||
* ```ts tangle:../export/def-format.ts | ||
* import { defFormat } from "@thi.ng/vectors"; | ||
* | ||
* defFormat()([1, -2, 3]) | ||
* console.log( | ||
* defFormat()([1, -2, 3]) | ||
* ); | ||
* // [1.000, -2.000, 3.000] | ||
* | ||
* defFormat({ width: 10, wrap: "||", delim: "|\n|" })([1, -2, 3]) | ||
* console.log( | ||
* defFormat({ width: 10, wrap: "||", delim: "|\n|" })([1, -2, 3]) | ||
* ); | ||
* // | 1.000| | ||
@@ -25,3 +29,5 @@ * // | -2.000| | ||
* | ||
* defFormat({ prec: 5, delim: " " })([1, -2, 3]) | ||
* console.log( | ||
* defFormat({ prec: 5, delim: " " })([1, -2, 3]) | ||
* ); | ||
* // [1.00000 -2.00000 3.00000] | ||
@@ -28,0 +34,0 @@ * ``` |
@@ -21,9 +21,13 @@ import type { ReadonlyVec, Vec } from "./api.js"; | ||
* @example | ||
* ```ts | ||
* ```ts tangle:../export/tensor.ts | ||
* import { tensor } from "@thi.ng/vectors"; | ||
* | ||
* tensor([], [1, 2, 3], [4, 5]) | ||
* console.log( | ||
* tensor([], [1, 2, 3], [4, 5]) | ||
* ); | ||
* // [ 4, 8, 12, 5, 10, 15 ] | ||
* | ||
* tensor([], [4, 5], [1, 2, 3]) | ||
* console.log( | ||
* tensor([], [4, 5], [1, 2, 3]) | ||
* ); | ||
* // [ 4, 5, 8, 10, 12, 15 ] | ||
@@ -30,0 +34,0 @@ * ``` |
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
365998
0.9%440
0.46%7949
1.06%768
0.13%