sFloats

package
v0.1.84 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2025 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare added in v0.1.30

func Compare(v1, v2 float64, prec int) int

func ComparePrec added in v0.1.30

func ComparePrec(v1, v2 float64, prec int) float64

ComparePrec, "v1>v2: >0", "v1<v2: <0", "v1=v2: 0"

func CompareSlices added in v0.1.53

func CompareSlices(s1, s2 []float64, prec int) bool

func CompareTrunc added in v0.1.30

func CompareTrunc(v1, v2 float64, prec int) float64

CompareTrunc, "v1>v2: >0", "v1<v2: <0", "v1=v2: 0"

func CountValues added in v0.1.56

func CountValues(values []float64) map[float64]int

func Get64

func Get64(str string) float64

func GetDiffAbs added in v0.1.8

func GetDiffAbs(fromValue, toValue float64) float64

func GetDiffPercent added in v0.1.8

func GetDiffPercent(fromValue, toValue float64) float64

func GetDiffPercentAbs added in v0.1.8

func GetDiffPercentAbs(fromValue, toValue float64) float64

func GetPrec added in v0.1.30

func GetPrec(value float64, prec int) float64

func GetTrunc added in v0.1.30

func GetTrunc(value float64, prec int) float64

func GetTruncPlus added in v0.1.30

func GetTruncPlus(value float64, prec, plus int) float64

trunc a float value an add a plus value at prec decimal

func GetValid added in v0.1.1

func GetValid(f float64) float64

func GetWithPercent

func GetWithPercent(value, percent float64, adding bool) float64

Adding or Subtracting percent to value

func MinMax added in v0.1.2

func MinMax(values []float64, zero bool) (float64, float64)

MinMax positive values of the float slice, including "0" or not

func ModifySlice added in v0.1.56

func ModifySlice(s []float64, f func(float64) float64)

func Sort added in v0.1.30

func Sort(values []float64, asc bool)

Sort the float slice in ascending or descending order

func Sum added in v0.1.34

func Sum(values []float64) float64

func SumSlice added in v0.1.53

func SumSlice(s []float64) float64

func ToString added in v0.1.1

func ToString(v float64, prec int) string

func WeightValues added in v0.1.56

func WeightValues(values []float64, prec int) map[float64]float64

Types

type Average added in v0.1.2

type Average struct {
	// contains filtered or unexported fields
}

func NewAverage added in v0.1.2

func NewAverage() *Average

func (*Average) Add added in v0.1.2

func (a *Average) Add(v float64)

func (*Average) Calc added in v0.1.2

func (a *Average) Calc() float64

func (*Average) Qty added in v0.1.2

func (a *Average) Qty() int

func (*Average) Reset added in v0.1.2

func (a *Average) Reset()

func (*Average) String added in v0.1.2

func (a *Average) String() string

func (*Average) Value added in v0.1.2

func (a *Average) Value() float64

type InterAverage added in v0.1.9

type InterAverage interface {
	String() string

	Add(float64)
	Calc() float64
	Value() float64
	Qty() int
	Reset()
}

type InterIter added in v0.1.21

type InterIter interface {
	dIter.Inter

	Value() float64
	Count() int
	Reset()

	Clone() InterIter
}

type InterPeriodValues added in v0.1.9

type InterPeriodValues interface {
	Log(qty int)

	Filled() bool
	ToFill() int
	Values() []float64
	Periods() int

	Add(value float64)

	Fill(value float64) bool
	// DeepCopy() InterPeriodValues
	Mean() float64
	MeanStdDev() (mean, std float64)
	Sum() float64
}

type InterSmoothedAverage added in v0.1.9

type InterSmoothedAverage interface {
	String() string
	Log()

	Filled() bool
	Value() float64
	Periods() int

	AddPos(v float64)
	AddNeg(v float64)
}

type Iter added in v0.1.10

type Iter struct {
	sInts.InterIter
	// contains filtered or unexported fields
}

func NewIter added in v0.1.21

func NewIter(from, to, step float64, prec int, values ...float64) *Iter

func (*Iter) Clone added in v0.1.40

func (b *Iter) Clone() InterIter

func (*Iter) Log added in v0.1.21

func (b *Iter) Log(name string)

func (*Iter) Next added in v0.1.21

func (b *Iter) Next() bool

func (*Iter) Reset added in v0.1.10

func (b *Iter) Reset()

