Package pl.mkaczara.bch.encoder.worker

Source Code of pl.mkaczara.bch.encoder.worker.BCHEncoderWorker

package pl.mkaczara.bch.encoder.worker;

import java.util.concurrent.Callable;
import pl.mkaczara.bch.math.BinMonomial;
import pl.mkaczara.bch.math.BinPolynomial;
import pl.mkaczara.bch.code.CyclicCode;

/**
* Klasa obiektow, reprezentujacych workery kodera kodu BCH
*
* @author Kuba
*/
public class BCHEncoderWorker implements Callable<BinPolynomial>{
    /**
     * Wielomian wejsciowy
     */
    private BinPolynomial input;
    /**
     * Kod
     */
    private CyclicCode code;

    /**
     * Tworzy obiekt kodera BCH
     *
     * @param code kod
     */
    public BCHEncoderWorker(CyclicCode code) {
        this.code = code;
    }

    /**
     * Koduje informacje
     *
     * @param input wielomian informacji
     * @return wielomian slowa kodowego
     */
    public BinPolynomial encode(BinPolynomial input){
        input = input.multiplyByMonomial(new BinMonomial(code.getN() - code.getK()));
        BinPolynomial rx = input.modulo(code.getGenerator());
        input = input.add(rx);
        return input;
    }
   
    @Override
    public BinPolynomial call() throws Exception {
        if(null == input){
            throw new IllegalStateException("No input data given!");
        }
        return encode(input);
    }

    public BinPolynomial getInput() {
        return input;
    }

    public void setInput(BinPolynomial input) {
        this.input = input;
    }
} // end BCHEncoderWorker
TOP

Related Classes of pl.mkaczara.bch.encoder.worker.BCHEncoderWorker

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.