Percy++
A C++ implementation of Private Information Retrieval (PIR) protocols
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
old_matrix.h
1 // Percy++ Copyright 2014 Ian Goldberg <iang@cs.uwaterloo.ca>,
2 // Wouter Lueks <lueks@cs.ru.nl>
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of version 2 of the GNU General Public License as
6 // published by the Free Software Foundation.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // There is a copy of the GNU General Public License in the COPYING file
14 // packaged with this plugin; if you cannot find it, write to the Free
15 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16 // 02110-1301 USA
17 
18 #ifndef __MATRIX_H__
19 #define __MATRIX_H__
20 
21 #include "gf2e.h"
22 #include <iostream>
23 #include <stdint.h>
24 #include <string.h>
25 #include "xor.h"
26 
27 template <typename Element> class SubMatrix;
28 template <typename Element> class Col;
29 template <typename Element> class Row;
30 template <typename Element> class Elem;
31 
32 template <typename Element>
33 class Matrix {
34 public:
35  Element *data;
36  dbsize_t num_rows;
37  dbsize_t num_cols;
38 
39  // Constructor and destructor
40  Matrix ();
41  Matrix (Element *data, dbsize_t num_rows, dbsize_t num_cols);
42 
43  void print();
44 
45  void strassen_submatrices(SubMatrix<Element> &m11,
46  SubMatrix<Element> &m12,
47  SubMatrix<Element> &m21,
48  SubMatrix<Element> &m22);
49 
50  void clear();
51 
52  void is_sum_of(SubMatrix<const Element> &m1,
54  void copy_from(SubMatrix<const Element> &src);
55 };
56 
57 template <typename Element>
58 class SubMatrix {
59 public:
60  Matrix<Element> matrix;
61  dbsize_t row;
62  dbsize_t col;
63  dbsize_t num_rows;
64  dbsize_t num_cols;
65 
66  // Constructors
67  SubMatrix ();
68  SubMatrix (Matrix<Element> matrix,
69  dbsize_t row, dbsize_t col,
70  dbsize_t num_rows, dbsize_t num_cols);
71 
72  Element* get(dbsize_t row, dbsize_t col);
73  Element* first();
74 
75  void add(Matrix<Element> &m);
76 
77  void print();
78 
79  inline void is_mult_of(
80  Col<const Element> col_a,
81  Row<const Element> row_b);
82 };
83 
84 template <typename Element>
85 class Row : public virtual SubMatrix<Element> {
86 public:
87  Row (Matrix<Element> matrix,
88  dbsize_t row, dbsize_t col, dbsize_t num_cols);
89 
90  Element* get(dbsize_t row);
91 
92 
93  inline void is_mult_of(Row<const Element> row_a,
95 };
96 
97 template <typename Element>
98 class Col : public virtual SubMatrix<Element> {
99 public:
100  Col (Matrix<Element> matrix,
101  dbsize_t row, dbsize_t col, dbsize_t num_rows);
102 
103  Element* get(dbsize_t col);
104 
105  inline void is_mult_of(
107  Col<const Element> col_b);
108 
109  inline void is_mult_of(
110  Col<const Element> col_a,
111  Elem<const Element> elem_b);
112 };
113 
114 template <typename Element>
115 class Elem : public Row<Element>, public Col<Element> {
116 public:
117  Elem (Matrix<Element> matrix,
118  dbsize_t row, dbsize_t col);
119 
120  Element* get(dbsize_t nothing);
121 
122  inline void is_mult_of(
123  Row<const Element> row_a,
124  Col<const Element> col_b);
125 
126  inline void is_mult_of(
127  Elem<const Element> elem_a,
128  Elem<const Element> elem_b);
129 };
130 
131 #include "matrix_impl.h"
132 
133 #endif
Definition: old_matrix.h:28
Definition: old_matrix.h:33
Definition: old_matrix.h:29
Definition: old_matrix.h:30
Definition: old_matrix.h:27