Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
elpa
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
10
Issues
10
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Environments
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
elpa
elpa
Commits
69ecbce4
Commit
69ecbce4
authored
Oct 29, 2018
by
Sebastian Ohlmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update python example, make it simpler
parent
6f1b2a85
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
21 deletions
+20
-21
python/examples/example.py
python/examples/example.py
+20
-21
No files found.
python/examples/example.py
View file @
69ecbce4
#!/usr/bin/env python
import
numpy
as
np
from
pyelpa
import
ProcessorLayout
,
DistributedMatrix
,
Elpa
from
mpi4py
import
MPI
from
pyelpa
import
ProcessorLayout
,
DistributedMatrix
import
sys
# set some parameters for matrix layout
...
...
@@ -9,37 +8,37 @@ na = 1000
nev
=
200
nblk
=
16
# initialize processor layout, needed for calling ELPA
comm
=
MPI
.
COMM_WORLD
layout_p
=
ProcessorLayout
(
comm
)
# create distributed matrix
a
=
DistributedMatrix
.
from_comm_world
(
na
,
nev
,
nblk
)
# create arrays
a
=
DistributedMatrix
(
layout_p
,
na
,
nev
,
nblk
)
eigenvectors
=
DistributedMatrix
(
layout_p
,
na
,
nev
,
nblk
)
eigenvalues
=
np
.
zeros
(
na
,
dtype
=
np
.
float64
)
# initialize elpa
e
=
Elpa
.
from_distributed_matrix
(
a
)
# set input matrix (a.data) on this core (a is stored in a block-cyclic
# distributed layout; local size: a.na_rows x a.na_cols)
a
.
data
[:,
:]
=
np
.
random
.
rand
(
a
.
na_rows
,
a
.
na_cols
).
astype
(
np
.
float64
)
def
set_matrix
(
a
):
for
global_row
,
global_col
in
a
.
global_indices
():
a
.
set_data_for_global_index
(
global_row
,
global_col
,
global_row
*
global_col
)
print
(
"Call ELPA eigenvectors"
)
sys
.
stdout
.
flush
()
set_matrix
(
a
)
# now compute nev of na eigenvectors and eigenvalues
e
.
eigenvectors
(
a
.
data
,
eigenvalues
,
eigenvectors
.
data
)
data
=
a
.
compute_eigenvectors
()
eigenvalues
=
data
[
'eigenvalues'
]
eigenvectors
=
data
[
'eigenvectors'
]
print
(
"Done"
)
# now eigenvectors.data contains the local part of the eigenvector matrix
# which is stored in a block-cyclic distributed layout
# now eigenvalues contains all computed eigenvalues on all cores
# which is stored in a block-cyclic distributed layout and eigenvalues contains
# all computed eigenvalues on all cores
print
(
"Call ELPA eigenvalues"
)
sys
.
stdout
.
flush
()
set_matrix
(
a
)
# now compute nev of na eigenvalues
e
.
eigenvalues
(
a
.
data
,
eigenvalues
)
set_matrix
(
a
)
eigenvalues
=
a
.
compute_eigenvalues
()
print
(
"Done"
)
# now eigenvalues contains all computed eigenvalues on all cores
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment