185 lines
5.3 KiB
Java
185 lines
5.3 KiB
Java
package com.google.zxing.pdf417.decoder.ec;
|
|
|
|
/* loaded from: classes.dex */
|
|
final class ModulusPoly {
|
|
private final ModulusGF a;
|
|
private final int[] b;
|
|
|
|
ModulusPoly(ModulusGF modulusGF, int[] iArr) {
|
|
if (iArr.length == 0) {
|
|
throw new IllegalArgumentException();
|
|
}
|
|
this.a = modulusGF;
|
|
int length = iArr.length;
|
|
if (length <= 1 || iArr[0] != 0) {
|
|
this.b = iArr;
|
|
return;
|
|
}
|
|
int i = 1;
|
|
while (i < length && iArr[i] == 0) {
|
|
i++;
|
|
}
|
|
if (i == length) {
|
|
this.b = new int[]{0};
|
|
return;
|
|
}
|
|
this.b = new int[length - i];
|
|
int[] iArr2 = this.b;
|
|
System.arraycopy(iArr, i, iArr2, 0, iArr2.length);
|
|
}
|
|
|
|
int a() {
|
|
return this.b.length - 1;
|
|
}
|
|
|
|
boolean b() {
|
|
return this.b[0] == 0;
|
|
}
|
|
|
|
ModulusPoly c(ModulusPoly modulusPoly) {
|
|
if (this.a.equals(modulusPoly.a)) {
|
|
return modulusPoly.b() ? this : a(modulusPoly.c());
|
|
}
|
|
throw new IllegalArgumentException("ModulusPolys do not have same ModulusGF field");
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder sb = new StringBuilder(a() * 8);
|
|
for (int a = a(); a >= 0; a--) {
|
|
int b = b(a);
|
|
if (b != 0) {
|
|
if (b < 0) {
|
|
sb.append(" - ");
|
|
b = -b;
|
|
} else if (sb.length() > 0) {
|
|
sb.append(" + ");
|
|
}
|
|
if (a == 0 || b != 1) {
|
|
sb.append(b);
|
|
}
|
|
if (a != 0) {
|
|
if (a == 1) {
|
|
sb.append('x');
|
|
} else {
|
|
sb.append("x^");
|
|
sb.append(a);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return sb.toString();
|
|
}
|
|
|
|
int a(int i) {
|
|
if (i == 0) {
|
|
return b(0);
|
|
}
|
|
if (i == 1) {
|
|
int i2 = 0;
|
|
for (int i3 : this.b) {
|
|
i2 = this.a.a(i2, i3);
|
|
}
|
|
return i2;
|
|
}
|
|
int[] iArr = this.b;
|
|
int i4 = iArr[0];
|
|
int length = iArr.length;
|
|
for (int i5 = 1; i5 < length; i5++) {
|
|
ModulusGF modulusGF = this.a;
|
|
i4 = modulusGF.a(modulusGF.c(i, i4), this.b[i5]);
|
|
}
|
|
return i4;
|
|
}
|
|
|
|
int b(int i) {
|
|
return this.b[(r0.length - 1) - i];
|
|
}
|
|
|
|
ModulusPoly b(ModulusPoly modulusPoly) {
|
|
if (this.a.equals(modulusPoly.a)) {
|
|
if (!b() && !modulusPoly.b()) {
|
|
int[] iArr = this.b;
|
|
int length = iArr.length;
|
|
int[] iArr2 = modulusPoly.b;
|
|
int length2 = iArr2.length;
|
|
int[] iArr3 = new int[(length + length2) - 1];
|
|
for (int i = 0; i < length; i++) {
|
|
int i2 = iArr[i];
|
|
for (int i3 = 0; i3 < length2; i3++) {
|
|
int i4 = i + i3;
|
|
ModulusGF modulusGF = this.a;
|
|
iArr3[i4] = modulusGF.a(iArr3[i4], modulusGF.c(i2, iArr2[i3]));
|
|
}
|
|
}
|
|
return new ModulusPoly(this.a, iArr3);
|
|
}
|
|
return this.a.c();
|
|
}
|
|
throw new IllegalArgumentException("ModulusPolys do not have same ModulusGF field");
|
|
}
|
|
|
|
ModulusPoly c() {
|
|
int length = this.b.length;
|
|
int[] iArr = new int[length];
|
|
for (int i = 0; i < length; i++) {
|
|
iArr[i] = this.a.d(0, this.b[i]);
|
|
}
|
|
return new ModulusPoly(this.a, iArr);
|
|
}
|
|
|
|
ModulusPoly a(ModulusPoly modulusPoly) {
|
|
if (this.a.equals(modulusPoly.a)) {
|
|
if (b()) {
|
|
return modulusPoly;
|
|
}
|
|
if (modulusPoly.b()) {
|
|
return this;
|
|
}
|
|
int[] iArr = this.b;
|
|
int[] iArr2 = modulusPoly.b;
|
|
if (iArr.length > iArr2.length) {
|
|
iArr = iArr2;
|
|
iArr2 = iArr;
|
|
}
|
|
int[] iArr3 = new int[iArr2.length];
|
|
int length = iArr2.length - iArr.length;
|
|
System.arraycopy(iArr2, 0, iArr3, 0, length);
|
|
for (int i = length; i < iArr2.length; i++) {
|
|
iArr3[i] = this.a.a(iArr[i - length], iArr2[i]);
|
|
}
|
|
return new ModulusPoly(this.a, iArr3);
|
|
}
|
|
throw new IllegalArgumentException("ModulusPolys do not have same ModulusGF field");
|
|
}
|
|
|
|
ModulusPoly c(int i) {
|
|
if (i == 0) {
|
|
return this.a.c();
|
|
}
|
|
if (i == 1) {
|
|
return this;
|
|
}
|
|
int length = this.b.length;
|
|
int[] iArr = new int[length];
|
|
for (int i2 = 0; i2 < length; i2++) {
|
|
iArr[i2] = this.a.c(this.b[i2], i);
|
|
}
|
|
return new ModulusPoly(this.a, iArr);
|
|
}
|
|
|
|
ModulusPoly a(int i, int i2) {
|
|
if (i < 0) {
|
|
throw new IllegalArgumentException();
|
|
}
|
|
if (i2 == 0) {
|
|
return this.a.c();
|
|
}
|
|
int length = this.b.length;
|
|
int[] iArr = new int[i + length];
|
|
for (int i3 = 0; i3 < length; i3++) {
|
|
iArr[i3] = this.a.c(this.b[i3], i2);
|
|
}
|
|
return new ModulusPoly(this.a, iArr);
|
|
}
|
|
}
|