Example usage for org.apache.commons.math3.transform DctNormalization ORTHOGONAL_DCT_I

List of usage examples for org.apache.commons.math3.transform DctNormalization ORTHOGONAL_DCT_I

Introduction

In this page you can find the example usage for org.apache.commons.math3.transform DctNormalization ORTHOGONAL_DCT_I.

Prototype

DctNormalization ORTHOGONAL_DCT_I

To view the source code for org.apache.commons.math3.transform DctNormalization ORTHOGONAL_DCT_I.

Click Source Link

Document

Should be passed to the constructor of FastCosineTransformer to use the orthogonal normalization convention.

Usage

From source file:experiment.FastCosineTransformer_bug.java

/**
 * {@inheritDoc}/*from   w  w w  .  jav  a  2s.c  om*/
 *
 * @throws MathIllegalArgumentException if the length of the data array is
 * not a power of two plus one
 */
public double[] transform(final double[] f, final TransformType type) throws MathIllegalArgumentException {
    if (type == TransformType.FORWARD) {
        if (normalization == DctNormalization.ORTHOGONAL_DCT_I) {
            final double s = FastMath.sqrt(2.0 / (f.length - 1));
            return TransformUtils.scaleArray(fct(f), s);
        }
        return fct(f);
    }
    final double s2 = 2.0 / (f.length - 1);
    final double s1;
    if (normalization == DctNormalization.ORTHOGONAL_DCT_I) {
        s1 = FastMath.sqrt(s2);
    } else {
        s1 = s2;
    }
    return TransformUtils.scaleArray(fct(f), s1);
}