First version of the iphone client that actually works, for at least a subset
[zxing.git] / cpp / core / src / common / reedsolomon / GF256Poly.h
1 #ifndef __GF256_POLY_H__
2 #define __GF256_POLY_H__
3
4 /*
5  *  GF256Poly.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 "../Counted.h"
26 #include "../Array.h"
27 using namespace std;
28 using namespace common;
29
30 namespace reedsolomon {
31   class GF256;
32   
33   class GF256Poly : public Counted {
34   private:
35     GF256 &field;
36     ArrayRef<int> coefficients;
37     void fixCoefficients();
38   public:
39     GF256Poly(GF256 &field, ArrayRef<int> c);
40     ~GF256Poly();
41     
42     int getDegree();
43     bool isZero();
44     int getCoefficient(int degree);
45     int evaluateAt(int a);
46     GF256Poly *addOrSubtract(GF256Poly *other);
47     GF256Poly *multiply(GF256Poly *other);
48     GF256Poly *multiply(int scalar);
49     GF256Poly *multiplyByMonomial(int degree,
50                                   int coefficient);
51     const char *description() const;
52     friend ostream& operator<<(ostream& out, const GF256Poly& poly);
53
54   };
55 }
56
57 #endif // __GF256_POLY_H__