Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Package interpolator provides univariate data interpolators.

License

Notifications You must be signed in to change notification settings

edgelaboratories/interpolator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Interpolator

GoDoc Build Status GolangCI Lint Go Report Card

Description

Package interpolator provides univariate data interpolators:

The input data is specified by means of a nonempty slice of two-dimensional points XYs. If a single data point is provided, the resulting interpolator treats the input as a constant for all abscissae.

Installation

go get -u github.com/edgelaboratories/interpolator

Example

package main

import (
	"fmt"
	"log"

	"github.com/edgelaboratories/interpolator"
)

func main() {
	xys := interpolator.XYs{
		{
			X: 0.0,
			Y: 1.2,
		},
		{
			X: 0.5,
			Y: 1.0,
		},
		{
			X: 1.0,
			Y: 1.4,
		},
	}
	interp, err := interpolator.NewGeometric(xys)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("value at 0.75 is %0.2f\n", interp.Value(0.75))
	fmt.Printf("gradient at 0.75 is %0.2f\n", interp.Gradient(0.75))
}