149 lines
4 KiB
Java
149 lines
4 KiB
Java
|
package c.i.e.n.l;
|
||
|
|
||
|
import java.util.Objects;
|
||
|
/* compiled from: GenericGFPoly */
|
||
|
public final class b {
|
||
|
public final a a;
|
||
|
public final int[] b;
|
||
|
|
||
|
public b(a aVar, int[] iArr) {
|
||
|
if (iArr.length != 0) {
|
||
|
this.a = aVar;
|
||
|
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;
|
||
|
}
|
||
|
int[] iArr2 = new int[(length - i)];
|
||
|
this.b = iArr2;
|
||
|
System.arraycopy(iArr, i, iArr2, 0, iArr2.length);
|
||
|
return;
|
||
|
}
|
||
|
throw new IllegalArgumentException();
|
||
|
}
|
||
|
|
||
|
public b a(b bVar) {
|
||
|
if (!this.a.equals(bVar.a)) {
|
||
|
throw new IllegalArgumentException("GenericGFPolys do not have same GenericGF field");
|
||
|
} else if (e()) {
|
||
|
return bVar;
|
||
|
} else {
|
||
|
if (bVar.e()) {
|
||
|
return this;
|
||
|
}
|
||
|
int[] iArr = this.b;
|
||
|
int[] iArr2 = bVar.b;
|
||
|
if (iArr.length <= iArr2.length) {
|
||
|
iArr = iArr2;
|
||
|
iArr2 = iArr;
|
||
|
}
|
||
|
int[] iArr3 = new int[iArr.length];
|
||
|
int length = iArr.length - iArr2.length;
|
||
|
System.arraycopy(iArr, 0, iArr3, 0, length);
|
||
|
for (int i = length; i < iArr.length; i++) {
|
||
|
iArr3[i] = iArr2[i - length] ^ iArr[i];
|
||
|
}
|
||
|
return new b(this.a, iArr3);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public int b(int i) {
|
||
|
if (i == 0) {
|
||
|
return c(0);
|
||
|
}
|
||
|
if (i == 1) {
|
||
|
int[] iArr = this.b;
|
||
|
int i2 = 0;
|
||
|
for (int i3 : iArr) {
|
||
|
a aVar = a.a;
|
||
|
i2 ^= i3;
|
||
|
}
|
||
|
return i2;
|
||
|
}
|
||
|
int[] iArr2 = this.b;
|
||
|
int i4 = iArr2[0];
|
||
|
int length = iArr2.length;
|
||
|
for (int i5 = 1; i5 < length; i5++) {
|
||
|
i4 = this.a.c(i, i4) ^ this.b[i5];
|
||
|
}
|
||
|
return i4;
|
||
|
}
|
||
|
|
||
|
public int c(int i) {
|
||
|
int[] iArr = this.b;
|
||
|
return iArr[(iArr.length - 1) - i];
|
||
|
}
|
||
|
|
||
|
public int d() {
|
||
|
return this.b.length - 1;
|
||
|
}
|
||
|
|
||
|
public boolean e() {
|
||
|
return this.b[0] == 0;
|
||
|
}
|
||
|
|
||
|
public b f(int i) {
|
||
|
if (i == 0) {
|
||
|
return this.a.k;
|
||
|
}
|
||
|
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 b(this.a, iArr);
|
||
|
}
|
||
|
|
||
|
public String toString() {
|
||
|
StringBuilder sb = new StringBuilder(d() * 8);
|
||
|
for (int d = d(); d >= 0; d--) {
|
||
|
int c2 = c(d);
|
||
|
if (c2 != 0) {
|
||
|
if (c2 < 0) {
|
||
|
sb.append(" - ");
|
||
|
c2 = -c2;
|
||
|
} else if (sb.length() > 0) {
|
||
|
sb.append(" + ");
|
||
|
}
|
||
|
if (d == 0 || c2 != 1) {
|
||
|
a aVar = this.a;
|
||
|
Objects.requireNonNull(aVar);
|
||
|
if (c2 != 0) {
|
||
|
int i = aVar.j[c2];
|
||
|
if (i == 0) {
|
||
|
sb.append('1');
|
||
|
} else if (i == 1) {
|
||
|
sb.append('a');
|
||
|
} else {
|
||
|
sb.append("a^");
|
||
|
sb.append(i);
|
||
|
}
|
||
|
} else {
|
||
|
throw new IllegalArgumentException();
|
||
|
}
|
||
|
}
|
||
|
if (d != 0) {
|
||
|
if (d == 1) {
|
||
|
sb.append('x');
|
||
|
} else {
|
||
|
sb.append("x^");
|
||
|
sb.append(d);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return sb.toString();
|
||
|
}
|
||
|
}
|