Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Troubled Cell Detection
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Laura Christine Kühle
Troubled Cell Detection
Commits
9d4d5e6c
Commit
9d4d5e6c
authored
3 years ago
by
Laura Christine Kühle
Browse files
Options
Downloads
Patches
Plain Diff
Added documentation to 'Basis_Function'.
parent
b5eb2134
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Basis_Function.py
+176
-0
176 additions, 0 deletions
Basis_Function.py
with
176 additions
and
0 deletions
Basis_Function.py
+
176
−
0
View file @
9d4d5e6c
...
...
@@ -13,35 +13,121 @@ z = Symbol('z')
class
Vector
(
object
):
"""
Class for basis vector.
Attributes
----------
basis : np.array
Array of basis.
wavelet : np.array
Array of wavelet.
Methods
-------
get_basis_vector()
Returns basis vector.
get_wavelet_vector
Returns wavelet vector.
get_basis_projections()
Returns basis projections.
get_wavelet_projections()
Returns wavelet projections.
"""
def
__init__
(
self
,
polynomial_degree
):
"""
Initializes Vector.
Parameters
----------
polynomial_degree : int
Polynomial degree.
"""
self
.
_polynomial_degree
=
polynomial_degree
self
.
_basis
=
self
.
_build_basis_vector
(
x
)
self
.
_wavelet
=
self
.
_build_wavelet_vector
(
z
)
def
get_basis_vector
(
self
):
"""
Returns basis vector.
"""
return
self
.
_basis
def
_build_basis_vector
(
self
,
eval_point
):
"""
Constructs basis vector.
Parameters
----------
eval_point : float
Evaluation point.
Returns
-------
np.array
Vector containing basis evaluated at evaluation point.
"""
return
[]
def
get_wavelet_vector
(
self
):
"""
Returns wavelet vector.
"""
return
self
.
_wavelet
def
_build_wavelet_vector
(
self
,
eval_point
):
"""
Constructs wavelet vector.
Parameters
----------
eval_point : float
Evaluation point.
Returns
-------
np.array
Vector containing wavelet evaluated at evaluation point.
"""
return
[]
def
get_basis_projections
(
self
):
"""
Returns basis projection.
"""
pass
def
get_multiwavelet_projections
(
self
):
"""
Returns wavelet projection.
"""
pass
class
Legendre
(
Vector
):
"""
Class for Legendre basis.
"""
def
_build_basis_vector
(
self
,
eval_point
):
"""
Constructs basis vector.
Parameters
----------
eval_point : float
Evaluation point.
Returns
-------
np.array
Vector containing basis evaluated at evaluation point.
"""
return
self
.
_calculate_legendre_vector
(
eval_point
)
def
_calculate_legendre_vector
(
self
,
eval_point
):
"""
Constructs Legendre vector.
Parameters
----------
eval_point : float
Evaluation point.
Returns
-------
np.array
Vector containing Legendre polynomial evaluated at evaluation point.
"""
vector
=
[]
for
degree
in
range
(
self
.
_polynomial_degree
+
1
):
if
degree
==
0
:
...
...
@@ -57,12 +143,52 @@ class Legendre(Vector):
class
OrthonormalLegendre
(
Legendre
):
"""
Class for orthonormal Legendre basis.
Methods
-------
get_basis_projection()
Returns basis projection.
get_wavelet_projection()
Returns wavelet projection.
"""
def
_build_basis_vector
(
self
,
eval_point
):
"""
Constructs basis vector.
Parameters
----------
eval_point : float
Evaluation point.
Returns
-------
np.array
Vector containing basis evaluated at evaluation point.
"""
leg_vector
=
self
.
_calculate_legendre_vector
(
eval_point
)
return
[
leg_vector
[
degree
]
*
np
.
sqrt
(
degree
+
0.5
)
for
degree
in
range
(
self
.
_polynomial_degree
+
1
)]
def
_build_wavelet_vector
(
self
,
eval_point
):
"""
Constructs wavelet vector.
Parameters
----------
eval_point : float
Evaluation point.
Returns
-------
np.array
Vector containing wavelet evaluated at evaluation point.
Notes
-----
Hardcoded version only for now.
"""
degree
=
self
.
_polynomial_degree
if
degree
==
0
:
...
...
@@ -97,11 +223,35 @@ class OrthonormalLegendre(Legendre):
up to degree 4 for this application
'
)
def
get_basis_projections
(
self
):
"""
Returns basis projection.
Returns
-------
np.array
Array containing the basis projection based on the integrals of the product
of two basis vectors for each degree combination.
"""
basis_projection_left
=
self
.
_build_basis_matrix
(
z
,
0.5
*
(
z
-
1
))
basis_projection_right
=
self
.
_build_basis_matrix
(
z
,
0.5
*
(
z
+
1
))
return
basis_projection_left
,
basis_projection_right
def
_build_basis_matrix
(
self
,
first_param
,
second_param
):
"""
Constructs a basis matrix.
Parameters
----------
first_param : float
First parameter.
second_param : float
Second parameter.
Returns
-------
np.array
Matrix containing the integral of basis products.
"""
matrix
=
[]
for
i
in
range
(
self
.
_polynomial_degree
+
1
):
row
=
[]
...
...
@@ -114,11 +264,37 @@ class OrthonormalLegendre(Legendre):
return
matrix
def
get_multiwavelet_projections
(
self
):
"""
Returns wavelet projection.
Returns
-------
np.array
Array containing the multiwavelet projection based on the integrals of the product
of a basis vector and a wavelet vector for each degree combination.
"""
wavelet_projection_left
=
self
.
_build_multiwavelet_matrix
(
z
,
-
0.5
*
(
z
-
1
),
True
)
wavelet_projection_right
=
self
.
_build_multiwavelet_matrix
(
z
,
0.5
*
(
z
+
1
),
False
)
return
wavelet_projection_left
,
wavelet_projection_right
def
_build_multiwavelet_matrix
(
self
,
first_param
,
second_param
,
is_left_matrix
):
"""
Constructs a multiwavelet matrix.
Parameters
----------
first_param : float
First parameter.
second_param : float
Second parameter.
is_left_matrix : boolean
Flag whether the left matrix is calculated.
Returns
-------
np.array
Matrix containing the integral of products of a basis and a wavelet vector.
"""
matrix
=
[]
for
i
in
range
(
self
.
_polynomial_degree
+
1
):
row
=
[]
...
...
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