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
bb7e9eb8
Commit
bb7e9eb8
authored
3 years ago
by
abivarma.kandiah
Browse files
Options
Downloads
Patches
Plain Diff
Compute_lagrange fonctionnel
parent
7c3b173a
Branches
Branches containing commit
No related tags found
1 merge request
!10
Resolve "Create Lagrange method"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
polynome.py
+2
-2
2 additions, 2 deletions
polynome.py
reed_solomon.py
+4
-8
4 additions, 8 deletions
reed_solomon.py
with
6 additions
and
10 deletions
polynome.py
+
2
−
2
View file @
bb7e9eb8
...
...
@@ -38,7 +38,7 @@ class polynome():
coeff_poly_res
=
[
0
]
*
(
len
(
self
.
coefs
)
+
len
(
poly_2
.
coefs
)
-
1
)
for
index_1
,
value_1
in
enumerate
(
self
.
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
)
def
evaluate
(
self
,
x
):
...
...
@@ -46,4 +46,4 @@ class polynome():
res
=
0
for
i
in
range
(
len
(
self
.
coefs
)
-
1
,
-
1
,
-
1
):
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
+
4
−
8
View file @
bb7e9eb8
...
...
@@ -29,12 +29,8 @@ def lagrange_compute(l: list) -> polynome:
poly_n
=
polynome
([
1
])
for
x_k
,
y_k
in
enumerate
(
l
):
if
x_k
!=
x_i
:
#print(f"value : {x_i - x_k}")
d
=
inverse_mult
(
x_i
-
x_k
,
poly_n
.
prime_mod
)
#print(f"inverse : {d}")
#poly_n = poly_n.mul(polynome([-x_k / (x_i-x_k), 1 / (x_i-x_k)]))
d
=
inverse_mult
((
x_i
-
x_k
)
%
poly_n
.
prime_mod
,
poly_n
.
prime_mod
)
poly_n
=
poly_n
.
mul
(
polynome
([
-
x_k
*
d
%
poly_n
.
prime_mod
,
d
%
poly_n
.
prime_mod
]))
#poly_n.show()
poly_n
=
poly_n
.
mul
(
polynome
([
y_i
[
1
]
%
poly_n
.
prime_mod
]))
poly
=
poly
.
add
(
poly_n
)
return
poly
...
...
@@ -43,7 +39,7 @@ def check_nb_error(l: list, p: polynome) -> int:
pass
if
__name__
==
'
__main__
'
:
list_
=
[(
0
,
2
),
(
1
,
4
),
(
2
,
8
)]
list_
=
[(
0
,
0
),
(
1
,
1
),
(
2
,
2
)]
poly
=
lagrange_compute
(
list_
)
poly
.
show
()
print
(
poly
.
evaluate
(
1
))
#
poly.show()
print
(
poly
.
evaluate
(
5
))
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