Documentation ¶
Index ¶
- func Blur(data MutableSlice, domainSize []int, kernel BlurKernel)
- func Clear(data []complex128)
- func CmplxEqualApprox(a []complex128, b []complex128, tol float64) bool
- func DivRealScalar(data []complex128, factor float64) []complex128
- func Dot(a []float64, b []float64) float64
- func Draw(shape Shape, grid *Grid, transformation *Affine, value float64)
- func ElemwiseAdd(dst []complex128, data []complex128)
- func ElemwiseMul(dst []complex128, data []complex128)
- func MaxReal(data []complex128) float64
- func MinReal(data []complex128) float64
- func NodeIdx(domainSize []int, idx []int) int
- func Pos(domainSize []int, nodeNum int) []int
- func ProdInt(a []int) int
- func Voronoi(pts []int, data []int, domainSize []int)
- func Wrap(pos []int, domainSize []int)
- type Affine
- type Ball
- type BlurKernel
- type BoundingBox
- type Box
- type BoxKernel
- type FFTWWrapper
- type Grid
- func (g Grid) Copy() Grid
- func (g *Grid) FromComplex(carray []complex128)
- func (g Grid) Get(pos []int) float64
- func (g Grid) Index(pos []int) int
- func (g Grid) Pos(i int) []int
- func (g *Grid) Rotate2D(angle float64)
- func (g Grid) SaveCsv(fname string)
- func (g *Grid) Set(pos []int, value float64)
- func (g Grid) ToComplex() []complex128
- type ImmutableSlice
- type MutableSlice
- type Product
- type RealPartSlice
- type RealSlice
- type Shape
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Blur ¶
func Blur(data MutableSlice, domainSize []int, kernel BlurKernel)
Blur applies a blurring kernel to the data. domainSize specifies the size of the domain in each direction. Thus, if domain size is []int{5, 5}, the length of data must be 25 and it is assumed that it represents a 5x5 domain. kernel is a blurring kernel.
func CmplxEqualApprox ¶
func CmplxEqualApprox(a []complex128, b []complex128, tol float64) bool
CmplxEqualApprox returns true if to complex arrays are equal within the passed tolerance
func DivRealScalar ¶
func DivRealScalar(data []complex128, factor float64) []complex128
DivRealScalar divides each element in the comlex array by a real scalar
func Draw ¶
Draw draws the shape onto the passed grid. The passed transfformations is applied to the shape prior to drawing. Note that the transformation is applied to the pixel position in the destination image. If a point is inside the passed shape, the value of that grid point will be set to value
func ElemwiseAdd ¶
func ElemwiseAdd(dst []complex128, data []complex128)
ElemwiseAdd adds dst and data and places the result in dst
func ElemwiseMul ¶
func ElemwiseMul(dst []complex128, data []complex128)
ElemwiseMul multiplies dst and data and places the result in dst.
Types ¶
type Affine ¶
Affine is a type used to represent affine transformations. The transformation itself is stored as a 4x4 matrix
func RotX ¶
RotX returns the rotation transformation corresponding to a rotation about th x-axis c = cos angle, s = sin angle ** ** * 1 0 0 * * 0 c -s * * 0 s c * ** **
func RotY ¶
RotY the rotation transformation an angle about the y-axis c = cos angle, s = sin angle ** ** * c 0 s * * 0 1 0 * * -s 0 c * ** **
func RotZ ¶
RotZ returns the rotation transformation corresonding to rotation about the z-axis by an angle alpha. c = cos alpha, s = sin alpha, the matrix is ** ** * c -s 0 * * s c 0 * * 0 0 1 * ** **
func Translation ¶
Translation initializes a new translation transformation
type Ball ¶
type Ball struct {
Radius float64
}
Ball represents a ball in n dimensions. In 2D this is a circle and in 3D this is a sphere
func (*Ball) InteriorPoint ¶
InteriorPoint returns true if the passed point is inside the ball
type BlurKernel ¶
type BlurKernel interface { // Value returns the value of the kernel Value(x []int) float64 // Cutoff returns a value beyond which the kernel is zero // (e.g. the kernel is assumed to be zero outisde the box // -Cutoff() < x < Cutoff() ) Cutoff() int }
BlurKernel is an interfae for kernel functions used for blurring
type BoundingBox ¶
BoundingBox represents the bounding box for the shape
type Box ¶
type Box struct {
Diagonal []float64
}
Box represents a rectangle in 2D and a box in 3D
func (*Box) InteriorPoint ¶
InteriorPoint returns true if the passed point is inside the box
type BoxKernel ¶
type BoxKernel struct {
Width int
}
BoxKernel returns a blurring kernel that is 1 inside a box and zero outside
type FFTWWrapper ¶
FFTWWrapper implemente the FourierTransform interface
func (*FFTWWrapper) ConjugateNode ¶
func (fw *FFTWWrapper) ConjugateNode(i int) int
ConjugateNode returns the node that corresponds to the negative frequency of the node being passed
func (*FFTWWrapper) FFT ¶
func (fw *FFTWWrapper) FFT(data []complex128) []complex128
FFT performs forward fourier transform
func (*FFTWWrapper) Freq ¶
func (fw *FFTWWrapper) Freq(i int) []float64
Freq returns the frequency corresponding to site i
func (*FFTWWrapper) IFFT ¶
func (fw *FFTWWrapper) IFFT(data []complex128) []complex128
IFFT performs inferse fourier transform
type Grid ¶
Grid is a type that represents a computatoinal grid
func (*Grid) FromComplex ¶
func (g *Grid) FromComplex(carray []complex128)
FromComplex extracts the real part of a complex array
func (*Grid) Rotate2D ¶
Rotate2D rotates 2D grids about the center. Angle is the rotation angle in radians.
func (Grid) SaveCsv ¶
SaveCsv stores the grid in a text file format. The format of the produced file is 1. For 2D grids x, y, value 2. For 3D grids x, y, z, value
func (Grid) ToComplex ¶
func (g Grid) ToComplex() []complex128
ToComplex converts the underlying data array to a complex array. The data is inserted as the real part and the imaginary part is zero.
type ImmutableSlice ¶
ImmutableSlice is a type for wrapping slices that can be accessed, but not altered slices
type MutableSlice ¶
type MutableSlice interface { ImmutableSlice Set(i int, v float64) }
MutableSlice is an interface for slice wrapeprs where the underlying data array can be both accessed and altered
type Product ¶
Product implements a generic product. It can be used to loop over all combinations Example: The following is equivalent to a double for loo from 0 to 3
prod := NewProduct([]{3, 3})
for idx := prod.Current; prod.Next() != nil; idx = prod.Current { Do something }
type RealPartSlice ¶
type RealPartSlice struct {
Data []complex128
}
RealPartSlice implements the MutableSlice interface. It only operates on the real part of the underlying complex array
func (*RealPartSlice) Get ¶
func (rps *RealPartSlice) Get(i int) float64
Get returns the value at position i
func (*RealPartSlice) Len ¶
func (rps *RealPartSlice) Len() int
Len returns the length of the underlying data array
func (*RealPartSlice) Set ¶
func (rps *RealPartSlice) Set(i int, v float64)
Set sets the real part at position i to the new value
type RealSlice ¶
type RealSlice struct {
Data []float64
}
RealSlice implements the MutableSlice interface when the underlying data is a real array
type Shape ¶
type Shape interface { // InteriorPoint returns true if the passed point is inside the shape InteriorPoint(pos []float64) bool // BBox returns the bounding box of the shape BBox() BoundingBox }
Shape is represents a generic interface to represent geometrical shapes