/** * This verifies that a code book constructed from a given set of * frequencies may be reconstructed from the cord word bit lengths, given in * a non-decreasing order, together with the symbols in a correlated array. * * @param frequency */ public void doRoundTripTest(final int[] frequency) { final DecoderInputs decoderInputs = new DecoderInputs(); final HuffmanCodec codec = new HuffmanCodec(frequency, decoderInputs); if (log.isDebugEnabled()) { log.debug(printCodeBook(codec.codeWords()) + "\nlength[]=" + Arrays.toString(decoderInputs.getLengths()) + "\nsymbol[]=" + Arrays.toString(decoderInputs.getSymbols())); } final CanonicalFast64CodeWordDecoder actualDecoder = new CanonicalFast64CodeWordDecoder( decoderInputs.getLengths(), decoderInputs.getSymbols()); for (int i = 0; i < frequency.length; i++) { final BooleanIterator coded = codec.coder().encode(i/*symbol*/); assertEquals(i, actualDecoder.decode(coded)); } }
/** * This verifies that a code book constructed from a given set of * frequencies may be reconstructed from the cord word bit lengths, given in * a non-decreasing order, together with the symbols in a correlated array. * * @param frequency */ public void doRoundTripTest(final int[] frequency) { final DecoderInputs decoderInputs = new DecoderInputs(); final HuffmanCodec codec = new HuffmanCodec(frequency, decoderInputs); if (log.isDebugEnabled()) { log.debug(printCodeBook(codec.codeWords()) + "\nlength[]=" + Arrays.toString(decoderInputs.getLengths()) + "\nsymbol[]=" + Arrays.toString(decoderInputs.getSymbols())); } final CanonicalFast64CodeWordDecoder actualDecoder = new CanonicalFast64CodeWordDecoder( decoderInputs.getLengths(), decoderInputs.getSymbols()); for (int i = 0; i < frequency.length; i++) { final BooleanIterator coded = codec.coder().encode(i/*symbol*/); assertEquals(i, actualDecoder.decode(coded)); } }
if (size == 1) codeWord[0] = LongArrayBitVector.getInstance(); coder = new Fast64CodeWordCoder(codeWord, new long[size]); decoder = new CanonicalFast64CodeWordDecoder(new int[size], new int[size]); return; decoder = new CanonicalFast64CodeWordDecoder(length, symbol);
this.decoder = new CanonicalFast64CodeWordDecoder( decoderInputs.getLengths(), decoderInputs .getSymbols());
this.decoder = new CanonicalFast64CodeWordDecoder( decoderInputs.getLengths(), decoderInputs .getSymbols());
decoderInputs.length = new int[size]; decoderInputs.symbol = new int[size]; decoder = new CanonicalFast64CodeWordDecoder( decoderInputs.length, decoderInputs.symbol ); return; + ", but length[0]=" + length[0]; decoder = new CanonicalFast64CodeWordDecoder( decoderInputs.length, decoderInputs.symbol);
decoderInputs.length = new int[size]; decoderInputs.symbol = new int[size]; decoder = new CanonicalFast64CodeWordDecoder( decoderInputs.length, decoderInputs.symbol ); return; + ", but length[0]=" + length[0]; decoder = new CanonicalFast64CodeWordDecoder( decoderInputs.length, decoderInputs.symbol);
final CanonicalFast64CodeWordDecoder actualDecoder = new CanonicalFast64CodeWordDecoder( decoderInputs.getLengths(), decoderInputs.getSymbols());
final CanonicalFast64CodeWordDecoder actualDecoder = new CanonicalFast64CodeWordDecoder( decoderInputs.getLengths(), decoderInputs.getSymbols());