ZXing.PDF417.Internal.EC.ModulusPoly.getCoefficient(int)

Here are the examples of the csharp api class ZXing.PDF417.Internal.EC.ModulusPoly.getCoefficient(int) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

8 Examples 7

1. Example

Project: dp2
Source File: ModulusPoly.cs
View license
internal int evaluateAt(int a)
      {
         if (a == 0)
         {
            // Just return the x^0 coefficient
            return getCoefficient(0);
         }
         int size = coefficients.Length;
         int result = 0;
         if (a == 1)
         {
            // Just the sum of the coefficients
            foreach (var coefficient in coefficients)
            {
               result = field.add(result, coefficient);
            }
            return result;
         }
         result = coefficients[0];
         for (int i = 1; i < size; i++)
         {
            result = field.add(field.multiply(a, result), coefficients[i]);
         }
         return result;
      }

2. Example

Project: dp2
Source File: ModulusPoly.cs
View license
override public String ToString()
      {
         var result = new StringBuilder(8 * Degree);
         for (int degree = Degree; degree >= 0; degree--)
         {
            int coefficient = getCoefficient(degree);
            if (coefficient != 0)
            {
               if (coefficient < 0)
               {
                  result.Append(" - ");
                  coefficient = -coefficient;
               }
               else
               {
                  if (result.Length > 0)
                  {
                     result.Append(" + ");
                  }
               }
               if (degree == 0 || coefficient != 1)
               {
                  result.Append(coefficient);
               }
               if (degree != 0)
               {
                  if (degree == 1)
                  {
                     result.Append('x');
                  }
                  else
                  {
                     result.Append("x^");
                     result.Append(degree);
                  }
               }
            }
         }
         return result.ToString();
      }

3. Example

Project: ZXing.Net
Source File: ModulusPoly.cs
View license
internal int evaluateAt(int a)
      {
         if (a == 0)
         {
            // Just return the x^0 coefficient
            return getCoefficient(0);
         }
         int result = 0;
         if (a == 1)
         {
            // Just the sum of the coefficients
            foreach (var coefficient in coefficients)
            {
               result = field.add(result, coefficient);
            }
            return result;
         }
         result = coefficients[0];
         int size = coefficients.Length;
         for (int i = 1; i < size; i++)
         {
            result = field.add(field.multiply(a, result), coefficients[i]);
         }
         return result;
      }

4. Example

Project: zxing-core
Source File: ModulusPoly.cs
View license
internal int evaluateAt(int a)
      {
         if (a == 0)
         {
            // Just return the x^0 coefficient
            return getCoefficient(0);
         }
         int size = coefficients.Length;
         int result = 0;
         if (a == 1)
         {
            // Just the sum of the coefficients
            foreach (var coefficient in coefficients)
            {
               result = field.add(result, coefficient);
            }
            return result;
         }
         result = coefficients[0];
         for (int i = 1; i < size; i++)
         {
            result = field.add(field.multiply(a, result), coefficients[i]);
         }
         return result;
      }

5. Example

Project: dp2
Source File: ModulusPoly.cs
View license
internal ModulusPoly[] divide(ModulusPoly other)
      {
         if (!field.Equals(other.field))
         {
            throw new ArgumentException("ModulusPolys do not have same ModulusGF field");
         }
         if (other.isZero)
         {
            throw new ArgumentException("Divide by 0");
         }

         ModulusPoly quotient = field.getZero();
         ModulusPoly remainder = this;

         int denominatorLeadingTerm = other.getCoefficient(other.Degree);
         int inverseDenominatorLeadingTerm = field.inverse(denominatorLeadingTerm);

         while (remainder.Degree >= other.Degree && !remainder.isZero)
         {
            int degreeDifference = remainder.Degree - other.Degree;
            int scale = field.multiply(remainder.getCoefficient(remainder.Degree), inverseDenominatorLeadingTerm);
            ModulusPoly term = other.multiplyByMonomial(degreeDifference, scale);
            ModulusPoly iterationQuotient = field.buildMonomial(degreeDifference, scale);
            quotient = quotient.add(iterationQuotient);
            remainder = remainder.subtract(term);
         }

         return new ModulusPoly[] { quotient, remainder };
      }

6. Example

Project: zxing-core
Source File: ModulusPoly.cs
View license
internal ModulusPoly[] divide(ModulusPoly other)
      {
         if (!field.Equals(other.field))
         {
            throw new ArgumentException("ModulusPolys do not have same ModulusGF field");
         }
         if (other.isZero)
         {
            throw new DivideByZeroException();
         }

         ModulusPoly quotient = field.Zero;
         ModulusPoly remainder = this;

         int denominatorLeadingTerm = other.getCoefficient(other.Degree);
         int inverseDenominatorLeadingTerm = field.inverse(denominatorLeadingTerm);

         while (remainder.Degree >= other.Degree && !remainder.isZero)
         {
            int degreeDifference = remainder.Degree - other.Degree;
            int scale = field.multiply(remainder.getCoefficient(remainder.Degree), inverseDenominatorLeadingTerm);
            ModulusPoly term = other.multiplyByMonomial(degreeDifference, scale);
            ModulusPoly iterationQuotient = field.buildMonomial(degreeDifference, scale);
            quotient = quotient.add(iterationQuotient);
            remainder = remainder.subtract(term);
         }

         return new ModulusPoly[] { quotient, remainder };
      }

7. Example

Project: ZXing.Net
Source File: ModulusPoly.cs
View license
public override String ToString()
      {
         var result = new StringBuilder(8 * Degree);
         for (int degree = Degree; degree >= 0; degree--)
         {
            int coefficient = getCoefficient(degree);
            if (coefficient != 0)
            {
               if (coefficient < 0)
               {
                  result.Append(" - ");
                  coefficient = -coefficient;
               }
               else
               {
                  if (result.Length > 0)
                  {
                     result.Append(" + ");
                  }
               }
               if (degree == 0 || coefficient != 1)
               {
                  result.Append(coefficient);
               }
               if (degree != 0)
               {
                  if (degree == 1)
                  {
                     result.Append('x');
                  }
                  else
                  {
                     result.Append("x^");
                     result.Append(degree);
                  }
               }
            }
         }
         return result.ToString();
      }

8. Example

Project: zxing-core
Source File: ModulusPoly.cs
View license
public override String ToString()
      {
         var result = new StringBuilder(8 * Degree);
         for (int degree = Degree; degree >= 0; degree--)
         {
            int coefficient = getCoefficient(degree);
            if (coefficient != 0)
            {
               if (coefficient < 0)
               {
                  result.Append(" - ");
                  coefficient = -coefficient;
               }
               else
               {
                  if (result.Length > 0)
                  {
                     result.Append(" + ");
                  }
               }
               if (degree == 0 || coefficient != 1)
               {
                  result.Append(coefficient);
               }
               if (degree != 0)
               {
                  if (degree == 1)
                  {
                     result.Append('x');
                  }
                  else
                  {
                     result.Append("x^");
                     result.Append(degree);
                  }
               }
            }
         }
         return result.ToString();
      }