scaleoffset

package
v0.19.1 Latest Latest
Warning

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

Go to latest
Published: May 28, 2024 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package scaleoffset provides functions for applying and discarding scale and offset from a value.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply[T Numeric](value T, scale, offset float64) float64

Apply applies scale and offset on value.

func ApplyAny

func ApplyAny(value any, scale, offset float64) any

ApplyAny applies scale and offset when possible and return it as primitive-types value. Otherwise return original value.

func ApplySlice

func ApplySlice[S []E, E Numeric](values S, scale, offset float64) []float64

Apply applies scale and offset on slice values.

func ApplyValue added in v0.12.0

func ApplyValue(value proto.Value, scale, offset float64) proto.Value

ApplyValue applies scale and offset when possible and return it as primitive-types value. Otherwise return original value.

func Discard

func Discard(value, scale, offset float64) float64

Discard discards applied scale and offset on value.

func DiscardAny

func DiscardAny(value any, baseType basetype.BaseType, scale, offset float64) any

DiscardAny restores scaled value in the form of float64 or []float64 to its basetype's form and return it as primitive-types value.

func DiscardSlice

func DiscardSlice[T Numeric](values []float64, scale, offset float64) []T

DiscardSlice discards applied scale and offset on slice values.

func DiscardValue added in v0.12.0

func DiscardValue(value proto.Value, baseType basetype.BaseType, scale, offset float64) proto.Value

DiscardValue restores scaled value in the form of float64 or []float64 to its basetype's form.

Types

type Numeric

type Numeric interface {
	constraints.Integer | constraints.Float
}

Jump to

Keyboard shortcuts

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