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
303a6372
Commit
303a6372
authored
May 06, 2020
by
Alexander Lapshin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
7d654472
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
8 deletions
+61
-8
TextFunctions.h
utils/TextFunctions.h
+59
-6
ephinterp.cpp
utils/ephinterp.cpp
+2
-2
No files found.
utils/TextFunctions.h
View file @
303a6372
#pragma once
#include <charconv>
#include <array>
#include <iostream>
#include <sstream>
#include <fstream>
...
...
@@ -15,7 +17,7 @@
#define SPACES " \t\r\n"
static
std
::
string
ToStr
(
const
int
arg
,
const
int
leading_zeros
=
0
)
static
std
::
string
ToStr
(
const
int
arg
,
const
int
leading_zeros
)
{
std
::
ostringstream
ss
;
if
(
leading_zeros
)
{
...
...
@@ -25,7 +27,7 @@ static std::string ToStr(const int arg, const int leading_zeros = 0)
return
ss
.
str
();
}
static
std
::
string
ToStr
(
const
size_t
arg
,
const
int
leading_zeros
=
0
)
static
std
::
string
ToStr
(
const
size_t
arg
,
const
int
leading_zeros
)
{
std
::
ostringstream
ss
;
if
(
leading_zeros
)
{
...
...
@@ -35,13 +37,64 @@ static std::string ToStr(const size_t arg, const int leading_zeros = 0)
return
ss
.
str
();
}
static
std
::
string
ToStr
(
const
double
arg
)
template
<
typename
T
>
void
hangle_to_chars_error
(
const
std
::
to_chars_result
&
res
,
const
T
&
arg
)
{
std
::
ostringstream
ss
;
ss
<<
arg
;
return
ss
.
str
();
if
(
res
.
ec
==
std
::
errc
::
invalid_argument
)
{
throw
Exp
()
<<
"failed to convert value ["
<<
arg
<<
"] to string, invalid argument"
;
}
if
(
res
.
ec
==
std
::
errc
::
result_out_of_range
)
{
throw
Exp
()
<<
"failed to convert value ["
<<
arg
<<
"] to string, out of range"
;
}
throw
Exp
()
<<
"failed to convert value ["
<<
arg
<<
"] to string"
;
}
static
std
::
string
ToStr
(
const
int
arg
)
{
std
::
array
<
char
,
32
>
buf
;
const
auto
res
=
std
::
to_chars
(
buf
.
data
(),
buf
.
data
()
+
buf
.
size
(),
arg
);
if
(
res
.
ec
==
std
::
errc
())
{
return
std
::
string
(
buf
.
data
(),
res
.
ptr
-
buf
.
data
());
}
hangle_to_chars_error
(
res
,
arg
);
return
""
;
}
static
std
::
string
ToStr
(
const
size_t
arg
)
{
std
::
array
<
char
,
32
>
buf
;
const
auto
res
=
std
::
to_chars
(
buf
.
data
(),
buf
.
data
()
+
buf
.
size
(),
arg
);
if
(
res
.
ec
==
std
::
errc
())
{
return
std
::
string
(
buf
.
data
(),
res
.
ptr
-
buf
.
data
());
}
hangle_to_chars_error
(
res
,
arg
);
return
""
;
}
static
std
::
string
ToStr
(
const
double
arg
)
{
std
::
array
<
char
,
32
>
buf
;
const
auto
res
=
std
::
to_chars
(
buf
.
data
(),
buf
.
data
()
+
buf
.
size
(),
arg
);
if
(
res
.
ec
==
std
::
errc
())
{
return
std
::
string
(
buf
.
data
(),
res
.
ptr
-
buf
.
data
());
}
hangle_to_chars_error
(
res
,
arg
);
return
""
;
}
static
std
::
string
ToStr
(
const
double
value
,
const
int
precision
)
{
...
...
utils/ephinterp.cpp
View file @
303a6372
...
...
@@ -86,7 +86,7 @@ int cinterp_pvac(
/* Position */
if
(
j
<
3
)
{
if
(
fabs
(
ephi
.
outv
[
j
+
3
][
0
])
>
1.e-10
)
{
/* Use velocities if they exist (hermite) */
/* Use velocities if they exist
s
(hermite) */
hermite
(
pindex
,
2
,
ephi
.
jds
,
&
ephi
.
outv
[
j
][
0
],
&
ephi
.
outv
[
j
+
3
][
0
],
ephi
.
nv
,
10
,
itime
,
&
outvec
[
j
],
&
vz
,
ircode
);
}
else
{
...
...
@@ -95,7 +95,7 @@ int cinterp_pvac(
}
}
/* Velocity */
/* Interpolate if they exist */
/* Interpolate if they exist
s
*/
else
if
(
fabs
(
ephi
.
outv
[
j
][
0
])
>
1.e-10
)
{
hermite
(
pindex
,
1
,
ephi
.
jds
,
&
ephi
.
outv
[
j
][
0
],
&
z
,
ephi
.
nv
,
10
,
itime
,
&
outvec
[
j
],
&
vz
,
ircode
);
}
...
...
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