Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
alta
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
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
alta
alta
Commits
e2be5f02
Commit
e2be5f02
authored
May 12, 2015
by
Ludovic Courtès
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
data_storage: Initialize '_min' and '_max' in 'load_data_from_binary'.
parent
5e8cf8d2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
1 deletion
+27
-1
sources/core/data_storage.cpp
sources/core/data_storage.cpp
+19
-1
sources/tests/data-io.cpp
sources/tests/data-io.cpp
+8
-0
No files found.
sources/core/data_storage.cpp
View file @
e2be5f02
...
@@ -280,6 +280,15 @@ void load_data_from_binary(std::istream& in, const header& header, data& data)
...
@@ -280,6 +280,15 @@ void load_data_from_binary(std::istream& in, const header& header, data& data)
int
sample_count
=
header
[
"SAMPLE_COUNT"
];
int
sample_count
=
header
[
"SAMPLE_COUNT"
];
// Initialize the mininum and maximum values.
vec
min
(
dim
.
first
),
max
(
dim
.
first
);
for
(
int
k
=
0
;
k
<
dim
.
first
;
k
++
)
{
min
[
k
]
=
std
::
numeric_limits
<
double
>::
max
();
max
[
k
]
=
-
std
::
numeric_limits
<
double
>::
max
();
}
// TODO: Arrage to use mmap and make it zero-alloc and zero-copy.
// TODO: Arrage to use mmap and make it zero-alloc and zero-copy.
for
(
int
i
=
0
;
i
<
sample_count
;
i
++
)
for
(
int
i
=
0
;
i
<
sample_count
;
i
++
)
{
{
...
@@ -294,7 +303,16 @@ void load_data_from_binary(std::istream& in, const header& header, data& data)
...
@@ -294,7 +303,16 @@ void load_data_from_binary(std::istream& in, const header& header, data& data)
}
}
data
.
set
(
row
);
data
.
set
(
row
);
// Update min and max.
for
(
int
k
=
0
;
k
<
dim
.
first
;
k
++
)
{
min
[
k
]
=
std
::
min
(
min
[
k
],
row
[
k
]);
max
[
k
]
=
std
::
max
(
max
[
k
],
row
[
k
]);
}
}
}
// TODO: Factorize this in data::set.
data
.
setMin
(
min
);
data
.
setMax
(
max
);
}
}
sources/tests/data-io.cpp
View file @
e2be5f02
...
@@ -151,5 +151,13 @@ int main(int argc, char** argv)
...
@@ -151,5 +151,13 @@ int main(int argc, char** argv)
TEST_ASSERT
(
files_are_equal
(
temp_file1
,
temp_file2
));
TEST_ASSERT
(
files_are_equal
(
temp_file1
,
temp_file2
));
TEST_ASSERT
(
sample2
.
equals
(
sample3
));
TEST_ASSERT
(
sample2
.
equals
(
sample3
));
TEST_ASSERT
(
sample1
.
min
().
size
()
==
sample1
.
dimX
());
TEST_ASSERT
(
sample1
.
max
().
size
()
==
sample1
.
dimX
());
TEST_ASSERT
(
sample1
.
min
()
==
sample2
.
min
());
TEST_ASSERT
(
sample1
.
max
()
==
sample2
.
max
());
TEST_ASSERT
(
sample1
.
min
()
==
sample3
.
min
());
TEST_ASSERT
(
sample1
.
max
()
==
sample3
.
max
());
return
EXIT_SUCCESS
;
return
EXIT_SUCCESS
;
}
}
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