Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tlibs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Scientific Software
Takin
tlibs
Commits
631ee715
Commit
631ee715
authored
Jun 26, 2019
by
Tobias WEBER
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added an epsilon to peak_finder
parent
cd167b6e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
19 deletions
+29
-19
fit/interpolation.h
fit/interpolation.h
+23
-13
helper/misc.h
helper/misc.h
+3
-3
math/geo.h
math/geo.h
+3
-3
No files found.
fit/interpolation.h
View file @
631ee715
...
...
@@ -276,21 +276,27 @@ T LinInterp<T>::operator()(T x) const
// ----------------------------------------------------------------------------
template
<
typename
T
>
void
find_peaks
(
std
::
size_t
iLen
,
const
T
*
px
,
const
T
*
py
,
unsigned
int
iOrder
,
void
find_peaks
(
std
::
size_t
iLen
,
const
T
*
_px
,
const
T
*
_
py
,
unsigned
int
iOrder
,
std
::
vector
<
T
>&
vecMaximaX
,
std
::
vector
<
T
>&
vecMaximaSize
,
std
::
vector
<
T
>&
vecMaximaWidth
,
std
::
size_t
iNumSpline
=
512
)
T
eps
=
tl
::
get_epsilon
<
T
>
(),
std
::
size_t
iNumSpline
=
512
)
{
BSpline
<
T
>
spline
(
iLen
,
px
,
py
,
iOrder
);
// allocate memory
std
::
unique_ptr
<
T
,
std
::
default_delete
<
T
[]
>>
uptrMem
{
new
T
[
6
*
iNumSpline
]};
T
*
px
=
uptrMem
.
get
()
+
0
*
iNumSpline
;
T
*
py
=
uptrMem
.
get
()
+
1
*
iNumSpline
;
T
*
pSplineX
=
uptrMem
.
get
()
+
2
*
iNumSpline
;
T
*
pSplineY
=
uptrMem
.
get
()
+
3
*
iNumSpline
;
T
*
pSplineDiff
=
uptrMem
.
get
()
+
4
*
iNumSpline
;
T
*
pSplineDiff2
=
uptrMem
.
get
()
+
5
*
iNumSpline
;
// allocate memory
std
::
unique_ptr
<
T
,
std
::
default_delete
<
T
[]
>>
uptrMem
{
new
T
[
4
*
iNumSpline
]};
T
*
pSplineX
=
uptrMem
.
get
();
T
*
pSplineY
=
uptrMem
.
get
()
+
iNumSpline
;
T
*
pSplineDiff
=
uptrMem
.
get
()
+
2
*
iNumSpline
;
T
*
pSplineDiff2
=
uptrMem
.
get
()
+
3
*
iNumSpline
;
// sort input values
std
::
copy
(
_px
,
_px
+
iLen
,
px
);
std
::
copy
(
_py
,
_py
+
iLen
,
py
);
tl
::
sort_2
<
T
*>
(
px
,
px
+
iLen
,
py
);
BSpline
<
T
>
spline
(
iLen
,
px
,
py
,
iOrder
);
const
T
*
pdyMin
=
std
::
min_element
(
py
,
py
+
iLen
);
for
(
std
::
size_t
iSpline
=
0
;
iSpline
<
iNumSpline
;
++
iSpline
)
...
...
@@ -304,10 +310,14 @@ void find_peaks(std::size_t iLen, const T* px, const T* py, unsigned int iOrder,
tl
::
diff
(
iNumSpline
,
pSplineX
,
pSplineY
,
pSplineDiff
);
tl
::
diff
(
iNumSpline
,
pSplineX
,
pSplineDiff
,
pSplineDiff2
);
std
::
vector
<
std
::
size_t
>
vecZeroes
=
tl
::
find_zeroes
<
T
>
(
iNumSpline
,
pSplineDiff
);
std
::
vector
<
std
::
size_t
>
vecZeroes
=
tl
::
find_zeroes
<
T
>
(
iNumSpline
,
pSplineDiff
,
eps
);
//std::ofstream ofDbg{"0.dat"};
//for(std::size_t i=0; i<iNumSpline; ++i)
// ofDbg << pSplineX[i] << "\t" << pSplineY[i] << "\t" << pSplineDiff[i] << "\t" << pSplineDiff2[i] << std::endl;
for
(
std
::
size_t
iZeroIdx
=
0
;
iZeroIdx
<
vecZeroes
.
size
();
++
iZeroIdx
)
for
(
std
::
size_t
iZeroIdx
=
0
;
iZeroIdx
<
vecZeroes
.
size
();
++
iZeroIdx
)
{
const
std
::
size_t
iZero
=
vecZeroes
[
iZeroIdx
];
...
...
@@ -332,7 +342,7 @@ void find_peaks(std::size_t iLen, const T* px, const T* py, unsigned int iOrder,
if
(
iMinIdxLeft
>=
0
)
{
dHeight
+=
(
pSplineY
[
iZero
]
-
pSplineY
[
iMinIdxLeft
]);
dWidth
+=
f
abs
((
pSplineX
[
iZero
]
-
pSplineX
[
iMinIdxLeft
]));
dWidth
+=
std
::
abs
((
pSplineX
[
iZero
]
-
pSplineX
[
iMinIdxLeft
]));
dDiv
+=
1.
;
}
...
...
@@ -340,7 +350,7 @@ void find_peaks(std::size_t iLen, const T* px, const T* py, unsigned int iOrder,
if
(
iMinIdxRight
>=
0
)
{
dHeight
+=
(
pSplineY
[
iZero
]
-
pSplineY
[
iMinIdxRight
]);
dWidth
+=
f
abs
((
pSplineX
[
iZero
]
-
pSplineX
[
iMinIdxRight
]));
dWidth
+=
std
::
abs
((
pSplineX
[
iZero
]
-
pSplineX
[
iMinIdxRight
]));
dDiv
+=
1.
;
}
...
...
helper/misc.h
View file @
631ee715
...
...
@@ -191,7 +191,7 @@ void sort_2(Iter begin1, Iter end1, Iter begin2)
pObj
[
i
].
vec
.
push_back
(
*
(
begin2
+
i
));
}
std
::
sort
(
pObj
,
pObj
+
N
,
comp_fkt
<
T
>
);
std
::
s
table_s
ort
(
pObj
,
pObj
+
N
,
comp_fkt
<
T
>
);
for
(
std
::
size_t
i
=
0
;
i
<
N
;
++
i
)
{
*
(
begin1
+
i
)
=
pObj
[
i
].
vec
[
0
];
...
...
@@ -219,7 +219,7 @@ void sort_3(Iter begin1, Iter end1, Iter begin2, Iter begin3)
pObj
[
i
].
vec
.
push_back
(
*
(
begin3
+
i
));
}
std
::
sort
(
pObj
,
pObj
+
N
,
comp_fkt
<
T
>
);
std
::
s
table_s
ort
(
pObj
,
pObj
+
N
,
comp_fkt
<
T
>
);
for
(
std
::
size_t
i
=
0
;
i
<
N
;
++
i
)
{
*
(
begin1
+
i
)
=
pObj
[
i
].
vec
[
0
];
...
...
@@ -243,7 +243,7 @@ t_cont<std::size_t> sorted_idx(const t_cont<t_val>& vec, t_func fkt)
for
(
std
::
size_t
i
=
0
;
i
<
vec
.
size
();
++
i
)
vecIdx
.
push_back
(
i
);
std
::
sort
(
vecIdx
.
begin
(),
vecIdx
.
end
(),
std
::
s
table_s
ort
(
vecIdx
.
begin
(),
vecIdx
.
end
(),
[
&
vec
,
&
fkt
]
(
std
::
size_t
iIdx0
,
std
::
size_t
iIdx1
)
->
bool
{
return
fkt
(
vec
[
iIdx0
],
vec
[
iIdx1
]);
...
...
math/geo.h
View file @
631ee715
...
...
@@ -1215,7 +1215,7 @@ public:
template
<
typename
T
=
double
>
std
::
vector
<
std
::
size_t
>
find_zeroes
(
std
::
size_t
N
,
const
T
*
pIn
)
std
::
vector
<
std
::
size_t
>
find_zeroes
(
std
::
size_t
N
,
const
T
*
pIn
,
T
eps
=
tl
::
get_epsilon
<
T
>
()
)
{
using
t_vec
=
ublas
::
vector
<
T
>
;
std
::
vector
<
std
::
size_t
>
vecIndices
;
...
...
@@ -1234,8 +1234,8 @@ std::vector<std::size_t> find_zeroes(std::size_t N, const T* pIn)
pos1
[
0
]
=
1.
;
pos1
[
1
]
=
pIn
[
i
+
1
];
Line
<
T
>
line
(
pos0
,
pos1
-
pos0
);
T
param
;
if
(
!
line
.
intersect
(
xaxis
,
param
))
T
param
{}
;
if
(
!
line
.
intersect
(
xaxis
,
param
,
eps
))
continue
;
t_vec
posInters
=
line
(
param
);
...
...
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