Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
reed_solomon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
darius.briquet
reed_solomon
Commits
66a3bb06
Commit
66a3bb06
authored
3 years ago
by
nicolas.albanesi
Browse files
Options
Downloads
Patches
Plain Diff
Changed indentation to tabs, modified get_possibilities
parent
fcdf70e8
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
inverse_mult.py
+5
-5
5 additions, 5 deletions
inverse_mult.py
main.py
+5
-5
5 additions, 5 deletions
main.py
polynome.py
+41
-41
41 additions, 41 deletions
polynome.py
reed_solomon.py
+3
-3
3 additions, 3 deletions
reed_solomon.py
with
54 additions
and
54 deletions
inverse_mult.py
+
5
−
5
View file @
66a3bb06
...
@@ -7,10 +7,10 @@ from euclide import *
...
@@ -7,10 +7,10 @@ from euclide import *
# x = Multiplicative inverse of a mod p:
# x = Multiplicative inverse of a mod p:
# a * x mod p = 1
# a * x mod p = 1
def
inverse_mult
(
a
,
p
)
:
def
inverse_mult
(
a
,
p
)
:
pgcd
,
x
,
y
=
pgcd_etendu
(
a
,
p
)
pgcd
,
x
,
y
=
pgcd_etendu
(
a
,
p
)
if
pgcd
!=
1
:
if
pgcd
!=
1
:
return
None
return
None
return
x
if
a
>
p
else
y
return
x
if
a
>
p
else
y
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
print
(
inverse_mult
(
3
,
11
))
print
(
inverse_mult
(
3
,
11
))
\ No newline at end of file
\ No newline at end of file
This diff is collapsed.
Click to expand it.
main.py
+
5
−
5
View file @
66a3bb06
...
@@ -3,8 +3,8 @@
...
@@ -3,8 +3,8 @@
from
polynome
import
*
from
polynome
import
*
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
pol1
=
polynome
([
1
,
2
,
3
,
4
,
5
])
pol1
=
polynome
([
1
,
2
,
3
,
4
,
5
])
pol2
=
polynome
([
2
,
3
,
4
,
4
,
4
])
pol2
=
polynome
([
2
,
3
,
4
,
4
,
4
])
# pol3 = pol1.add(pol2)
# pol3 = pol1.add(pol2)
pol1
.
show
()
pol1
.
show
()
pol1
.
evaluate
(
2
)
pol1
.
evaluate
(
2
)
\ No newline at end of file
\ No newline at end of file
This diff is collapsed.
Click to expand it.
polynome.py
+
41
−
41
View file @
66a3bb06
...
@@ -4,46 +4,46 @@
...
@@ -4,46 +4,46 @@
import
math
import
math
class
polynome
():
class
polynome
():
def
__init__
(
self
,
coefs
:
list
):
def
__init__
(
self
,
coefs
:
list
):
self
.
coefs
=
coefs
self
.
coefs
=
coefs
self
.
prime_mod
=
229
self
.
prime_mod
=
229
def
show
(
self
):
def
show
(
self
):
for
i
in
range
(
len
(
self
.
coefs
)
-
1
,
-
1
,
-
1
):
for
i
in
range
(
len
(
self
.
coefs
)
-
1
,
-
1
,
-
1
):
power
=
""
power
=
""
if
self
.
coefs
[
i
]
!=
0
:
if
self
.
coefs
[
i
]
!=
0
:
coef
=
str
(
self
.
coefs
[
i
])
coef
=
str
(
self
.
coefs
[
i
])
if
i
!=
0
:
# its not 0's degree
if
i
!=
0
:
# its not 0's degree
power
=
f
"
x^
{
i
}
+
"
power
=
f
"
x^
{
i
}
+
"
else
:
else
:
coef
=
""
coef
=
""
print
(
f
"
{
coef
}{
power
}
"
,
end
=
""
)
print
(
f
"
{
coef
}{
power
}
"
,
end
=
""
)
print
()
# new line
print
()
# new line
def
add
(
self
,
poly_2
):
def
add
(
self
,
poly_2
):
coeff_poly_1
=
self
.
coefs
coeff_poly_1
=
self
.
coefs
if
len
(
coeff_poly_1
)
>
len
(
poly_2
.
coefs
):
if
len
(
coeff_poly_1
)
>
len
(
poly_2
.
coefs
):
while
len
(
coeff_poly_1
)
>
len
(
poly_2
.
coefs
):
while
len
(
coeff_poly_1
)
>
len
(
poly_2
.
coefs
):
poly_2
.
coefs
.
append
(
0
)
poly_2
.
coefs
.
append
(
0
)
else
:
else
:
while
len
(
coeff_poly_1
)
<
len
(
poly_2
.
coefs
):
while
len
(
coeff_poly_1
)
<
len
(
poly_2
.
coefs
):
coeff_poly_1
.
append
(
0
)
coeff_poly_1
.
append
(
0
)
for
i
in
range
(
0
,
len
(
coeff_poly_1
)):
for
i
in
range
(
0
,
len
(
coeff_poly_1
)):
coeff_poly_1
[
i
]
=
(
coeff_poly_1
[
i
]
+
poly_2
.
coefs
[
i
])
%
self
.
prime_mod
coeff_poly_1
[
i
]
=
(
coeff_poly_1
[
i
]
+
poly_2
.
coefs
[
i
])
%
self
.
prime_mod
return
polynome
(
coeff_poly_1
)
return
polynome
(
coeff_poly_1
)
def
mul
(
self
,
poly_2
):
def
mul
(
self
,
poly_2
):
coeff_poly_res
=
[
0
]
*
(
len
(
self
.
coefs
)
+
len
(
poly_2
.
coefs
)
-
1
)
coeff_poly_res
=
[
0
]
*
(
len
(
self
.
coefs
)
+
len
(
poly_2
.
coefs
)
-
1
)
for
index_1
,
value_1
in
enumerate
(
self
.
coefs
):
for
index_1
,
value_1
in
enumerate
(
self
.
coefs
):
for
index_2
,
value_2
in
enumerate
(
poly_2
.
coefs
):
for
index_2
,
value_2
in
enumerate
(
poly_2
.
coefs
):
coeff_poly_res
[
index_1
+
index_2
]
+=
(
value_1
*
value_2
)
%
self
.
prime_mod
coeff_poly_res
[
index_1
+
index_2
]
+=
(
value_1
*
value_2
)
%
self
.
prime_mod
return
polynome
(
coeff_poly_res
)
return
polynome
(
coeff_poly_res
)
def
evaluate
(
self
,
x
):
def
evaluate
(
self
,
x
):
# Using horner method
# Using horner method
res
=
0
res
=
0
for
i
in
range
(
len
(
self
.
coefs
)
-
1
,
-
1
,
-
1
):
for
i
in
range
(
len
(
self
.
coefs
)
-
1
,
-
1
,
-
1
):
res
=
(
res
*
x
+
self
.
coefs
[
i
])
res
=
(
res
*
x
+
self
.
coefs
[
i
])
return
(
res
%
self
.
prime_mod
)
return
(
res
%
self
.
prime_mod
)
This diff is collapsed.
Click to expand it.
reed_solomon.py
+
3
−
3
View file @
66a3bb06
...
@@ -3,7 +3,7 @@ from polynome import *
...
@@ -3,7 +3,7 @@ from polynome import *
from
inverse_mult
import
*
from
inverse_mult
import
*
from
itertools
import
combinations
from
itertools
import
combinations
def
get_possibilities
(
l
:
list
):
def
get_possibilities
(
l
:
list
,
index
:
int
):
# Transforme the list in list of tupples with their indexes
# Transforme the list in list of tupples with their indexes
for
x
,
_
in
enumerate
(
l
):
for
x
,
_
in
enumerate
(
l
):
...
@@ -11,8 +11,8 @@ def get_possibilities(l: list):
...
@@ -11,8 +11,8 @@ def get_possibilities(l: list):
# ! la valeur 20 est hardcodée. Paramètre de fonction ??
# ! la valeur 20 est hardcodée. Paramètre de fonction ??
l_fixe
=
l
[
20
:]
# Liste contenant aucune erreur
l_fixe
=
l
[
index
:]
# Liste contenant aucune erreur
l_posi
=
l
[:
20
]
# Liste contenant des erreurs,
l_posi
=
l
[:
index
]
# Liste contenant des erreurs,
p
=
list
(
combinations
(
l_posi
,
2
))
p
=
list
(
combinations
(
l_posi
,
2
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment