This commit is contained in:
jacekpoz 2024-04-12 10:39:00 +02:00
parent 2f61515fb7
commit bab58d8b7c
Signed by: poz
SSH key fingerprint: SHA256:JyLeVWE4bF3tDnFeUpUaJsPsNlJyBldDGV/dIKSLyN8

View file

@ -18,7 +18,7 @@ public class GF {
public GF add(final GF rhs) throws IllegalArgumentException {
verifyCharacteristics(this, rhs);
return new GF((this.value + rhs.value) % this.characteristic, this.characteristic);
return new GF(this.characteristic, (this.value + rhs.value) % this.characteristic);
}
public void addAssign(final GF rhs) throws IllegalArgumentException {
@ -30,7 +30,7 @@ public class GF {
public GF subtract(final GF rhs) throws IllegalArgumentException {
verifyCharacteristics(this, rhs);
if (this.value < rhs.value) {
return new GF(this.characteristic - (rhs.value - this.value), this.characteristic);
return new GF(this.characteristic, this.characteristic - (rhs.value - this.value));
}
return new GF((this.value - rhs.value), this.characteristic);
}
@ -44,7 +44,7 @@ public class GF {
public GF multiply(final GF rhs) throws IllegalArgumentException {
verifyCharacteristics(this, rhs);
return new GF((this.value * rhs.value) % this.characteristic, this.characteristic);
return new GF(this.characteristic, (this.value * rhs.value) % this.characteristic);
}
public void multiplyAssign(final GF rhs) throws IllegalArgumentException {
@ -67,7 +67,7 @@ public class GF {
}
}
return new GF((this.value * inverse) % this.characteristic, this.characteristic);
return new GF(this.characteristic, (this.value * inverse) % this.characteristic);
}
public void divideAssign(final GF rhs) throws IllegalArgumentException {