GenericGFPoly.java revision 7e3fa36d69ffee874dd364b8e3d9aa3cab9a273b
/*
* Copyright 2007 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* <p>Represents a polynomial whose coefficients are elements of a GF.
* Instances of this class are immutable.</p>
*
* <p>Much credit is due to William Rucklidge since portions of this code are an indirect
* port of his C++ Reed-Solomon implementation.</p>
*
* @author Sean Owen
*/
final class GenericGFPoly {
private final int[] coefficients;
/**
* @param field the {@link GenericGF} instance representing the field to use
* to perform computations
* @param coefficients coefficients as ints representing elements of GF(size), arranged
* from most significant (highest-power term) coefficient to least significant
* @throws IllegalArgumentException if argument is null or empty,
* or if leading coefficient is 0 and this is not a
* constant polynomial (that is, it is not the monomial "0")
*/
throw new IllegalArgumentException();
}
// Leading term must be non-zero for anything except the constant polynomial "0"
int firstNonZero = 1;
firstNonZero++;
}
if (firstNonZero == coefficientsLength) {
} else {
this.coefficients,
0,
this.coefficients.length);
}
} else {
this.coefficients = coefficients;
}
}
int[] getCoefficients() {
return coefficients;
}
/**
* @return degree of this polynomial
*/
int getDegree() {
}
/**
* @return true iff this polynomial is the monomial "0"
*/
boolean isZero() {
}
/**
* @return coefficient of x^degree term in this polynomial
*/
int getCoefficient(int degree) {
}
/**
* @return evaluation of this polynomial at a given point
*/
int evaluateAt(int a) {
if (a == 0) {
// Just return the x^0 coefficient
return getCoefficient(0);
}
if (a == 1) {
// Just the sum of the coefficients
int result = 0;
for (int coefficient : coefficients) {
}
return result;
}
for (int i = 1; i < size; i++) {
}
return result;
}
throw new IllegalArgumentException("GenericGFPolys do not have same GenericGF field");
}
if (isZero()) {
return other;
}
return this;
}
int[] smallerCoefficients = this.coefficients;
int[] temp = smallerCoefficients;
}
// Copy high-order terms only found in higher-degree polynomial's coefficients
}
}
throw new IllegalArgumentException("GenericGFPolys do not have same GenericGF field");
}
}
int[] aCoefficients = this.coefficients;
for (int i = 0; i < aLength; i++) {
int aCoeff = aCoefficients[i];
for (int j = 0; j < bLength; j++) {
}
}
}
if (scalar == 0) {
}
if (scalar == 1) {
return this;
}
for (int i = 0; i < size; i++) {
}
}
if (degree < 0) {
throw new IllegalArgumentException();
}
if (coefficient == 0) {
}
for (int i = 0; i < size; i++) {
}
}
throw new IllegalArgumentException("GenericGFPolys do not have same GenericGF field");
}
throw new IllegalArgumentException("Divide by 0");
}
GenericGFPoly remainder = this;
int scale = field.multiply(remainder.getCoefficient(remainder.getDegree()), inverseDenominatorLeadingTerm);
}
}
if (coefficient != 0) {
if (coefficient < 0) {
} else {
}
}
if (alphaPower == 0) {
} else if (alphaPower == 1) {
} else {
}
}
if (degree != 0) {
if (degree == 1) {
} else {
}
}
}
}
}
}