UNPKG

@thi.ng/vectors

Version:

Optimized 2d/3d/4d and arbitrary length vector operations, support for memory mapping/layouts

11 lines (10 loc) 193 B
const vecOf = (size, n = 0) => new Array(size).fill(n); const oneHot = (size, hot, value = 1) => { const res = vecOf(size); res[hot] = value; return res; }; export { oneHot, vecOf };