func (*Iter) String added in v0.1.21

func (b *Iter) String(name string) string

func (*Iter) Value added in v0.1.10

func (b *Iter) Value() float64

type Json added in v0.1.51

type Json struct {
	From   float64   `json:"from"`
	To     float64   `json:"to"`
	Step   float64   `json:"step"`
	Prec   int       `json:"prec"`
	Values []float64 `json:"values"`
}

func (Json) GetIter added in v0.1.51

func (jn Json) GetIter() *Iter

func (Json) IsZero added in v0.1.51

func (jn Json) IsZero() bool

type PeriodValues added in v0.1.2

type PeriodValues struct {
	// contains filtered or unexported fields
}

func NewPeriodValues added in v0.1.2

func NewPeriodValues(periods int) *PeriodValues

func (*PeriodValues) Add added in v0.1.2

func (pv *PeriodValues) Add(value float64)

func (*PeriodValues) DeepCopy added in v0.1.2

func (pv *PeriodValues) DeepCopy() *PeriodValues

func (*PeriodValues) Fill added in v0.1.2

func (pv *PeriodValues) Fill(value float64) bool

Fill adds a value to the PeriodValues if it is not filled yet and returns true. If the PeriodValues is already filled, it returns false. Fill inverse order of Add.

func (*PeriodValues) Filled added in v0.1.2

func (pv *PeriodValues) Filled() bool

func (*PeriodValues) Log added in v0.1.2

func (pv *PeriodValues) Log(qty int)

func (*PeriodValues) Mean added in v0.1.2

func (pv *PeriodValues) Mean() float64

func (*PeriodValues) MeanStdDev added in v0.1.3

func (pv *PeriodValues) MeanStdDev() (mean, std float64)

func (*PeriodValues) Periods added in v0.1.9

func (pv *PeriodValues) Periods() int

func (*PeriodValues) Sum added in v0.1.3

func (pv *PeriodValues) Sum() float64

func (*PeriodValues) ToFill added in v0.1.2

func (pv *PeriodValues) ToFill() int

func (*PeriodValues) Values added in v0.1.2

func (pv *PeriodValues) Values() []float64

type PeriodValuesMinMax added in v0.1.2

type PeriodValuesMinMax struct {
	*PeriodValues
	// contains filtered or unexported fields
}

func NewPeriodValuesMinMax added in v0.1.2

func NewPeriodValuesMinMax(periods int) *PeriodValuesMinMax

func (*PeriodValuesMinMax) Add added in v0.1.2

func (pv *PeriodValuesMinMax) Add(value float64)

func (*PeriodValuesMinMax) DeepCopy added in v0.1.2

func (pv *PeriodValuesMinMax) DeepCopy() *PeriodValuesMinMax

func (*PeriodValuesMinMax) Fill added in v0.1.2

func (pv *PeriodValuesMinMax) Fill(value float64) bool

func (*PeriodValuesMinMax) Log added in v0.1.2

func (pv *PeriodValuesMinMax) Log(qty int)

func (*PeriodValuesMinMax) Max added in v0.1.2

func (pv *PeriodValuesMinMax) Max() float64

func (*PeriodValuesMinMax) Min added in v0.1.2

func (pv *PeriodValuesMinMax) Min() float64

type SmoothedAverage added in v0.1.3

type SmoothedAverage struct {
	// contains filtered or unexported fields
}

func NewSmoothedAverage added in v0.1.3

func NewSmoothedAverage(periods int) *SmoothedAverage

func (*SmoothedAverage) AddNeg added in v0.1.3

func (sa *SmoothedAverage) AddNeg(v float64)

AddNeg subtracts a value from the average

func (*SmoothedAverage) AddPos added in v0.1.3

func (sa *SmoothedAverage) AddPos(v float64)

AddPos adds a value to the average

func (*SmoothedAverage) Filled added in v0.1.3

func (sa *SmoothedAverage) Filled() bool

func (*SmoothedAverage) Log added in v0.1.5

func (sa *SmoothedAverage) Log()

func (*SmoothedAverage) Periods added in v0.1.9

func (sa *SmoothedAverage) Periods() int

func (*SmoothedAverage) String added in v0.1.5

func (sa *SmoothedAverage) String() string

func (*SmoothedAverage) Value added in v0.1.3

func (sa *SmoothedAverage) Value() float64

Jump to

Keyboard shortcuts

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