Skip to content

Commit

Permalink
first files
Browse files Browse the repository at this point in the history
  • Loading branch information
fmndantas committed Jan 28, 2020
1 parent f7e339e commit 4970910
Show file tree
Hide file tree
Showing 5 changed files with 428 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST
*.ipynb

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
256 changes: 256 additions & 0 deletions mcw2_128.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
1.000000
1.000000
1.000000
-1.000000
1.000000
1.000000
-1.000000
1.000000
1.000000
1.000000
1.000000
-1.000000
-1.000000
-1.000000
1.000000
-1.000000
1.000000
1.000000
1.000000
-1.000000
1.000000
1.000000
-1.000000
1.000000
-1.000000
-1.000000
-1.000000
1.000000
1.000000
1.000000
-1.000000
1.000000
1.000000
1.000000
1.000000
-1.000000
1.000000
1.000000
-1.000000
1.000000
1.000000
1.000000
1.000000
-1.000000
-1.000000
-1.000000
1.000000
-1.000000
-1.000000
-1.000000
-1.000000
1.000000
-1.000000
-1.000000
1.000000
-1.000000
1.000000
1.000000
1.000000
-1.000000
-1.000000
-1.000000
1.000000
-1.000000
1.000000
1.000000
1.000000
-1.000000
1.000000
1.000000
-1.000000
1.000000
1.000000
1.000000
1.000000
-1.000000
-1.000000
-1.000000
1.000000
-1.000000
1.000000
1.000000
1.000000
-1.000000
1.000000
1.000000
-1.000000
1.000000
-1.000000
-1.000000
-1.000000
1.000000
1.000000
1.000000
-1.000000
1.000000
-1.000000
-1.000000
-1.000000
1.000000
-1.000000
-1.000000
1.000000
-1.000000
-1.000000
-1.000000
-1.000000
1.000000
1.000000
1.000000
-1.000000
1.000000
1.000000
1.000000
1.000000
-1.000000
1.000000
1.000000
-1.000000
1.000000
-1.000000
-1.000000
-1.000000
1.000000
1.000000
1.000000
-1.000000
1.000000
1.000000
1.000000
1.000000
-1.000000
1.000000
1.000000
-1.000000
1.000000
1.000000
1.000000
1.000000
-1.000000
-1.000000
-1.000000
1.000000
-1.000000
1.000000
1.000000
1.000000
-1.000000
1.000000
1.000000
-1.000000
1.000000
-1.000000
-1.000000
-1.000000
1.000000
1.000000
1.000000
-1.000000
1.000000
1.000000
1.000000
1.000000
-1.000000
1.000000
1.000000
-1.000000
1.000000
1.000000
1.000000
1.000000
-1.000000
-1.000000
-1.000000
1.000000
-1.000000
-1.000000
-1.000000
-1.000000
1.000000
-1.000000
-1.000000
1.000000
-1.000000
1.000000
1.000000
1.000000
-1.000000
-1.000000
-1.000000
1.000000
-1.000000
-1.000000
-1.000000
-1.000000
1.000000
-1.000000
-1.000000
1.000000
-1.000000
-1.000000
-1.000000
-1.000000
1.000000
1.000000
1.000000
-1.000000
1.000000
-1.000000
-1.000000
-1.000000
1.000000
-1.000000
-1.000000
1.000000
-1.000000
1.000000
1.000000
1.000000
-1.000000
-1.000000
-1.000000
1.000000
-1.000000
1.000000
1.000000
1.000000
-1.000000
1.000000
1.000000
-1.000000
1.000000
1.000000
1.000000
1.000000
-1.000000
-1.000000
-1.000000
1.000000
-1.000000
-1.000000
-1.000000
-1.000000
1.000000
-1.000000
-1.000000
1.000000
-1.000000
1.000000
1.000000
1.000000
-1.000000
-1.000000
-1.000000
1.000000
-1.000000
4 changes: 4 additions & 0 deletions mcw2_4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-1
10
111
-1.9
53 changes: 53 additions & 0 deletions wavelet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/python3

import numpy as np


class Wavelet:
def __init__(self, m, g):
self.m = m
self.g = g
self.mg = m * g
self.A = None
self.mcw = None

def _allocate_a_matrix(self):
if self.A is None:
self.A = np.zeros((self.m, self.mg))

def _get_raw_lines(self, file, type=float):
with open(file, 'r') as file:
flatten = [type(l) for l in file.readlines()]
size = int(np.size(flatten))
step = int(size / self.m)
for i in np.arange(0, size, step):
yield flatten[i: i + step]

def _set_a_coefficients(self, file):
"""Loads A with coefficients defined on raw file `file`"""
self._allocate_a_matrix()
lines = self._get_raw_lines(file)
for i in range(self.m):
self.A[i] = next(lines)

def _allocate_mcw(self, message_length):
"""MCW matrix will be rotated, so it has m as number of lines"""
if self.mcw is None:
self.mcw = np.zeros((self.m, message_length + self.mg - self.m))

def mcw_from_coefficients(self, file, message_length):
self._set_a_coefficients(file)
self._allocate_mcw(message_length)
self.mcw[:self.m, :self.mg] = self.A

def displace_mcw(self, pad):
self.mcw = np.roll(self.mcw, self.m * pad)

def get_encoded_output(self):
return np.zeros((self.mcw.shape[1]))

def encode(self, message):
pass



Loading

0 comments on commit 4970910

Please sign in to comment.