Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Thomas Peters
NIFTy
Commits
01082932
Commit
01082932
authored
Apr 20, 2017
by
Martin Reinecke
Browse files
de-cythonize
parent
76cfd35f
Changes
4
Hide whitespace changes
Inline
Side-by-side
nifty/operators/fft_operator/transformations/lm_transformation_factory.py
x
→
nifty/operators/fft_operator/transformations/lm_transformation_factory.py
View file @
01082932
import
numpy
as
np
cimport
numpy
as
np
def
buildLm
(
inp
,
**
kwargs
):
if
inp
.
dtype
==
np
.
dtype
(
'float32'
):
...
...
@@ -14,40 +12,36 @@ def buildIdx(inp, **kwargs):
else
:
return
_buildIdx
(
inp
,
**
kwargs
)
cpdef
np
.
ndarray
[
np
.
float32_t
,
ndim
=
1
]
_buildIdx_f
(
np
.
ndarray
[
np
.
complex64_t
,
ndim
=
1
]
nr
,
np
.
int_t
lmax
):
cdef
np
.
int
size
=
(
lmax
+
1
)
*
(
lmax
+
1
)
def
_buildIdx_f
(
nr
,
lmax
):
size
=
(
lmax
+
1
)
*
(
lmax
+
1
)
cdef
np
.
ndarray
final
=
np
.
zeros
([
size
],
dtype
=
np
.
float32
)
final
=
np
.
zeros
([
size
],
dtype
=
np
.
float32
)
final
[
0
:
lmax
+
1
]
=
nr
[
0
:
lmax
+
1
].
real
final
[
lmax
+
1
::
2
]
=
np
.
sqrt
(
2
)
*
nr
[
lmax
+
1
:].
real
final
[
lmax
+
2
::
2
]
=
np
.
sqrt
(
2
)
*
nr
[
lmax
+
1
:].
imag
return
final
cpdef
np
.
ndarray
[
np
.
float64_t
,
ndim
=
1
]
_buildIdx
(
np
.
ndarray
[
np
.
complex128_t
,
ndim
=
1
]
nr
,
np
.
int_t
lmax
):
cdef
np
.
int
size
=
(
lmax
+
1
)
*
(
lmax
+
1
)
def
_buildIdx
(
nr
,
lmax
):
size
=
(
lmax
+
1
)
*
(
lmax
+
1
)
cdef
np
.
ndarray
final
=
np
.
zeros
([
size
],
dtype
=
np
.
float64
)
final
=
np
.
zeros
([
size
],
dtype
=
np
.
float64
)
final
[
0
:
lmax
+
1
]
=
nr
[
0
:
lmax
+
1
].
real
final
[
lmax
+
1
::
2
]
=
np
.
sqrt
(
2
)
*
nr
[
lmax
+
1
:].
real
final
[
lmax
+
2
::
2
]
=
np
.
sqrt
(
2
)
*
nr
[
lmax
+
1
:].
imag
return
final
cpdef
np
.
ndarray
[
np
.
complex64_t
,
ndim
=
1
]
_buildLm_f
(
np
.
ndarray
[
np
.
float32_t
,
ndim
=
1
]
nr
,
np
.
int_t
lmax
):
cdef
np
.
int
size
=
(
len
(
nr
)
-
lmax
-
1
)
/
2
+
lmax
+
1
def
_buildLm_f
(
nr
,
lmax
):
size
=
(
len
(
nr
)
-
lmax
-
1
)
/
2
+
lmax
+
1
cdef
np
.
ndarray
res
=
np
.
zeros
([
size
],
dtype
=
np
.
complex64
)
res
=
np
.
zeros
([
size
],
dtype
=
np
.
complex64
)
res
[
0
:
lmax
+
1
]
=
nr
[
0
:
lmax
+
1
]
res
[
lmax
+
1
:]
=
np
.
sqrt
(
0.5
)
*
(
nr
[
lmax
+
1
::
2
]
+
1j
*
nr
[
lmax
+
2
::
2
])
return
res
cpdef
np
.
ndarray
[
np
.
complex128_t
,
ndim
=
1
]
_buildLm
(
np
.
ndarray
[
np
.
float64_t
,
ndim
=
1
]
nr
,
np
.
int_t
lmax
):
cdef
np
.
int
size
=
(
len
(
nr
)
-
lmax
-
1
)
/
2
+
lmax
+
1
def
_buildLm
(
nr
,
lmax
):
size
=
(
len
(
nr
)
-
lmax
-
1
)
/
2
+
lmax
+
1
cdef
np
.
ndarray
res
=
np
.
zeros
([
size
],
dtype
=
np
.
complex128
)
res
=
np
.
zeros
([
size
],
dtype
=
np
.
complex128
)
res
[
0
:
lmax
+
1
]
=
nr
[
0
:
lmax
+
1
]
res
[
lmax
+
1
:]
=
np
.
sqrt
(
0.5
)
*
(
nr
[
lmax
+
1
::
2
]
+
1j
*
nr
[
lmax
+
2
::
2
])
return
res
nifty/spaces/lm_space/lm_helper.pyx
deleted
100644 → 0
View file @
76cfd35f
import
numpy
as
np
cimport
numpy
as
np
cpdef
_distance_array_helper
(
np
.
ndarray
[
np
.
int_t
]
index_array
,
np
.
int_t
lmax
):
cdef
np
.
int
size
=
(
lmax
+
1
)
*
(
lmax
+
1
)
cdef
np
.
ndarray
res
=
np
.
zeros
([
len
(
index_array
)],
dtype
=
np
.
float128
)
for
idx
,
index_full
in
enumerate
(
index_array
):
if
index_full
<=
lmax
:
index_half
=
index_full
else
:
if
(
index_full
-
lmax
)
%
2
==
0
:
index_half
=
(
index_full
+
lmax
)
/
2
;
else
:
index_half
=
(
index_full
+
lmax
+
1
)
/
2
;
m
=
(
np
.
ceil
(((
2
*
lmax
+
1
)
-
np
.
sqrt
((
2
*
lmax
+
1
)
**
2
-
8
*
(
index_half
-
lmax
)))
/
2
)).
astype
(
int
)
res
[
idx
]
=
index_half
-
m
*
(
2
*
lmax
+
1
-
m
)
//
2
return
res
nifty/spaces/lm_space/lm_space.py
View file @
01082932
...
...
@@ -25,13 +25,18 @@ from nifty.spaces.space import Space
from
nifty.config
import
nifty_configuration
as
gc
,
\
dependency_injector
as
gdi
from
lm_helper
import
_distance_array_helper
from
d2o
import
arange
gl
=
gdi
.
get
(
'libsharp_wrapper_gl'
)
hp
=
gdi
.
get
(
'healpy'
)
def
_distance_array_helper
(
index_array
,
lmax
):
u
=
2
*
lmax
+
1
index_half
=
(
index_array
+
np
.
minimum
(
lmax
,
index_array
)
+
1
)
//
2
m
=
(
np
.
ceil
((
u
-
np
.
sqrt
(
u
*
u
-
8
*
(
index_half
-
lmax
)))
/
2
)).
astype
(
int
)
res
=
(
index_half
-
m
*
(
u
-
m
)
//
2
).
astype
(
np
.
float64
)
return
res
class
LMSpace
(
Space
):
"""
...
...
setup.py
View file @
01082932
...
...
@@ -35,9 +35,6 @@ setup(name="ift_nifty",
package_dir
=
{
"nifty"
:
"nifty"
},
zip_safe
=
False
,
ext_modules
=
cythonize
([
"nifty/operators/fft_operator/transformations/"
"lm_transformation_factory.pyx"
,
"nifty/spaces/lm_space/lm_helper.pyx"
,
"nifty/operators/smoothing_operator/smooth_util.pyx"
]),
include_dirs
=
[
numpy
.
get_include
()],
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment