List of usage examples for org.apache.commons.math3.transform TransformUtils scaleArray
public static Complex[] scaleArray(Complex[] f, double d)
From source file:experiment.FastCosineTransformer_bug.java
/** * {@inheritDoc}//from ww w .ja v a2 s. c o m * * @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); }
From source file:experiment.FastSineTransformer_bug.java
/** * {@inheritDoc}// w w w . ja va 2s. c o m * * The first element of the specified data set is required to be {@code 0}. * * @throws MathIllegalArgumentException if the length of the data array is * not a power of two, or the first element of the data array is not zero */ public double[] transform(final double[] f, final TransformType type) { if (normalization == DstNormalization.ORTHOGONAL_DST_I) { final double s = FastMath.sqrt(2.0 / f.length); return TransformUtils.scaleArray(fst(f), s); } if (type == TransformType.FORWARD) { return fst(f); } final double s = 2.0 / f.length; return TransformUtils.scaleArray(fst(f), s); }