encode(toEncode, ecBytes /*int*/) {
        if (ecBytes === 0) {
            throw new IllegalArgumentException('No error correction bytes');
        }
        const dataBytes = toEncode.length - ecBytes;
        if (dataBytes <= 0) {
            throw new IllegalArgumentException('No data bytes provided');
        }
        const generator = this.buildGenerator(ecBytes);
        const infoCoefficients = new Int32Array(dataBytes);
        System.arraycopy(toEncode, 0, infoCoefficients, 0, dataBytes);
        let info = new GenericGFPoly(this.field, infoCoefficients);
        info = info.multiplyByMonomial(ecBytes, 1);
        const remainder = info.divide(generator)[1];
        const coefficients = remainder.getCoefficients();
        const numZeroCoefficients = ecBytes - coefficients.length;
        for (let i = 0; i < numZeroCoefficients; i++) {
            toEncode[dataBytes + i] = 0;
        }
        System.arraycopy(coefficients, 0, toEncode, dataBytes + numZeroCoefficients, coefficients.length);
    }
/**
     * <p>Encode a sequence of code words (symbols) using Reed-Solomon to allow decoders
     * to detect and correct errors that may have been introduced when the resulting
     * data is stored or transmitted.</p>
     *
     * @param toEncode array used for both and output. Caller initializes the array with
     * the code words (symbols) to be encoded followed by empty elements allocated to make
     * space for error-correction code words in the encoded output. The array contains
     * the encdoded output when encode returns. Code words are encoded as numbers from
     * 0 to n-1, where n is the number of possible code words (symbols), as determined
     * by the size of the Galois Field passed in the constructor of this object.
     * @param ecBytes the number of elements reserved in the array (first parameter)
     * to store error-correction code words. Thus, the number of code words (symbols)
     * to encode in the first parameter is thus toEncode.length - ecBytes.
     * Note, the use of "bytes" in the name of this parameter is misleading, as there may
     * be more or fewer than 256 symbols being encoded, as determined by the number of
     * elements in the Galois Field passed as a constructor to this object.
     * @throws IllegalArgumentException thrown in response to validation errros.
     */
Encode a sequence of code words (symbols) using Reed-Solomon to allow decoders
to detect and correct errors that may have been introduced when the resulting
data is stored or transmitted.

@param toEncode array used for both and output. Caller initializes the array with
the code words (symbols) to be encoded followed by empty elements allocated to make
space for error-correction code words in the encoded output. The array contains
the encdoded output when encode returns. Code words are encoded as numbers from
0 to n-1, where n is the number of possible code words (symbols), as determined
by the size of the Galois Field passed in the constructor of this object.
@param ecBytes the number of elements reserved in the array (first parameter)
to store error-correction code words. Thus, the number of code words (symbols)
to encode in the first parameter is thus toEncode.length - ecBytes.
Note, the use of "bytes" in the name of this parameter is misleading, as there may
be more or fewer than 256 symbols being encoded, as determined by the number of
elements in the Galois Field passed as a constructor to this object.
@throws IllegalArgumentException thrown in response to validation errros.
Encode a sequence of code words ( symbols ) using Reed - Solomon to allow decoders to detect and correct errors that may have been introduced when the resulting data is stored or transmitted . @param toEncode array used for both and output . Caller initializes the array with the code words ( symbols ) to be encoded followed by empty elements allocated to make space for error - correction code words in the encoded output . The array contains the encdoded output when encode returns . Code words are encoded as numbers from 0 to n - 1 where n is the number of possible code words ( symbols ) as determined by the size of the Galois Field passed in the constructor of this object . @param ecBytes the number of elements reserved in the array ( first parameter ) to store error - correction code words . Thus the number of code words ( symbols ) to encode in the first parameter is thus toEncode . length - ecBytes . Note the use of " bytes " in the name of this parameter is misleading as there may be more or fewer than 256 symbols being encoded as determined by the number of elements in the Galois Field passed as a constructor to this object . @throws IllegalArgumentException thrown in response to validation errros .
encode(toEncode, ecBytes ) {
        if (ecBytes === 0) {
            throw new IllegalArgumentException('No error correction bytes');
        }
        const dataBytes = toEncode.length - ecBytes;
        if (dataBytes <= 0) {
            throw new IllegalArgumentException('No data bytes provided');
        }
        const generator = this.buildGenerator(ecBytes);
        const infoCoefficients = new Int32Array(dataBytes);
        System.arraycopy(toEncode, 0, infoCoefficients, 0, dataBytes);
        let info = new GenericGFPoly(this.field, infoCoefficients);
        info = info.multiplyByMonomial(ecBytes, 1);
        const remainder = info.divide(generator)[1];
        const coefficients = remainder.getCoefficients();
        const numZeroCoefficients = ecBytes - coefficients.length;
        for (let i = 0; i < numZeroCoefficients; i++) {
            toEncode[dataBytes + i] = 0;
        }
        System.arraycopy(coefficients, 0, toEncode, dataBytes + numZeroCoefficients, coefficients.length);
    }
encode ( toEncode , ecBytes ) { if ( ecBytes === 0 ) { throw new IllegalArgumentException ( 'No error correction bytes' ) ; } const dataBytes = toEncode . length - ecBytes ; if ( dataBytes <= 0 ) { throw new IllegalArgumentException ( 'No data bytes provided' ) ; } const generator = this . buildGenerator ( ecBytes ) ; const infoCoefficients = new Int32Array ( dataBytes ) ; System . arraycopy ( toEncode , 0 , infoCoefficients , 0 , dataBytes ) ; let info = new GenericGFPoly ( this . field , infoCoefficients ) ; info = info . multiplyByMonomial ( ecBytes , 1 ) ; const remainder = info . divide ( generator ) [ 1 ] ; const coefficients = remainder . getCoefficients ( ) ; const numZeroCoefficients = ecBytes - coefficients . length ; for ( let i = 0 ; i < numZeroCoefficients ; i ++ ) { toEncode [ dataBytes + i ] = 0 ; } System . arraycopy ( coefficients , 0 , toEncode , dataBytes + numZeroCoefficients , coefficients . length ) ; }
<p>Encode a sequence of code words (symbols) using Reed-Solomon to allow decoders
 to detect and correct errors that may have been introduced when the resulting
 data is stored or transmitted.</p>
<p > Encode a sequence of code words ( symbols ) using Reed - Solomon to allow decoders to detect and correct errors that may have been introduced when the resulting data is stored or transmitted . < / p >
/*int*/