mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-28 05:12:34 +00:00
step
This commit is contained in:
@@ -523,8 +523,7 @@ use super::{ReedSolomonEncoder, GenericGF, ReedSolomonDecoder};
|
|||||||
// break;
|
// break;
|
||||||
// }
|
// }
|
||||||
if (i < maxErrors) {
|
if (i < maxErrors) {
|
||||||
assertDataEquals("Decode in " + field + " (" + dataWords.len() + ',' + ecWords.len() + ") failed at " +
|
assertDataEquals(format!("Decode in {} ({},{}) failed at {} errors",field, dataWords.len(),ecWords.len(),i),
|
||||||
i + " errors",
|
|
||||||
dataWords,
|
dataWords,
|
||||||
message);
|
message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ impl GenericGF {
|
|||||||
* @return base 2 log of a in GF(size)
|
* @return base 2 log of a in GF(size)
|
||||||
*/
|
*/
|
||||||
pub fn log(&self, a: usize) -> Result<usize, IllegalArgumentException> {
|
pub fn log(&self, a: usize) -> Result<usize, IllegalArgumentException> {
|
||||||
if (a == 0) {
|
if a == 0 {
|
||||||
return Err(IllegalArgumentException::new(""));
|
return Err(IllegalArgumentException::new(""));
|
||||||
}
|
}
|
||||||
return Ok(self.logTable[a]);
|
return Ok(self.logTable[a]);
|
||||||
@@ -209,7 +209,7 @@ impl GenericGF {
|
|||||||
* @return product of a and b in GF(size)
|
* @return product of a and b in GF(size)
|
||||||
*/
|
*/
|
||||||
pub fn multiply(&self, a: usize, b: usize) -> usize {
|
pub fn multiply(&self, a: usize, b: usize) -> usize {
|
||||||
if (a == 0 || b == 0) {
|
if a == 0 || b == 0 {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return self.expTable[(self.logTable[a] + self.logTable[b]) % (self.size - 1)];
|
return self.expTable[(self.logTable[a] + self.logTable[b]) % (self.size - 1)];
|
||||||
@@ -284,7 +284,7 @@ impl GenericGFPoly {
|
|||||||
field: Box<GenericGF>,
|
field: Box<GenericGF>,
|
||||||
coefficients: &Vec<i32>,
|
coefficients: &Vec<i32>,
|
||||||
) -> Result<Self, IllegalArgumentException> {
|
) -> Result<Self, IllegalArgumentException> {
|
||||||
if (coefficients.len() == 0) {
|
if coefficients.len() == 0 {
|
||||||
return Err(IllegalArgumentException::new(""));
|
return Err(IllegalArgumentException::new(""));
|
||||||
}
|
}
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
@@ -346,12 +346,12 @@ impl GenericGFPoly {
|
|||||||
/**
|
/**
|
||||||
* @return evaluation of this polynomial at a given point
|
* @return evaluation of this polynomial at a given point
|
||||||
*/
|
*/
|
||||||
pub fn evaluateAt(&self, a: usize) -> usize {
|
pub fn evaluateAt(&self, a: usize) -> i32 {
|
||||||
if (a == 0) {
|
if a == 0 {
|
||||||
// Just return the x^0 coefficient
|
// Just return the x^0 coefficient
|
||||||
return self.getCoefficient(0);
|
return self.getCoefficient(0);
|
||||||
}
|
}
|
||||||
if (a == 1) {
|
if a == 1 {
|
||||||
// Just the sum of the coefficients
|
// Just the sum of the coefficients
|
||||||
let mut result = 0;
|
let mut result = 0;
|
||||||
for coefficient in self.coefficients {
|
for coefficient in self.coefficients {
|
||||||
|
|||||||
Reference in New Issue
Block a user