Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
L
load_leveller
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
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
Lukas Weber
load_leveller
Commits
07ab802f
Commit
07ab802f
authored
Nov 20, 2019
by
sw440870
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
can now add a valarray
parent
5e271ed5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
0 deletions
+29
-0
src/observable.h
src/observable.h
+29
-0
No files found.
src/observable.h
View file @
07ab802f
...
...
@@ -5,6 +5,7 @@
#include <map>
#include <string>
#include <vector>
#include <valarray>
namespace
loadl
{
...
...
@@ -20,6 +21,9 @@ public:
template
<
class
T
>
void
add
(
const
std
::
vector
<
T
>
&
);
template
<
class
T
>
void
add
(
const
std
::
valarray
<
T
>
&
);
void
checkpoint_write
(
const
iodump
::
group
&
dump_file
)
const
;
// This will empty the cache of already completed bins
...
...
@@ -73,4 +77,29 @@ void observable::add(const std::vector<T> &val) {
current_bin_filling_
=
0
;
}
}
template
<
class
T
>
void
observable
::
add
(
const
std
::
valarray
<
T
>
&
val
)
{
if
(
vector_length_
!=
val
.
size
())
{
throw
std
::
runtime_error
{
fmt
::
format
(
"observable::add: added vector has unexpected size ({}). Observable was "
"initialized with vector length ({})"
,
val
.
size
(),
vector_length_
)};
}
for
(
size_t
j
=
0
;
j
<
vector_length_
;
++
j
)
samples_
[
j
+
current_bin_
*
vector_length_
]
+=
static_cast
<
double
>
(
val
[
j
]);
current_bin_filling_
++
;
if
(
current_bin_filling_
==
bin_length_
)
{
// need to start a new bin next time
if
(
bin_length_
>
1
)
{
for
(
size_t
j
=
0
;
j
<
vector_length_
;
++
j
)
{
samples_
[
current_bin_
*
vector_length_
+
j
]
/=
bin_length_
;
}
}
current_bin_
++
;
samples_
.
resize
((
current_bin_
+
1
)
*
vector_length_
);
current_bin_filling_
=
0
;
}
}
}
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