***
Wartungsfenster jeden ersten Mittwoch vormittag im Monat
***
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jackknife
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
E138 Institute of Solid State Physics
E138-01 Computational Materials Science
Software
jackknife
Commits
c810432b
Commit
c810432b
authored
5 years ago
by
Patrick Kappl
Browse files
Options
Downloads
Patches
Plain Diff
Add function for generalized outer product
parent
51df3615
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
main.py
+44
-3
44 additions, 3 deletions
main.py
with
44 additions
and
3 deletions
main.py
+
44
−
3
View file @
c810432b
...
...
@@ -6,8 +6,49 @@ import sys
import
h5py
import
configparser
from
distutils.util
import
strtobool
from
functools
import
partial
def
calculate_outer_product_along_axis
(
a
,
b
,
axis
):
"""
Return the outer product of arrays ``a`` and ``b`` along the
given ``axis``.
Calculate the result according to the following formular:
.. math::
c_{(i_0)...(i_{j-1})kl(i_{j+1})...(i_{N-1})}=
a_{(i_0)...(i_{j-1})k(i_{j+1})...(i_{N-1})}
b_{(i_0)...(i_{j-1})l(i_{j+1})...(i_{N-1})},
where indices in braces are not implicitly summed over.
:var a: N-dimensional numpy array :math:`a`
:var b: N-dimensional numpy array :math:`b`
:var axis: axis :math:`j
\\
in [0,N)` along which the outer product is
calculated
:return: N+1-dimensional numpy array :math:`c`
"""
final_shape
=
list
(
a
.
shape
)
final_shape
.
insert
(
axis
,
a
.
shape
[
axis
])
if
axis
==
0
:
a
=
a
[
np
.
newaxis
,
...]
b
=
b
[
np
.
newaxis
,
...]
axis
=
1
if
axis
==
a
.
ndim
-
1
:
a
=
a
[...,
np
.
newaxis
]
b
=
b
[...,
np
.
newaxis
]
new_shape
=
(
np
.
product
(
a
.
shape
[:
axis
]),
a
.
shape
[
axis
],
np
.
product
(
a
.
shape
[
axis
+
1
:]))
a
=
a
.
reshape
(
new_shape
)
b
=
b
.
reshape
(
new_shape
)
result
=
np
.
empty
((
new_shape
[
0
],
new_shape
[
1
],
new_shape
[
1
],
new_shape
[
2
]))
for
i
in
range
(
new_shape
[
0
]):
for
j
in
range
(
new_shape
[
2
]):
result
[
i
,
:,
:,
j
]
=
np
.
outer
(
a
[
i
,
:,
j
],
np
.
conjugate
(
b
[
i
,
:,
j
]))
return
result
.
reshape
(
final_shape
)
# %%
config_file_name
=
"
jackknife.ini
"
n_processes
=
1
if
len
(
sys
.
argv
)
==
1
:
...
...
@@ -60,8 +101,8 @@ else:
# %%
# Do the Jackknife estimation
jackknife
=
jk
.
Jackknife
(
x_generator
,
n
,
f
,
adga
.
outer_product_of_self_energies
,
outer_product
=
partial
(
calculate_outer_product_along_axis
,
axis
=
2
)
jackknife
=
jk
.
Jackknife
(
x_generator
,
n
,
f
,
outer_product
,
general
[
"
output_file_prefix
"
],
strtobool
(
general
[
"
store_output_samples
"
]))
jackknife
.
do_estimation
()
...
...
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