calculate

package
v0.0.0-...-67c439a Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2023 License: Unlicense Imports: 7 Imported by: 0

Documentation

Overview

Package calculate provides convenient functions to help perform various repetitive calculations. It is meant to be used by the top level package inside compositional algos (ie. Algo1.)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LinearScale

func LinearScale(value float64, r MinMax, t MinMax) float64

LinearScale (value - r.Min) / (r.Max - r.Min) * (t.Max - t.Min) + t.Min.

func SineGeneration

func SineGeneration(f *audio.Format, opts SineOptions) audio.PCMBuffer

SineGeneration generates a sine wave according to the parameters provided. It returns an audio.PCMBuffer loaded with the generated sine wave as 32bit floating point slice []F32. The math package used to calculate the sine wave is github.com/chewxy/math32. If f is nil it returns an empty audio.PCMbuffer{}.

Types

type MinMax

type MinMax struct {
	// Min is the minimum value found in a network analysis.
	Min float64
	// Max is the maximum value found in a network analysis.
	Max float64
}

MinMax is a structure that holds the minimum and maximum of something. It is used to hold the min/max range of the various calculations done to graphs as it is needed when we need to scale things (see calculate.LinearScale().)

type NetworkAnalysis

type NetworkAnalysis struct {
	// NodeValue is a map holding all maps that network analysis ran against.
	NodeValue map[NetworkOption]map[int64]float64
	// MM is min/max values coming from network analysis of the graph.
	MM map[NetworkOption]MinMax
	// contains filtered or unexported fields
}

NetworkAnalysis holds all data to run a network analysis against a graph.

func GraphNetwork

GraphNetwork runs the provided network analysis opts, against the graph g. If no options are provided all available analysis will run.

type NetworkOption

type NetworkOption int

NetworkOption is a custom type around the various network calculations we need to perform.

const (
	// Betweenness centrality is a measure of centrality in a graph based on shortest paths.
	Betweenness NetworkOption = iota
	// BetweennessWeighted centrality is a measure of centrality in a graph based on shortest paths.
	BetweennessWeighted
	// Closeness is a measure of centrality in a network, calculated as the reciprocal of the sum of the length of the shortest paths between the node and all other nodes in the graph.
	Closeness
	// Farness is the opposite of Closeness.
	Farness
	// Harmonic Closeness.
	Harmonic
	// Residual Closeness.
	Residual
)

type SineOptions

type SineOptions struct {
	// Freq is the frequency of the sine wave.
	Freq float32
	// Amp is the amplitude of the sine wave.
	Amp float32
	// A, D, R represents the attack, decay, release times in milliseconds.
	A, D, R float64
}

SineOptions hold the frequency, amplitude, and attack, decay, release information.

Jump to

Keyboard shortcuts

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