Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
xQML
xQML
Commits
4fd1b451
Commit
4fd1b451
authored
Feb 25, 2019
by
Syl
Browse files
Fixed testesti
parents
95c0c65b
516d8d99
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
73 additions
and
13 deletions
+73
-13
setup.py
setup.py
+10
-3
src/libcov.h
src/libcov.h
+1
-0
xqml/libcov.py
xqml/libcov.py
+2
-2
xqml/xqml.py
xqml/xqml.py
+8
-8
xqml/xqml_utils.py
xqml/xqml_utils.py
+52
-0
No files found.
setup.py
View file @
4fd1b451
...
...
@@ -11,17 +11,24 @@ try:
except
AttributeError
:
numpy_include
=
numpy
.
get_numpy_include
()
print
(
sys
.
argv
)
if
'--disable-openmp'
in
sys
.
argv
:
sys
.
argv
.
pop
(
sys
.
argv
.
index
(
'--disable-openmp'
))
USE_OPENMP
=
False
else
:
USE_OPENMP
=
True
if
'--icc'
in
sys
.
argv
:
sys
.
argv
.
pop
(
sys
.
argv
.
index
(
'--icc'
))
USE_ICC
=
True
else
:
USE_ICC
=
False
libs
=
[
'm'
]
use_icc
=
True
if
'--icc'
in
sys
.
argv
else
False
extra
=
[
'-std=c99'
]
if
use_icc
:
extra
=
[
'-std=gnu99'
]
if
USE_ICC
:
if
USE_OPENMP
:
libs
+=
[
'gomp'
,
'iomp5'
]
extra
+=
[
'-openmp'
]
...
...
src/libcov.h
View file @
4fd1b451
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
/* #include <chealpix.h> */
...
...
xqml/libcov.py
View file @
4fd1b451
...
...
@@ -12,8 +12,8 @@ import healpy as hp
import
math
from
scipy
import
special
from
simulation
import
extrapolpixwin
from
xqml_utils
import
getstokes
,
progress_bar
from
.
simulation
import
extrapolpixwin
from
.
xqml_utils
import
getstokes
,
progress_bar
import
_libcov
as
clibcov
...
...
xqml/xqml.py
View file @
4fd1b451
...
...
@@ -18,14 +18,14 @@ import random as rd
from
xqml_utils
import
getstokes
,
pd_inv
from
estimators
import
El
from
estimators
import
CovAB
from
estimators
import
CrossGisherMatrix
from
estimators
import
CrossWindowFunction
from
estimators
import
yQuadEstimator
,
ClQuadEstimator
from
estimators
import
biasQuadEstimator
from
libcov
import
compute_ds_dcb
,
S_bins_MC
,
compute_S
,
covth_bins_MC
,
compute_PlS
,
SignalCovMatrix
from
.
estimators
import
El
from
.
estimators
import
CovAB
from
.
estimators
import
CrossGisherMatrix
from
.
estimators
import
CrossWindowFunction
from
.
estimators
import
yQuadEstimator
,
ClQuadEstimator
from
.
estimators
import
biasQuadEstimator
from
.
libcov
import
compute_ds_dcb
,
S_bins_MC
,
compute_S
,
covth_bins_MC
,
compute_PlS
,
SignalCovMatrix
__all__
=
[
'xQML'
]
...
...
xqml/xqml_utils.py
View file @
4fd1b451
...
...
@@ -368,3 +368,55 @@ def IsInvertible(F):
# P *= binsnorm
# return P, Q, ell, ellval
class
Sym
(
np
.
ndarray
):
# wrapper class for numpy array for symmetric matrices. New attribute can pack matrix to optimize storage.
# Usage:
# If you have a symmetric matrix A as a shape (n,n) numpy ndarray, Sym(A).packed is a shape (n(n+1)/2,) numpy array
# that is a packed version of A. To convert it back, just wrap the flat list in Sym(). Note that Sym(Sym(A).packed)
def
__new__
(
cls
,
input_array
):
obj
=
np
.
asarray
(
input_array
).
view
(
cls
)
if
len
(
obj
.
shape
)
==
1
:
l
=
obj
.
copy
()
p
=
obj
.
copy
()
m
=
int
((
np
.
sqrt
(
8
*
len
(
obj
)
+
1
)
-
1
)
/
2
)
sqrt_m
=
np
.
sqrt
(
m
)
if
np
.
isclose
(
sqrt_m
,
np
.
round
(
sqrt_m
)):
A
=
np
.
zeros
((
m
,
m
))
for
i
in
range
(
m
):
A
[
i
,
i
:]
=
l
[:(
m
-
i
)]
A
[
i
:,
i
]
=
l
[:(
m
-
i
)]
l
=
l
[(
m
-
i
):]
obj
=
np
.
asarray
(
A
).
view
(
cls
)
obj
.
packed
=
p
else
:
raise
ValueError
(
'One dimensional input length must be a triangular number.'
)
elif
len
(
obj
.
shape
)
==
2
:
if
obj
.
shape
[
0
]
!=
obj
.
shape
[
1
]:
raise
ValueError
(
'Two dimensional input must be a square matrix.'
)
packed_out
=
[]
for
i
in
range
(
obj
.
shape
[
0
]):
packed_out
.
append
(
obj
[
i
,
i
:])
obj
.
packed
=
np
.
concatenate
(
packed_out
)
else
:
raise
ValueError
(
'Input array must be 1 or 2 dimensional.'
)
return
obj
def
__array_finalize__
(
self
,
obj
):
if
obj
is
None
:
return
self
.
packed
=
getattr
(
obj
,
'packed'
,
None
)
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