Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CT-INT-FGOTH
QMC_Master
Commits
16bce0c1
Commit
16bce0c1
authored
Aug 19, 2013
by
fgoth
Browse files
optimize calculation of covariance matrix.
parent
79bed14e
Changes
1
Hide whitespace changes
Inline
Side-by-side
common/jackknife.h
View file @
16bce0c1
...
...
@@ -152,6 +152,7 @@ errordata<typename Func::res_t > vecjackknife(Func func, const Cont& data, unsig
RetType
temp
=
jackmean
-
jackbin
[
k
];
fun_error
+=
temp
*
temp
;
}
typedef
typename
ToScalar
<
RetType
>::
RetType
ScalarType
;
auto
fac
=
typename
ToScalar
<
RetType
>::
RetType
(
data
.
size
()
-
1
);
fun_error
*=
fac
/
static_cast
<
double
>
(
data
.
size
());
fun_error
=
std
::
sqrt
(
fun_error
);
...
...
@@ -162,17 +163,21 @@ errordata<typename Func::res_t > vecjackknife(Func func, const Cont& data, unsig
#ifdef _OPENMP
double
start
=
omp_get_wtime
();
#endif
std
::
valarray
<
typename
ToScalar
<
RetType
>::
Ret
Type
>
cov
(
numcont
*
numcont
);
std
::
valarray
<
Scalar
Type
>
cov
(
numcont
*
numcont
);
#pragma omp parallel for schedule(dynamic)
for
(
uint
y
=
0
;
y
<
numcont
;
++
y
)
{
ScalarType
fmy
=
fun_mean
[
y
];
for
(
uint
x
=
0
;
x
<
numcont
;
++
x
)
{
ScalarType
fmx
=
fun_mean
[
x
];
ScalarType
coventry
(
0
);
for
(
uint
k
=
0
;
k
<
data
.
size
();
++
k
)
{
cov
[
y
*
numcont
+
x
]
+=
(
jackbin
[
k
][
x
]
-
f
un_mean
[
x
]
)
*
(
jackbin
[
k
][
y
]
-
f
un_mean
[
y
]
);
coventry
+=
(
jackbin
[
k
][
x
]
-
f
mx
)
*
(
jackbin
[
k
][
y
]
-
f
my
);
}
cov
[
y
*
numcont
+
x
]
*=
(
data
.
size
()
-
1.0
)
/
data
.
size
();
coventry
*=
(
data
.
size
()
-
1.0
)
/
data
.
size
();
cov
[
y
*
numcont
+
x
]
=
coventry
;
}
}
#ifdef _OPENMP
...
...
Write
Preview
Supports
Markdown
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