Added a project written on Qt framework for Symbian and added tutorials for both...
[zxing.git] / symbian / QQrDecoder / zxing / common / reedsolomon / GF256.h
1 #ifndef __GF256_H__
2 #define __GF256_H__
3
4 /*
5  *  GF256.h
6  *  zxing
7  *
8  *  Created by Christian Brunschen on 05/05/2008.
9  *  Copyright 2008 Google UK. All rights reserved.
10  *
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  *      http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  */
23
24 #include <memory>
25 #include <valarray>
26 #include <zxing/common/Counted.h>
27
28 namespace zxing {
29 class GF256Poly;
30
31 class GF256 {
32   /**
33    * <p>This class contains utility methods for performing mathematical
34    * operations over the Galois Field GF(256). Operations use a given
35    * primitive polynomial in calculations.</p>
36    *
37    * <p>Throughout this package, elements of GF(256) are represented as an
38    * <code>int</code> for convenience and speed (but at the cost of memory).
39    * Only the bottom 8 bits are really used.</p>
40    *
41    * @author srowen@google.com (Sean Owen)
42    * @author christian.brunschen@gmail.com (Christian Brunschen)
43    */
44 private:
45   std::valarray<int> exp_;
46   std::valarray<int> log_;
47   Ref<GF256Poly> zero_;
48   Ref<GF256Poly> one_;
49
50   GF256(int primitive);
51
52 public:
53   Ref<GF256Poly> getZero();
54   Ref<GF256Poly> getOne();
55   Ref<GF256Poly> buildMonomial(int degree, int coefficient);
56   static int addOrSubtract(int a, int b);
57   int exp(int a);
58   int log(int a);
59   int inverse(int a);
60   int multiply(int a, int b);
61
62   static GF256 QR_CODE_FIELD;
63   static GF256 DATA_MATRIX_FIELD;
64
65   friend std::ostream& operator<<(std::ostream& out, const GF256& field);
66 };
67 }
68
69 #endif // __GF256_H__