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
Merge requests
!10
Resolve "Create Lagrange method"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "Create Lagrange method"
12-create-lagrange-method
into
main
Overview
0
Commits
9
Pipelines
0
Changes
1
Merged
jonas.stirnema
requested to merge
12-create-lagrange-method
into
main
3 years ago
Overview
0
Commits
9
Pipelines
0
Changes
1
Expand
Closes
#12 (closed)
Edited
3 years ago
by
abivarma.kandiah
0
0
Merge request reports
Viewing commit
f4a4715f
Prev
Next
Show latest version
1 file
+
25
−
26
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
f4a4715f
Lagrange still doesn't work
· f4a4715f
Djokzer
authored
3 years ago
reed_solomon.py
+
25
−
26
Options
@@ -23,35 +23,34 @@ def get_possibilities(l: list):
@@ -23,35 +23,34 @@ def get_possibilities(l: list):
return
p
return
p
def
lagrange_compute
(
l
:
list
)
->
polynome
:
def
lagrange_compute
(
l
:
list
)
->
polynome
:
list_s
=
[
0
]
*
len
(
l
)
poly
=
[
0
]
*
len
(
l
)
list_p
=
[
0
]
*
len
(
l
)
for
x_i
,
y_i
in
l
:
sum_poly
=
polynome
(
list_s
)
#Produit des coeffs
#product_poly = polynome(list_p)
coeff
=
[
0
]
*
len
(
l
)
first_time
=
True
denominator
=
1
for
x_i
,
y_i
in
enumerate
(
l
):
for
j
in
range
(
len
(
l
)):
for
x_j
,
y_j
in
enumerate
(
l
):
if
x_i
!=
j
:
if
x_j
!=
x_i
:
denominator
*=
x_i
-
l
[
j
][
0
]
list_p
[
0
]
=
-
x_j
/
(
x_i
-
x_j
)
coeff
[
0
]
=
1
/
denominator
#Produit de chaque denominateur
list_p
[
1
]
=
1
/
(
x_i
-
x_j
)
if
first_time
:
for
k
in
range
(
len
(
l
)):
product_poly
=
polynome
(
list_p
)
new_coeff
=
[
0
]
*
(
len
(
l
)
+
1
)
first_time
=
False
if
x_i
!=
k
:
else
:
for
j
in
range
(
k
+
1
if
k
<
x_i
else
k
,
0
,
-
1
):
product_poly
=
product_poly
.
mul
(
polynome
(
list_p
))
new_coeff
[
j
+
1
]
+=
coeff
[
j
]
product_poly
.
show
()
new_coeff
[
j
]
-=
l
[
k
][
0
]
*
coeff
[
j
]
first_time
=
True
coeff
=
new_coeff
sum_poly
=
sum_poly
.
add
(
product_poly
)
sum_poly
.
show
()
#Somme des coeffs
list_p
=
[
0
]
*
len
(
l
)
for
s
in
range
(
len
(
l
)):
return
sum_poly
poly
[
s
]
+=
y_i
*
coeff
[
s
]
return
poly
def
check_nb_error
(
l
:
list
,
p
:
polynome
)
->
int
:
def
check_nb_error
(
l
:
list
,
p
:
polynome
)
->
int
:
pass
pass
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
list_
=
[
1
,
2
,
3
]
list_
=
[(
0
,
1
),
(
1
,
2
),
(
2
,
3
)]
#print(list_)
poly
=
lagrange_compute
(
list_
)
poly
=
lagrange_compute
(
list_
)
poly
.
show
()
print
(
poly
)
#print(poly.evaluate(0))
Loading