8 * Created by Christian Brunschen on 05/05/2008.
9 * Copyright 2008 Google UK. All rights reserved.
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
15 * http://www.apache.org/licenses/LICENSE-2.0
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.
26 #include <zxing/common/Counted.h>
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>
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>
41 * @author srowen@google.com (Sean Owen)
42 * @author christian.brunschen@gmail.com (Christian Brunschen)
45 std::valarray<int> exp_;
46 std::valarray<int> log_;
53 Ref<GF256Poly> getZero();
54 Ref<GF256Poly> getOne();
55 Ref<GF256Poly> buildMonomial(int degree, int coefficient);
56 static int addOrSubtract(int a, int b);
60 int multiply(int a, int b);
62 static GF256 QR_CODE_FIELD;
63 static GF256 DATA_MATRIX_FIELD;
65 friend std::ostream& operator<<(std::ostream& out, const GF256& field);