Nengo.ca

ca.nengo.math.impl
Class FourierFunction

java.lang.Object
  extended by ca.nengo.math.impl.FourierFunction
All Implemented Interfaces:
Function, java.io.Serializable, java.lang.Cloneable

public class FourierFunction
extends java.lang.Object
implements Function

A Function that is composed of a finite number of sinusoids.

See Also:
Serialized Form

Constructor Summary
FourierFunction(float[][] frequencies, float[] amplitudes, float[][] phases)
          Creates an n-dimensional function composed of explicitly defined sinusoids.
FourierFunction(float[] frequencies, float[] amplitudes, float[] phases)
          Creates a 1-dimensional function composed of explicitly defined sinusoids.
FourierFunction(float fundamental, float cutoff, float rms, long seed)
          Creates a 1-dimensional band-limited pink noise function with specified parameters.
FourierFunction(float fundamental, float cutoff, float rms, long seed, int type)
          Creates a 1-dimensional band-limited noise function with specified parameters.
 
Method Summary
 Function clone()
           
 float[] getAmplitudes()
           
 int getComponents()
           
 float getCutoff()
           
 int getDimension()
           
 float[][] getFrequencies()
           
 float getFundamental()
           
 float[][] getPhases()
           
 float getRms()
           
 long getSeed()
           
 float map(float[] from)
           
 float[] multiMap(float[][] from)
           
 void setAmplitudes(float[] amplitudes)
           
 void setFrequencies(float[][] frequencies)
           
 void setPhases(float[][] phases)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FourierFunction

public FourierFunction(float[] frequencies,
                       float[] amplitudes,
                       float[] phases)
Creates a 1-dimensional function composed of explicitly defined sinusoids.

Parameters:
frequencies - Explicit list of frequencies of sinusoidal components of the function (Hz)
amplitudes - The amplitude of each component
phases - The phase lead of each component (from -.5 to .5)

FourierFunction

public FourierFunction(float[][] frequencies,
                       float[] amplitudes,
                       float[][] phases)
Creates an n-dimensional function composed of explicitly defined sinusoids.

Parameters:
frequencies - Lists of frequencies (length n; ith members define frequencies of ith component along each dimension)
amplitudes - The amplitude of each component
phases - Lists of phases (length n; ith members define phases of ith component along each dimension)

FourierFunction

public FourierFunction(float fundamental,
                       float cutoff,
                       float rms,
                       long seed,
                       int type)
Creates a 1-dimensional band-limited noise function with specified parameters.

Parameters:
fundamental - The fundamental frequency (Hz), i.e., frequency step size.
cutoff - The high-frequency limit (Hz)
rms - The root-mean-squared function amplitude
seed - Random seed
type - The type of noise: 0 = white; 1 = pink;

FourierFunction

public FourierFunction(float fundamental,
                       float cutoff,
                       float rms,
                       long seed)
Creates a 1-dimensional band-limited pink noise function with specified parameters.

Parameters:
fundamental - The fundamental frequency (Hz), i.e., frequency step size.
cutoff - The high-frequency limit (Hz)
rms - The root-mean-squared function amplitude
seed - Random seed
Method Detail

getDimension

public int getDimension()
Specified by:
getDimension in interface Function
Returns:
Dimension of the space that the Function maps from
See Also:
Function.getDimension()

getComponents

public int getComponents()
Returns:
Number of frequency components

getFrequencies

public float[][] getFrequencies()
Returns:
Lists of frequencies (length n; ith members define frequencies of ith component along each dimension)

setFrequencies

public void setFrequencies(float[][] frequencies)
Parameters:
frequencies - Lists of frequencies (length n; ith members define frequencies of ith component along each dimension)

getAmplitudes

public float[] getAmplitudes()
Returns:
The amplitude of each component

setAmplitudes

public void setAmplitudes(float[] amplitudes)
Parameters:
amplitudes - The amplitude of each component

getPhases

public float[][] getPhases()
Returns:
Lists of phases (length n; ith members define phases of ith component along each dimension)

setPhases

public void setPhases(float[][] phases)
Parameters:
phases - Lists of phases (length n; ith members define phases of ith component along each dimension)

map

public float map(float[] from)
Specified by:
map in interface Function
Parameters:
from - Must have same length as getDimension()
Returns:
result of function operation on arg
See Also:
Function.map(float[])

multiMap

public float[] multiMap(float[][] from)
Specified by:
multiMap in interface Function
Parameters:
from - An array of arguments; each element must have length getDimension().
Returns:
Array of results of function operation on each arg
See Also:
Function.multiMap(float[][])

getFundamental

public float getFundamental()
Returns:
The fundamental frequency used to generate the function if it was provided.

getCutoff

public float getCutoff()
Returns:
The cutoff frequency used to generate the function if it was provided.

getRms

public float getRms()
Returns:
The rms amplitude used to generate the function if it was provided.

getSeed

public long getSeed()
Returns:
The seed used to generate the function if it was provided.

clone

public Function clone()
               throws java.lang.CloneNotSupportedException
Specified by:
clone in interface Function
Overrides:
clone in class java.lang.Object
Returns:
Valid clone
Throws:
java.lang.CloneNotSupportedException - if clone can't be made

Nengo.ca