
Research
/Security News
Contagious Interview Campaign Escalates With 67 Malicious npm Packages and New Malware Loader
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
ndarray-select
Advanced tools
Finds the kth element in an ndarray in linear time with high probability. This implementation is based on the quick select algorithm and mutates the array in place.
var pack = require("ndarray-pack")
var ndselect = require("ndarray-select")
var points = pack([0, 0, 1, 2.5, -1])
//Find the median element in the list
var median = ndselect(points, points.shape[0]>>1)
console.log(median.get())
0 2.5 -1
It is also possible to select vectors (using lexicographical comparisons):
var pack = require("ndarray-pack")
var ndselect = require("ndarray-select")
var points = pack([
[0, 0, 1],
[100, 0, 10],
[50, 1, 10],
[0, 2.5, -1],
[-1, -1, -1]
])
//Find the median element in the list
var median = ndselect(points, points.shape[0]>>1)
console.log(median.get(0), median.get(1), median.get(2))
0 2.5 -1
Install using npm:
npm install ndarray-select
var ndselect = require("ndarray-select")
ndselect(array, k[, compare])
Selects the kth item from the ndarray array
along the first axis of array
.
array
is an ndarrayk
is the rank of the item which is being selectedcompare
is an optional comparison function that gets a pair of ndarrays as input.Returns An ndarray view of array.pick(k)
Note This method modifies array
. After completion, the element at position k
will be in sorted order, with all elements <array.pick(k)
occuring before k
and all elements >array.pick(k)
after k
in the list.
ndselect.compile(order, useCompare, dtype)
Precompiles an optimized selection algorithm for an array with the given index order and datatype.
order
is the order of the ndarrayuseCompare
is a flag which if set uses a comparison functiondtype
is the datatype of the arrayReturns An optimized ndselect
function
(c) 2014 Mikola Lysenko. MIT License
FAQs
Linear time selection algorithm for ndarrays
The npm package ndarray-select receives a total of 1,341 weekly downloads. As such, ndarray-select popularity was classified as popular.
We found that ndarray-select demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.