Documentation
¶
Index ¶
- func FFT(inAny any, dest []complex128) []complex128
- func Freq(n int, samplingFreq float64) []float64
- func IFFT(inAny any, dest []complex128) []complex128
- func Mag(in []complex128, dest []float64) []float64
- func Norm(in []complex128)
- func NormOrtho(in []complex128)
- func NumberSliceToComplexSlice(inAny any) []complex128
- func TrimFirstN[T any](c *Controller, inChannel chan []T, n int) chan []T
- type ComplexNumber
- type Controller
- type Number
- type RealNumber
- type Wire
- func Add[T Number](c *Controller, inputs ...*Wire[T]) *Wire[T]
- func Complex128ToFloat64(c *Controller, inWire *Wire[complex128]) *Wire[float64]
- func Divide[T Number](c *Controller, inputs ...*Wire[T]) *Wire[T]
- func GenericProcessingBlock_1In_1Out[T, U any](c *Controller, operation func([]T) []U, inWires ...*Wire[T]) *Wire[U]
- func GenericProcessingBlock_NIn_1Out[T, U any](c *Controller, operation func([][]T) []U, inWires ...*Wire[T]) *Wire[U]
- func GenericProcessingBlock_NIn_MOut[T, U any](c *Controller, operation func([][]T) [][]U, outputCount int, ...) []*Wire[U]
- func Multiply[T Number](c *Controller, inputs ...*Wire[T]) *Wire[T]
- func RealToComplex128[T RealNumber](c *Controller, inWire *Wire[T]) *Wire[complex128]
- func RealToFloat64[T RealNumber](c *Controller, inWire *Wire[T]) *Wire[float64]
- func SrcComplexFrequency(c *Controller, frequencyHz float64, startPhaseRad float64) *Wire[complex128]
- func SrcCosine(c *Controller, frequencyHz float64, startPhaseRad float64) *Wire[float64]
- func SrcSine(c *Controller, frequencyHz float64, startPhaseRad float64) *Wire[float64]
- func Subtract[T Number](c *Controller, inputs ...*Wire[T]) *Wire[T]
- type WireEnd
- type WireSource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FFT ¶
func FFT(inAny any, dest []complex128) []complex128
Coefficients computes the Fourier coefficients of a complex input sequence, converting the time series in seq into the frequency spectrum, placing the result in dst and returning it. This transform is unnormalized; a call to Coefficients followed by a call of Sequence will multiply the input sequence by the length of the sequence.
If the length of seq is not t.Len(), Coefficients will panic. If dst is nil, a new slice is allocated and returned. If dst is not nil and the length of dst does not equal the length of seq, Coefficients will panic. It is safe to use the same slice for dst and seq.
func IFFT ¶
func IFFT(inAny any, dest []complex128) []complex128
Sequence computes the complex periodic sequence from the Fourier coefficients, converting the frequency spectrum in coeff into a time series, placing the result in dst and returning it. This transform is unnormalized; a call to Coefficients followed by a call of Sequence will multiply the input sequence by the length of the sequence.
If the length of coeff is not t.Len(), Sequence will panic. If dst is nil, a new slice is allocated and returned. If dst is not nil and the length of dst does not equal the length of coeff, Sequence will panic. It is safe to use the same slice for dst and coeff.
func Mag ¶
func Mag(in []complex128, dest []float64) []float64
func NumberSliceToComplexSlice ¶
func NumberSliceToComplexSlice(inAny any) []complex128
func TrimFirstN ¶
func TrimFirstN[T any](c *Controller, inChannel chan []T, n int) chan []T
Types ¶
type ComplexNumber ¶
type ComplexNumber interface {
complex64 | complex128
}
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
func NewController ¶
func NewController(blockSize, channelDepth int, timeStepSec float64) *Controller
func (*Controller) BlockSize ¶
func (s *Controller) BlockSize() int
func (*Controller) Start ¶
func (s *Controller) Start()
func (*Controller) Stop ¶
func (s *Controller) Stop()
func (*Controller) TimeStepSec ¶
func (s *Controller) TimeStepSec() float64
func (*Controller) WaitForStart ¶
func (s *Controller) WaitForStart()
type Number ¶
type Number interface {
RealNumber | ComplexNumber
}
type RealNumber ¶
type Wire ¶
type Wire[T any] struct { // contains filtered or unexported fields }
func Add ¶
func Add[T Number](c *Controller, inputs ...*Wire[T]) *Wire[T]
y = x[0] + x[1] + x[2] + ...
func Complex128ToFloat64 ¶
func Complex128ToFloat64(c *Controller, inWire *Wire[complex128]) *Wire[float64]
func Divide ¶
func Divide[T Number](c *Controller, inputs ...*Wire[T]) *Wire[T]
y = x[0] / x[1] / x[2] / ...
func GenericProcessingBlock_1In_1Out ¶
func GenericProcessingBlock_1In_1Out[T, U any](c *Controller, operation func([]T) []U, inWires ...*Wire[T]) *Wire[U]
func GenericProcessingBlock_NIn_1Out ¶
func GenericProcessingBlock_NIn_1Out[T, U any](c *Controller, operation func([][]T) []U, inWires ...*Wire[T]) *Wire[U]
func GenericProcessingBlock_NIn_MOut ¶
func GenericProcessingBlock_NIn_MOut[T, U any](c *Controller, operation func([][]T) [][]U, outputCount int, inWires ...*Wire[T]) []*Wire[U]
func Multiply ¶
func Multiply[T Number](c *Controller, inputs ...*Wire[T]) *Wire[T]
y = x[0] * x[1] * x[2] * ...
func RealToComplex128 ¶
func RealToComplex128[T RealNumber](c *Controller, inWire *Wire[T]) *Wire[complex128]
func RealToFloat64 ¶
func RealToFloat64[T RealNumber](c *Controller, inWire *Wire[T]) *Wire[float64]
func SrcComplexFrequency ¶
func SrcComplexFrequency(c *Controller, frequencyHz float64, startPhaseRad float64) *Wire[complex128]
func SrcCosine ¶
func SrcCosine(c *Controller, frequencyHz float64, startPhaseRad float64) *Wire[float64]
func SrcSine ¶
func SrcSine(c *Controller, frequencyHz float64, startPhaseRad float64) *Wire[float64]
func Subtract ¶
func Subtract[T Number](c *Controller, inputs ...*Wire[T]) *Wire[T]
y = x[0] - x[1] - x[2] - x[3] - ...
func (*Wire[T]) NewWireEnd ¶
type WireEnd ¶
type WireEnd[T any] struct { // contains filtered or unexported fields }
func (*WireEnd[T]) Disconnect ¶
func (s *WireEnd[T]) Disconnect()
type WireSource ¶
type WireSource[T any] struct { // contains filtered or unexported fields }
func NewWire ¶
func NewWire[T any](bufferSize int) *WireSource[T]
Creates a new DataBus of any given type and start it running.
func (*WireSource[T]) GetWire ¶
func (s *WireSource[T]) GetWire() *Wire[T]
func (*WireSource[T]) Publish ¶
func (s *WireSource[T]) Publish(msg []T)
func (*WireSource[T]) Stop ¶
func (s *WireSource[T]) Stop()
Stop the DataBus. Only call this once. All subscriptions will be closed
func (*WireSource[T]) Subscribe ¶
func (s *WireSource[T]) Subscribe() chan []T
Subscribe to the DataBus. Messages can be received on the returned channel.
func (*WireSource[T]) Unsubscribe ¶
func (s *WireSource[T]) Unsubscribe(msgCh chan []T)
Unsubscribe from the DataBus. The reference to the channel can be safely discarded after calling this.