Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F11221279
test_LocalPolyFilter1D.cc
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
test_LocalPolyFilter1D.cc
View Options
#include
"UnitTest++.h"
#include
"test_utils.hh"
#include
"npstat/stat/LocalPolyFilter1D.hh"
#include
"npstat/stat/Filter1DBuilders.hh"
#include
"npstat/stat/Distributions1D.hh"
#include
"geners/Record.hh"
#include
"geners/Reference.hh"
#include
"geners/StringArchive.hh"
using
namespace
npstat
;
using
namespace
std
;
namespace
{
TEST
(
LocalPolyFilter1D_copy
)
{
Gauss1D
g
(
0
,
1
);
StretchingFilter1DBuilder
b
(
&
g
,
0.1
);
LocalPolyFilter1D
f
(
0
,
3
,
b
,
200U
);
LocalPolyFilter1D
f2
(
f
);
CHECK
(
f
==
f2
);
CPP11_auto_ptr
<
LocalPolyFilter1D
>
ds
=
f
.
doublyStochasticFilter
(
0.0
,
0
);
CHECK
(
*
ds
==
f
);
gs
::
StringArchive
ar
;
ar
<<
gs
::
Record
(
f
,
"n1"
,
"c1"
);
gs
::
Reference
<
LocalPolyFilter1D
>
ref1
(
ar
,
"n1"
,
"c1"
);
CPP11_auto_ptr
<
LocalPolyFilter1D
>
read
=
ref1
.
get
(
0
);
CHECK
(
*
read
==
f
);
DummyLocalPolyFilter1D
dummy
(
100
);
ar
<<
gs
::
Record
(
dynamic_cast
<
LocalPolyFilter1D
&>
(
dummy
),
"n2"
,
"c2"
);
gs
::
Reference
<
LocalPolyFilter1D
>
ref2
(
ar
,
"n2"
,
"c2"
);
read
=
ref2
.
get
(
0
);
CHECK
(
*
read
==
dummy
);
}
TEST
(
LocalPolyFilter1D_matrix
)
{
const
unsigned
nbins
=
100U
;
const
double
interval
=
3.0
;
const
double
eps
=
1.0e-12
;
Gauss1D
g
(
0
,
0.5
);
StretchingFilter1DBuilder
b
(
&
g
,
interval
/
nbins
);
LocalPolyFilter1D
f
(
0
,
5
,
b
,
nbins
);
const
Matrix
<
double
>&
fm
=
f
.
getFilterMatrix
();
double
in
[
nbins
],
out
[
nbins
];
for
(
unsigned
icycle
=
0
;
icycle
<
10
;
++
icycle
)
{
for
(
unsigned
i
=
0
;
i
<
nbins
;
++
i
)
in
[
i
]
=
test_rng
();
f
.
filter
(
in
,
nbins
,
out
);
const
Matrix
<
double
>&
mout
=
fm
.
timesVector
(
in
,
nbins
);
const
double
*
out2
=
mout
.
data
();
for
(
unsigned
i
=
0
;
i
<
nbins
;
++
i
)
CHECK_CLOSE
(
out
[
i
],
out2
[
i
],
eps
);
}
// Test row stochasticity
for
(
unsigned
i
=
0
;
i
<
nbins
;
++
i
)
CHECK_CLOSE
(
1.0
,
fm
.
rowSum
(
i
),
eps
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Wed, May 14, 10:10 AM (1 d, 12 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5111062
Default Alt Text
test_LocalPolyFilter1D.cc (1 KB)
Attached To
rNPSTATSVN npstatsvn
Event Timeline
Log In to Comment