Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
common
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Alexander Lapshin
common
Commits
29030586
Commit
29030586
authored
Apr 23, 2021
by
Alexander Lapshin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bisection search now template, add new load json handler
parent
8ae807ab
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
3 deletions
+28
-3
json_functions_bno.h
json/json_functions_bno.h
+25
-0
TimeFunctions.h
utils/TimeFunctions.h
+1
-2
xalgorithm.h
utils/xalgorithm.h
+2
-1
No files found.
json/json_functions_bno.h
View file @
29030586
...
...
@@ -5,6 +5,31 @@
#include "TimeFunctions.h"
#include "json_functions.h"
static
bool
loadjson
(
const
jsonval
&
parent
,
const
std
::
string
&
key
,
std
::
vector
<
TimeJD
>&
vec
,
const
bool
exist
=
true
,
bool
*
loaded
=
nullptr
)
{
jsonval
::
ConstMemberIterator
itr
;
if
(
!
extract_value
(
parent
,
key
,
exist
,
loaded
,
itr
))
{
return
false
;
}
const
jsonval
&
a
=
itr
->
value
;
if
(
!
a
.
IsArray
())
{
throw
Exp
()
<<
"error: element is not an array"
;
}
for
(
jsonval
::
ConstValueIterator
it
=
a
.
Begin
();
it
!=
a
.
End
();
++
it
)
{
if
(
it
->
IsString
())
{
vec
.
emplace_back
(
StrToDate
(
it
->
GetString
()));
}
else
{
throw
Exp
()
<<
"error: unsupported type"
;
}
}
return
true
;
}
static
void
loadjson
(
const
jsonval
&
parent
,
const
std
::
string
&
key
,
TimeJD
&
value
,
bool
exist
=
true
,
bool
*
loaded
=
nullptr
)
{
const
jsonval
::
ConstMemberIterator
itr
=
parent
.
FindMember
(
key
.
c_str
());
...
...
utils/TimeFunctions.h
View file @
29030586
...
...
@@ -501,6 +501,5 @@ inline TimeJD get_current_time()
StrToDate
(
s_now
,
now
);
//return StrToDate("16/09/2020 09:00:00");
return
now
;
}
utils/xalgorithm.h
View file @
29030586
...
...
@@ -112,11 +112,12 @@ inline double golden_section_search_stdf(
}
}
template
<
typename
T
>
inline
double
bisection_search_stdf
(
double
a
,
double
b
,
const
double
accuracy
,
const
std
::
function
<
bool
(
const
double
&
)
>&
f
const
std
::
function
<
T
(
const
double
&
)
>&
f
)
{
//f(a) should not be equal f(b) at the first step
...
...
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