Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
empyre
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
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Teresa Weßels
empyre
Commits
4099f971
Commit
4099f971
authored
11 years ago
by
Jan Caron
Browse files
Options
Downloads
Plain Diff
Merge
parents
46722da9
d7979cc2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pyramid/numcore/phase_mag_real.pyx
+78
-0
78 additions, 0 deletions
pyramid/numcore/phase_mag_real.pyx
pyramid/phasemapper.py
+16
-0
16 additions, 0 deletions
pyramid/phasemapper.py
with
94 additions
and
0 deletions
pyramid/numcore/phase_mag_real.pyx
+
78
−
0
View file @
4099f971
...
...
@@ -100,3 +100,81 @@ def get_jacobi_core(
jacobi
[
row
,
u_column
]
=
u_phi
[
q
,
p
]
# v-component (note the minus!):
jacobi
[
row
,
v_column
]
=
-
v_phi
[
q
,
p
]
@cython.boundscheck
(
False
)
@cython.wraparound
(
False
)
def
get_jacobi_core
(
unsigned
int
v_dim
,
unsigned
int
u_dim
,
double
[:,
:]
v_phi
,
double
[:,
:]
u_phi
,
double
[:,
:]
jacobi
):
'''
DOCSTRING!
'''
# TODO: Docstring!!!
cdef
unsigned
int
i
,
j
,
p
,
q
,
p_min
,
p_max
,
q_min
,
q_max
,
u_column
,
v_column
,
row
for
j
in
range
(
v_dim
):
for
i
in
range
(
u_dim
):
# v_dim*u_dim columns for the u-component:
jacobi
[:,
i
+
u_dim
*
j
]
=
\
np
.
reshape
(
u_phi
[
v_dim
-
1
-
j
:(
2
*
v_dim
-
1
)
-
j
,
u_dim
-
1
-
i
:(
2
*
u_dim
-
1
)
-
i
],
-
1
)
# v_dim*u_dim columns for the v-component (note the minus!):
jacobi
[:,
u_dim
*
v_dim
+
i
+
u_dim
*
j
]
=
\
-
np
.
reshape
(
v_phi
[
v_dim
-
1
-
j
:(
2
*
v_dim
-
1
)
-
j
,
u_dim
-
1
-
i
:(
2
*
u_dim
-
1
)
-
i
],
-
1
)
@cython.boundscheck
(
False
)
@cython.wraparound
(
False
)
def
multiply_jacobi_core
(
unsigned
int
v_dim
,
unsigned
int
u_dim
,
double
[:,
:]
v_phi
,
double
[:,
:]
u_phi
,
double
[:]
vector
,
double
[:]
result
):
cdef
unsigned
int
s
,
i
,
j
,
u_min
,
u_max
,
v_min
,
v_max
,
ri
,
u
,
v
,
siz
cdef
double
v0
,
v1
siz
=
u_dim
*
v_dim
s
=
0
for
i
in
range
(
u_dim
):
for
j
in
range
(
v_dim
):
u_min
=
(
u_dim
-
1
)
-
i
v_min
=
(
v_dim
-
1
)
-
j
ri
=
0
for
v
in
range
(
v_min
,
v_min
+
v_dim
):
for
u
in
range
(
u_min
,
u_min
+
u_dim
):
result
[
ri
]
+=
vector
[
s
]
*
u_phi
[
v
,
u
]
result
[
ri
]
-=
vector
[
s
+
siz
]
*
v_phi
[
v
,
u
]
ri
+=
1
s
+=
1
@cython.boundscheck
(
False
)
@cython.wraparound
(
False
)
def
multiply_jacobi_core2
(
int
v_dim
,
int
u_dim
,
double
[:,
:]
v_phi
,
double
[:,
:]
u_phi
,
double
[:]
vector
,
double
[:]
result
):
cdef
int
s1
,
s2
,
i
,
j
,
u_min
,
u_max
,
v_min
,
v_max
,
ri
,
u
,
v
,
siz
,
j_min
,
j_max
,
i_min
,
i_max
siz
=
u_dim
*
v_dim
for
v
in
range
(
2
*
v_dim
-
1
):
for
u
in
range
(
2
*
u_dim
-
1
):
i_min
=
max
(
0
,
(
u_dim
-
1
)
-
u
)
i_max
=
min
(
u_dim
,
((
2
*
u_dim
)
-
1
)
-
u
)
for
i
in
range
(
i_min
,
i_max
):
s1
=
i
*
u_dim
s2
=
s1
+
siz
j_min
=
max
(
0
,
(
v_dim
-
1
)
-
v
)
j_max
=
min
(
v_dim
,
((
2
*
v_dim
)
-
1
)
-
v
)
u_min
=
(
u_dim
-
1
)
-
i
v_min
=
(
v_dim
-
1
)
-
j_min
ri
=
(
v
-
((
v_dim
-
1
)
-
j_min
))
*
u_dim
+
(
u
-
u_min
)
for
j
in
range
(
j_min
,
j_max
):
result
[
ri
]
+=
vector
[
s1
+
j
]
*
u_phi
[
v
,
u
]
result
[
ri
]
-=
vector
[
s2
+
j
]
*
v_phi
[
v
,
u
]
ri
+=
u_dim
This diff is collapsed.
Click to expand it.
pyramid/phasemapper.py
+
16
−
0
View file @
4099f971
...
...
@@ -25,6 +25,22 @@ C = 2.998E8 # speed of light in m/s
def
phase_mag
(
a
,
projection
,
b_0
=
1
,
kernel
=
None
):
'''
Calculate the magnetic phase from magnetization data.
def multiply_jacobi_core(self, vector):
v_dim, u_dim = self.dim
size = v_dim * u_dim
result = np.zeros(size)
nc.multiply_jacobi_core(
v_dim, u_dim, self.v, self.u, vector, result)
return result
def multiply_jacobi_core2(self, vector):
v_dim, u_dim = self.dim
size = v_dim * u_dim
result = np.zeros(size)
nc.multiply_jacobi_core2(
v_dim, u_dim, self.v, self.u, vector, result)
return result
Parameters
----------
...
...
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