fastSort in toPointSet conversion
This commit is contained in:
parent
9f103f5cbe
commit
5db63fbe9f
|
@ -39,6 +39,13 @@ module Internals = {
|
|||
module T = {
|
||||
type t = array<float>
|
||||
|
||||
let fastSort = (samples: t): t => {
|
||||
let typedSamples = samples->Js.TypedArray2.Float64Array.make->Js.TypedArray2.Float64Array.sortInPlace
|
||||
// why is there no standard function in Resctipt for this?
|
||||
let typedToArray: Js.TypedArray2.Float64Array.t => t = %raw(`a => Array.from(a)`)
|
||||
typedToArray(typedSamples)
|
||||
}
|
||||
|
||||
let xWidthToUnitWidth = (samples, outputXYPoints, xWidth) => {
|
||||
let xyPointRange = E.A.Sorted.range(samples)->E.O2.default(0.0)
|
||||
let xyPointWidth = xyPointRange /. float_of_int(outputXYPoints)
|
||||
|
@ -62,7 +69,7 @@ let toPointSetDist = (
|
|||
~samplingInputs: SamplingInputs.samplingInputs,
|
||||
(),
|
||||
): Internals.Types.outputs => {
|
||||
let samples = samples->Js.Array2.copy->Js.Array2.sortInPlaceWith(compare)
|
||||
let samples = samples->Internals.T.fastSort
|
||||
|
||||
let minDiscreteToKeep = MagicNumbers.ToPointSet.minDiscreteToKeep(samples)
|
||||
let (continuousPart, discretePart) = E.A.Floats.Sorted.splitContinuousAndDiscreteForMinWeight(
|
||||
|
|
Loading…
Reference in New Issue
Block a user