Skip to content

Commit 92f86d1

Browse files
author
Floyd Zweydinger
committed
added Prange as a sat algorithm
1 parent 04c04a3 commit 92f86d1

File tree

6 files changed

+1635
-4
lines changed

6 files changed

+1635
-4
lines changed

decoding/matrix.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def __getitem__(self, tup):
2323

2424
def print(self, tranpose: bool = False):
2525
""" printing """
26+
print("nrows:", self.nrows, ", ncols:", self.ncols)
2627
for i in range(self.nrows):
2728
for j in range(self.ncols):
2829
print(self.data[i][j], end='')
@@ -36,6 +37,26 @@ def zero(self) -> 'Matrix':
3637
self.data[i][j] = 0
3738
return self
3839

40+
def from_string(self, d: str, transposed: bool = True) -> 'Matrix':
41+
""" reads line by line
42+
"""
43+
if transposed:
44+
D = Matrix(self.ncols, self.nrows, self.q)
45+
else:
46+
D = self
47+
for i in range(self.nrows):
48+
for j in range(self.ncols):
49+
if transposed:
50+
t = int(d[j*self.nrows+ i])
51+
D.data[j][i] = t
52+
else:
53+
t = int(d[i*self.ncols+ j])
54+
D.data[i][j] = t
55+
56+
if transposed:
57+
self = D.transpose()
58+
return self
59+
3960
def random(self) -> 'Matrix':
4061
""" generates a random matrix """
4162
for i in range(self.nrows):

decoding/optimize.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,8 @@ def gen_random_instance(self):
412412
""" creates a random parity check matrix and syndrome.
413413
TODO: no guarantee of the existence of a solution is made.
414414
"""
415+
self.H = ""
416+
self.syndrome = ""
415417
for _ in range(self.problem.n * (self.problem.n - self.problem.k)):
416418
self.H += str(random.randint(0, self.problem.q - 1))
417419
for _ in range(self.problem.n - self.problem.k):

0 commit comments

Comments
 (0)