algorithms

package
v0.2.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotEnoughData  = errors.New("not enough data points")
	ErrOutOfBounds    = errors.New("x value out of bounds")
	ErrLengthMismatch = errors.New("data and derivatives length mismatch")
)

Functions

func CompareAny

func CompareAny(a, b any) int

CompareAny compares two values of any type and returns: -1 if a < b

0 if a == b
1 if a > b

It uses type ranking and type-specific comparison logic.

func GetTypeSortingRank

func GetTypeSortingRank(v any) int

GetTypeSortingRank returns the type rank for sorting mixed types. Lower rank means higher priority (comes first in ascending order).

func HermiteInterpolation

func HermiteInterpolation(data []float64, derivatives []float64, x float64) (float64, error)

func LagrangeInterpolation

func LagrangeInterpolation(data []float64, x float64) (float64, error)

func LinearInterpolation

func LinearInterpolation(data []float64, x float64) (float64, error)

func NearestNeighborInterpolation

func NearestNeighborInterpolation(data []float64, x float64) (float64, error)

func NewtonInterpolation

func NewtonInterpolation(data []float64, x float64) (float64, error)

func ParallelMergeStable

func ParallelMergeStable[S ~[]E, E any](x S, cmp func(E, E) int, numChunks int)

ParallelMergeStable merges the sorted chunks in the slice x. It assumes x is divided into numChunks sorted sub-slices.

func ParallelSortStableFunc

func ParallelSortStableFunc[S ~[]E, E any](x S, cmp func(E, E) int)

ParallelSortStableFunc sorts the slice x in ascending order as determined by the cmp function. It is a parallelized version of slices.SortStableFunc, using goroutines to improve performance on large datasets. The function maintains stability: equal elements preserve their original order. This optimized version uses adaptive goroutines scaling and improved chunking strategy.

func QuadraticInterpolation

func QuadraticInterpolation(data []float64, x float64) (float64, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL