Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
openfpm_io
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sbalzarini Lab
Software
Parallel Computing
OpenFPM
openfpm_io
Commits
69308d7f
Commit
69308d7f
authored
9 years ago
by
Pietro Incardona
Browse files
Options
Downloads
Patches
Plain Diff
Added missing files
parent
f6a17078
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Makefile.am
+3
-0
3 additions, 0 deletions
Makefile.am
src/csv_multiarray.hpp
+204
-0
204 additions, 0 deletions
src/csv_multiarray.hpp
src/util.hpp
+172
-0
172 additions, 0 deletions
src/util.hpp
with
379 additions
and
0 deletions
Makefile.am
0 → 100755
+
3
−
0
View file @
69308d7f
SUBDIRS
=
src
bin_PROGRAMS
=
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/csv_multiarray.hpp
0 → 100644
+
204
−
0
View file @
69308d7f
/*
* csv_multiarray_copy.hpp
*
* Created on: Jun 20, 2015
* Author: i-bird
*/
#ifndef CSV_MULTIARRAY_COPY_HPP_
#define CSV_MULTIARRAY_COPY_HPP_
/*! \brief This class is an helper to produce csv headers from multi-array
*
* Usage:
*
* \code{.cpp}
*
* float src[3];
*
* std::stringstream str;
* csv_col_str<float[3]> cp(std::string("test"),str);
*
* std::cout << str.str() << "\n";
*
* \endcode
*
* Will produce ",test[0],test[1],test[2]"
*
*/
template
<
typename
T
>
struct
csv_col_str
{
inline
csv_col_str
(
std
::
string
prp
,
std
::
stringstream
&
str
)
{
str
<<
","
<<
prp
;
}
};
//! Partial specialization for N=1 1D-Array
template
<
typename
T
,
size_t
N1
>
struct
csv_col_str
<
T
[
N1
]
>
{
inline
csv_col_str
(
std
::
string
prp
,
std
::
stringstream
&
str
)
{
for
(
size_t
i
=
0
;
i
<
N1
;
i
++
)
str
<<
","
<<
prp
<<
"_"
<<
"["
<<
i
<<
"]"
;
}
};
//! Partial specialization for N=2 2D-Array
template
<
typename
T
,
size_t
N1
,
size_t
N2
>
struct
csv_col_str
<
T
[
N1
][
N2
]
>
{
inline
csv_col_str
(
std
::
string
prp
,
std
::
stringstream
&
str
)
{
for
(
size_t
i1
=
0
;
i1
<
N1
;
i1
++
)
{
for
(
size_t
i2
=
0
;
i2
<
N2
;
i2
++
)
{
str
<<
","
<<
prp
<<
"_"
<<
"["
<<
i1
<<
"]"
<<
"["
<<
i2
<<
"]"
;
}
}
}
};
//! Partial specialization for N=3
template
<
typename
T
,
size_t
N1
,
size_t
N2
,
size_t
N3
>
struct
csv_col_str
<
T
[
N1
][
N2
][
N3
]
>
{
inline
csv_col_str
(
std
::
string
prp
,
std
::
stringstream
&
str
)
{
for
(
size_t
i1
=
0
;
i1
<
N1
;
i1
++
)
{
for
(
size_t
i2
=
0
;
i2
<
N2
;
i2
++
)
{
for
(
size_t
i3
=
0
;
i3
<
N3
;
i3
++
)
{
str
<<
","
<<
prp
<<
"_"
<<
"["
<<
i1
<<
"]"
<<
"["
<<
i2
<<
"]"
<<
"["
<<
i3
<<
"]"
;
}
}
}
}
};
//! Partial specialization for N=4
template
<
typename
T
,
size_t
N1
,
size_t
N2
,
size_t
N3
,
size_t
N4
>
struct
csv_col_str
<
T
[
N1
][
N2
][
N3
][
N4
]
>
{
inline
csv_col_str
(
std
::
string
prp
,
std
::
stringstream
&
str
)
{
for
(
size_t
i1
=
0
;
i1
<
N1
;
i1
++
)
{
for
(
size_t
i2
=
0
;
i2
<
N2
;
i2
++
)
{
for
(
size_t
i3
=
0
;
i3
<
N3
;
i3
++
)
{
for
(
size_t
i4
=
0
;
i4
<
N4
;
i4
++
)
{
str
<<
","
<<
prp
<<
"_"
<<
"["
<<
i1
<<
"]"
<<
"["
<<
i2
<<
"]"
<<
"["
<<
i3
<<
"]"
<<
"["
<<
i4
<<
"]"
;
}
}
}
}
}
};
/*! \brief This class is an helper to produce csv data from multi-array
*
* Usage:
*
* \code{.cpp}
*
* float src[3] = {1.0,2.0,3.0};
*
* std::stringstream str;
* csv_value_str<float[3]> cp(src,str);
*
* std::cout << str.str() << "\n";
*
* \endcode
*
* Will produce ",1.0,2.0,3.0"
*
*/
template
<
typename
T
>
struct
csv_value_str
{
inline
csv_value_str
(
T
&
v
,
std
::
stringstream
&
str
)
{
str
<<
","
<<
v
;
}
};
//! Partial specialization for N=1 1D-Array
template
<
typename
T
,
size_t
N1
>
struct
csv_value_str
<
T
[
N1
]
>
{
inline
csv_value_str
(
const
T
v
[
N1
],
std
::
stringstream
&
str
)
{
for
(
size_t
i
=
0
;
i
<
N1
;
i
++
)
str
<<
","
<<
v
[
i
];
}
};
//! Partial specialization for N=2 2D-Array
template
<
typename
T
,
size_t
N1
,
size_t
N2
>
struct
csv_value_str
<
T
[
N1
][
N2
]
>
{
inline
csv_value_str
(
const
T
v
[
N1
][
N2
],
std
::
stringstream
&
str
)
{
for
(
size_t
i1
=
0
;
i1
<
N1
;
i1
++
)
{
for
(
size_t
i2
=
0
;
i2
<
N2
;
i2
++
)
{
str
<<
","
<<
v
[
i1
][
i2
];
}
}
}
};
//! Partial specialization for N=3
template
<
typename
T
,
size_t
N1
,
size_t
N2
,
size_t
N3
>
struct
csv_value_str
<
T
[
N1
][
N2
][
N3
]
>
{
inline
csv_value_str
(
const
T
v
[
N1
][
N2
][
N3
],
std
::
stringstream
&
str
)
{
for
(
size_t
i1
=
0
;
i1
<
N1
;
i1
++
)
{
for
(
size_t
i2
=
0
;
i2
<
N2
;
i2
++
)
{
for
(
size_t
i3
=
0
;
i3
<
N3
;
i3
++
)
{
str
<<
","
<<
v
[
i1
][
i2
][
i3
];
}
}
}
}
};
//! Partial specialization for N=4
template
<
typename
T
,
size_t
N1
,
size_t
N2
,
size_t
N3
,
size_t
N4
>
struct
csv_value_str
<
T
[
N1
][
N2
][
N3
][
N4
]
>
{
inline
csv_value_str
(
const
T
v
[
N1
][
N2
][
N3
][
N4
],
std
::
stringstream
&
str
)
{
for
(
size_t
i1
=
0
;
i1
<
N1
;
i1
++
)
{
for
(
size_t
i2
=
0
;
i2
<
N2
;
i2
++
)
{
for
(
size_t
i3
=
0
;
i3
<
N3
;
i3
++
)
{
for
(
size_t
i4
=
0
;
i4
<
N4
;
i4
++
)
{
str
<<
","
<<
v
[
i1
][
i2
][
i3
][
i4
];
}
}
}
}
}
};
#endif
/* CSV_MULTIARRAY_COPY_HPP_ */
This diff is collapsed.
Click to expand it.
src/util.hpp
0 → 100644
+
172
−
0
View file @
69308d7f
/*
* util.hpp
*
* Created on: May 7, 2015
* Author: Pietro Incardona
*/
#ifndef UTIL_HPP_
#define UTIL_HPP_
#include
<boost/iostreams/device/mapped_file.hpp>
/*! \brief Compare two files, return true if they match
*
* \param file1 path1
* \param file2 path2
*
* \return true if they match
*
*/
bool
compare
(
std
::
string
file1
,
std
::
string
file2
)
{
boost
::
iostreams
::
mapped_file_source
f1
(
file1
);
boost
::
iostreams
::
mapped_file_source
f2
(
file2
);
if
(
f1
.
size
()
==
f2
.
size
()
&&
std
::
equal
(
f1
.
data
(),
f1
.
data
()
+
f1
.
size
(),
f2
.
data
())
)
return
true
;
else
return
false
;
}
struct
RGB
{
float
R
;
float
G
;
float
B
;
std
::
string
toString
()
{
return
std
::
to_string
(
R
)
+
" "
+
std
::
to_string
(
G
)
+
" "
+
std
::
to_string
(
B
);
}
};
/*! \brief Return the color sampled from one group
*
* groups:
*
* 0: Red
* 1: Green
* 2: Blue
* 3: Yellow
* 4: Cyan
* 5: Magenta
* 6: Orange
* 7: Chartreuse-Green
* 8: Spring Green
* 9: Azure
* 10: Violet
* 11: Rose
*
* \param group
*
*/
struct
RGB
getColor
(
int
group
,
std
::
uniform_real_distribution
<
float
>
&
d
,
std
::
default_random_engine
&
g
)
{
struct
RGB
col
;
if
(
group
==
0
)
{
float
s
=
d
(
g
);
col
.
R
=
s
/
2
+
0.5
;
col
.
G
=
0.0
;
col
.
B
=
0.0
;
}
else
if
(
group
==
1
)
{
float
s
=
d
(
g
);
col
.
R
=
0.0
;
col
.
G
=
s
/
2
+
0.5
;
col
.
B
=
0.0
;
}
else
if
(
group
==
2
)
{
float
s
=
d
(
g
);
col
.
R
=
0.0
;
col
.
G
=
0.0
;
col
.
B
=
s
;
}
else
if
(
group
==
3
)
{
float
s
=
d
(
g
);
col
.
R
=
s
/
2
+
0.5
;
col
.
G
=
s
/
2
+
0.5
;
col
.
B
=
0.0
;
}
else
if
(
group
==
4
)
{
float
s
=
d
(
g
);
col
.
R
=
s
/
2
+
0.5
;
col
.
G
=
0.0
;
col
.
B
=
s
/
2
+
0.5
;
}
else
if
(
group
==
5
)
{
float
s
=
d
(
g
);
col
.
R
=
0.0
;
col
.
G
=
s
/
2
+
0.5
;
col
.
B
=
s
/
2
+
0.5
;
}
else
if
(
group
==
6
)
{
float
s
=
d
(
g
);
col
.
R
=
s
/
2
+
0.5
;
col
.
G
=
s
/
4
+
0.5
;
col
.
B
=
0.0
;
}
else
if
(
group
==
7
)
{
float
s
=
d
(
g
);
col
.
R
=
s
/
4
+
0.5
;
col
.
G
=
s
/
2
+
0.5
;
col
.
B
=
0.0
;
}
else
if
(
group
==
8
)
{
float
s
=
d
(
g
);
col
.
R
=
0.0
;
col
.
G
=
s
/
2
+
0.5
;
col
.
B
=
s
/
4
+
0.5
;
}
else
if
(
group
==
9
)
{
float
s
=
d
(
g
);
col
.
R
=
0.0
;
col
.
G
=
s
/
4
+
0.5
;
col
.
B
=
s
/
2
+
0.5
;
}
else
if
(
group
==
10
)
{
float
s
=
d
(
g
);
col
.
R
=
s
/
4
+
0.5
;
col
.
G
=
0.0
;
col
.
B
=
s
/
2
+
0.5
;
}
else
if
(
group
==
11
)
{
float
s
=
d
(
g
);
col
.
R
=
s
/
2
+
0.5
;
col
.
G
=
0.0
;
col
.
B
=
s
/
4
+
0.5
;
}
return
col
;
}
/*! \brief Check if one string end with a particular string
*
* \param fullString string to check
* \param ending ending string to check
*
*/
bool
hasEnding
(
std
::
string
const
&
fullString
,
std
::
string
const
&
ending
)
{
if
(
fullString
.
length
()
>=
ending
.
length
())
{
return
(
0
==
fullString
.
compare
(
fullString
.
length
()
-
ending
.
length
(),
ending
.
length
(),
ending
));}
else
{
return
false
;}
}
#endif
/* UTIL_HPP_ */
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment