Search in sources :

Example 6 with Complex

use of org.apache.commons.math3.complex.Complex in project opennars by opennars.

the class SpectrumChart method update.

protected void update() {
    TreeMLData chart = data.get(0);
    float length = chart.getEnd() - chart.getStart();
    ;
    int numWindows = (int) Math.ceil(length / windowSize);
    // TODO dont remove existing windows
    windows.clear();
    int t = 0;
    for (int w = 0; w < numWindows; w++) {
        final int vl = windowSize;
        double[] input = new double[vl];
        for (int i = 0; i < vl; i++) {
            input[i] = (float) chart.getData(t++);
        }
        Complex[] c = fft.transform(input, TransformType.FORWARD);
        // phase = atan2( imaginary , real )
        // magnitude = sqrt( real<sup>2</sup> + imaginary<sup>2</sup> )
        windows.add(new Window(c));
    }
}
Also used : TreeMLData(automenta.vivisect.TreeMLData) Complex(org.apache.commons.math3.complex.Complex)

Aggregations

Complex (org.apache.commons.math3.complex.Complex)3 RealMatrix (org.apache.commons.math3.linear.RealMatrix)2 DenseMatrix (org.apache.spark.mllib.linalg.DenseMatrix)2 Matrix (org.apache.spark.mllib.linalg.Matrix)2 RowMatrix (org.apache.spark.mllib.linalg.distributed.RowMatrix)2 ReadCountCollection (org.broadinstitute.hellbender.tools.exome.ReadCountCollection)2 TreeMLData (automenta.vivisect.TreeMLData)1 FftGenerator (com.serotonin.m2m2.view.quantize2.FftGenerator)1 IOException (java.io.IOException)1 EigenDecomposition (org.apache.commons.math3.linear.EigenDecomposition)1 DateTime (org.joda.time.DateTime)1 Test (org.junit.Test)1