utils

package
v0.0.0-...-adfcde9 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2023 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Identifier = iota
	// e.g. 50
	Literal
	// e.g. + - * /
	Operator
	// ,
	COMMA
)
View Source
const ExpDate = "12/31/2024"
View Source
const LicFile = "lic.json"

Variables

View Source
var Conf *viper.Viper
View Source
var Limit int = 1e7

Limit is an absolute limit on number of iterations.

Functions

func Dur

func Dur(x Date, y Date) int

func ErrPos

func ErrPos(s string, pos int) string

func GetFileList

func GetFileList(root string, suffix string) (paths []string, err error)

func GetFileName

func GetFileName(s string) string

func GetOutPath

func GetOutPath(s string) string

func GetPaths

func GetPaths(s string) string

func GetRedisClient

func GetRedisClient() *redis.Client

func GetUUID

func GetUUID() string

func Hide

func Hide(filename string) error

func InitializePath

func InitializePath(path string)

func IsDir

func IsDir(path string) bool

func LoadCsv

func LoadCsv[T any](fileName string, row T) []*T

func MapContainsValue

func MapContainsValue[K, V comparable](m map[K]V, value V) bool

func MapUniqValues

func MapUniqValues[T comparable](m map[string]T) []T

func MergeStringSlices

func MergeStringSlices(slices ...[]string) []string

func ParseCsvMap

func ParseCsvMap(filename string) (map[string][]string, error)

func PivotFloat64

func PivotFloat64(data any, tags []string, fieldsToSum []string) map[string]map[string]float64

func ReadConfig

func ReadConfig(c *viper.Viper)

func ReadProdSpecs

func ReadProdSpecs(filePath string) ([]string, map[string][]string)

func ReleaseVault

func ReleaseVault(fs *embed.FS) (path string)

func RemoveDup

func RemoveDup(this []*float64) []*float64

func ReplaceWholeWord

func ReplaceWholeWord(originalString string, oldWord string, newWord string) string

func SCA

func SCA(A [][]float64, b []float64, δ float64) (x []float64, i int, err error)

SCA solves the non-negative least squares problem.

Argument A represents a design or input matrix. Each element of A must have the same length. b represents a measurement or output vector. δ is a tolerance for the result.

Iteration will stop when the least squares objective is within δ of an optimal solution.

The result x returns coefficients of the fitted linear function, it will have the same length as elements of A. Result i is the number of iterations performed. An error is returned if A and b are not the same length.

func SCAKKT

func SCAKKT(A [][]float64, b []float64, ε float64) ([]float64, int, error)

SCAKKT solves the non-negative least squares problem.

Argument A represents a design or input matrix. Each element of A must have the same length. b represents a measurement or output vector. ε is a tolerance for stopping iteration.

Stopping criteria for this function are based on Karush–Kuhn–Tucker conditions (see https://en.wikipedia.org/wiki/Karush%E2%80%93Kuhn%E2%80%93Tucker_conditions). Iteration stops when a result is non-negative and the gradient of the objective function is within ε of KKT conditions. The advantage of this function over SCA is that stopping conditions are simpler to compute and so each iteration takes less time. The disadvantage is that the ε of this function is less obviously related to the objective function and stopping criteria are less clear.

The result x returns coefficients of the fitted linear function, it will have the same length as elements of A. Result i is the number of iterations performed. An error is returned if A and b are not the same length.

func SCALimit

func SCALimit(A [][]float64, b []float64, limit int) ([]float64, int, error)

SCALimit solves the non-negative least squares problem.

Argument A represents a design or input matrix. Each element of A must have the same length. b represents a measurement or output vector. limit is a maximum number of iterations.

Iteration will stops after limit iterations or when the result does not change from one iteration to the next. If argument limit is < 0, the package value Limit is used.

The result x returns coefficients of the fitted linear function, it will have the same length as elements of A. Result i is the number of iterations performed. An error is returned if A and b are not the same length.

func SetLogOutput

func SetLogOutput()

func StringExists

func StringExists(s []string, t string) bool

func ValidLicense

func ValidLicense(vaultPath string) bool

func WriteCsv

func WriteCsv(start, end Date, res ProjResult)

Types

type Date

type Date struct {
	Year  int
	Month int
}

func (Date) CalendarDate

func (this Date) CalendarDate(i int) Date

func (Date) CalendarMth

func (this Date) CalendarMth(t int) (res int)

func (Date) CalendarYr

func (this Date) CalendarYr(t int) (res int)

func (Date) DateStr

func (this Date) DateStr() (res string)

func (Date) DateValue

func (this Date) DateValue() (res int)

func (Date) T

func (this Date) T(Year, Month int) int

type FormulaParserRun

type FormulaParserRun struct {
	Name    string
	PrdFile string
	LibFile string
}

func GetFormulaParserRuns

func GetFormulaParserRuns() []FormulaParserRun

type FsCloner

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

embeded FS to release dll

func New

func New(fs *embed.FS, name, dist string) *FsCloner

func (*FsCloner) Clone

func (c *FsCloner) Clone() error

type Parser

type Parser struct {
	Source string
	// contains filtered or unexported fields
}

type ProjResult

type ProjResult struct {
	VarName string
	Res     []float64
}

type Token

type Token struct {
	// raw characters
	Tok string
	// type with Literal/Operator
	Type,
	Flag int
	Offset int
}

func Parse

func Parse(s string) ([]*Token, error)

type User

type User struct {
	Name string `json:"Name"`
	UUID string `json:"UUID"`
}

Jump to

Keyboard shortcuts

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