選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

ZXGenericGF.h 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright 2012 ZXing authors
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. @class ZXGenericGFPoly;
  17. /**
  18. * This class contains utility methods for performing mathematical operations over
  19. * the Galois Fields. Operations use a given primitive polynomial in calculations.
  20. *
  21. * Throughout this package, elements of the GF are represented as an int
  22. * for convenience and speed (but at the cost of memory).
  23. */
  24. @interface ZXGenericGF : NSObject
  25. @property (nonatomic, strong, readonly) ZXGenericGFPoly *zero;
  26. @property (nonatomic, strong, readonly) ZXGenericGFPoly *one;
  27. @property (nonatomic, assign, readonly) int32_t size;
  28. @property (nonatomic, assign, readonly) int32_t generatorBase;
  29. + (ZXGenericGF *)AztecData12;
  30. + (ZXGenericGF *)AztecData10;
  31. + (ZXGenericGF *)AztecData6;
  32. + (ZXGenericGF *)AztecParam;
  33. + (ZXGenericGF *)QrCodeField256;
  34. + (ZXGenericGF *)DataMatrixField256;
  35. + (ZXGenericGF *)AztecData8;
  36. + (ZXGenericGF *)MaxiCodeField64;
  37. /**
  38. * Create a representation of GF(size) using the given primitive polynomial.
  39. *
  40. * @param primitive irreducible polynomial whose coefficients are represented by
  41. * the bits of an int, where the least-significant bit represents the constant
  42. * coefficient
  43. * @param size the size of the field
  44. * @param b the factor b in the generator polynomial can be 0- or 1-based
  45. * (g(x) = (x+a^b)(x+a^(b+1))...(x+a^(b+2t-1))).
  46. * In most cases it should be 1, but for QR code it is 0.
  47. */
  48. - (id)initWithPrimitive:(int)primitive size:(int)size b:(int)b;
  49. /**
  50. * @return the monomial representing coefficient * x^degree
  51. */
  52. - (ZXGenericGFPoly *)buildMonomial:(int)degree coefficient:(int)coefficient;
  53. /**
  54. * Implements both addition and subtraction -- they are the same in GF(size).
  55. *
  56. * @return sum/difference of a and b
  57. */
  58. + (int32_t)addOrSubtract:(int32_t)a b:(int32_t)b;
  59. /**
  60. * @return 2 to the power of a in GF(size)
  61. */
  62. - (int32_t)exp:(int)a;
  63. /**
  64. * @return base 2 log of a in GF(size)
  65. */
  66. - (int32_t)log:(int)a;
  67. /**
  68. * @return multiplicative inverse of a
  69. */
  70. - (int32_t)inverse:(int)a;
  71. /**
  72. * @return product of a and b in GF(size)
  73. */
  74. - (int32_t)multiply:(int)a b:(int)b;
  75. @end