Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gext
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
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Michele Nottoli
gext
Commits
63489817
Commit
63489817
authored
1 year ago
by
Michele Nottoli
Browse files
Options
Downloads
Patches
Plain Diff
Converted diff coefficients to normal coefficients.
parent
8685c877
No related branches found
No related tags found
No related merge requests found
Pipeline
#2065
failed
1 year ago
Stage: test
Stage: lint
Stage: coverage
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gext/fitting.py
+8
-15
8 additions, 15 deletions
gext/fitting.py
with
8 additions
and
15 deletions
gext/fitting.py
+
8
−
15
View file @
63489817
...
@@ -76,22 +76,13 @@ class DiffFitting(AbstractFitting):
...
@@ -76,22 +76,13 @@ class DiffFitting(AbstractFitting):
if
self
.
options
[
"
regularization
"
]
>
0.0
:
if
self
.
options
[
"
regularization
"
]
>
0.0
:
a
+=
np
.
identity
(
len
(
b
))
*
self
.
options
[
"
regularization
"
]
a
+=
np
.
identity
(
len
(
b
))
*
self
.
options
[
"
regularization
"
]
coefficients
=
np
.
linalg
.
solve
(
a
,
b
)
coefficients
=
np
.
linalg
.
solve
(
a
,
b
)
return
np
.
array
(
coefficients
,
dtype
=
np
.
float64
)
def
linear_combination
(
self
,
vectors
:
List
[
np
.
ndarray
],
# Convert diff coefficients to normal coefficients (like in
coefficients
:
np
.
ndarray
)
->
np
.
ndarray
:
# least square fitting)
"""
Given a set of vectors (or matrices) and the corresponding
coefficients
=
np
.
concatenate
((
coefficients
,
[
1.0
-
np
.
sum
(
coefficients
)]))
coefficients, build their linear combination.
"""
if
len
(
vectors
)
==
1
:
return
coefficients
raise
ValueError
(
"
DiffFitting does not work for one vector
"
)
result
=
np
.
zeros
(
vectors
[
0
].
shape
,
dtype
=
np
.
float64
)
diff_vectors
=
[]
for
i
in
range
(
1
,
len
(
vectors
)):
diff_vectors
.
append
(
vectors
[
i
-
1
]
-
vectors
[
-
1
])
for
coeff
,
vector
in
zip
(
coefficients
,
diff_vectors
):
result
+=
vector
*
coeff
result
=
result
+
vectors
[
-
1
]
return
result
class
LeastSquare
(
AbstractFitting
):
class
LeastSquare
(
AbstractFitting
):
...
@@ -158,6 +149,8 @@ class QuasiTimeReversible(AbstractFitting):
...
@@ -158,6 +149,8 @@ class QuasiTimeReversible(AbstractFitting):
a
+=
np
.
identity
(
len
(
b
))
*
self
.
options
[
"
regularization
"
]
a
+=
np
.
identity
(
len
(
b
))
*
self
.
options
[
"
regularization
"
]
coefficients
=
np
.
linalg
.
solve
(
a
,
b
)
coefficients
=
np
.
linalg
.
solve
(
a
,
b
)
# Convert quasi time reversible coefficients to normal
# coefficients (like in least square fitting)
if
q
==
1
:
if
q
==
1
:
full_coefficients
=
np
.
concatenate
(([
-
1.0
],
coefficients
))
full_coefficients
=
np
.
concatenate
(([
-
1.0
],
coefficients
))
elif
q
%
2
==
0
:
elif
q
%
2
==
0
:
...
...
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