Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
openfpm_data
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_data
Commits
12066df2
Commit
12066df2
authored
9 years ago
by
Yaroslav
Browse files
Options
Downloads
Patches
Plain Diff
Added 'domain' to grid_cpu vectors_util.hpp; reworked algorithm of weight counter
parent
d490579d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/util/vectors_util.hpp
+5
-5
5 additions, 5 deletions
src/util/vectors_util.hpp
src/util/weight_counter_tests.hpp
+5
-4
5 additions, 4 deletions
src/util/weight_counter_tests.hpp
with
10 additions
and
9 deletions
src/util/vectors_util.hpp
+
5
−
5
View file @
12066df2
...
...
@@ -23,7 +23,7 @@ template <unsigned int dim, typename T, typename St>
class
weight_counter
<
dim
,
T
,
St
,
IS_GRID
>
{
public:
size_t
weight
(
T
&
t
,
Box
<
dim
,
St
>
&
b
)
size_t
weight
(
T
&
t
,
const
Box
<
dim
,
St
>
&
domain
,
Box
<
dim
,
St
>
&
b
)
{
// Grid implementation
// get a size vector
...
...
@@ -31,12 +31,12 @@ public:
size_t
res
=
1
;
//for each dimension
for
(
int
i
=
0
;
i
<
dim
;
i
++
)
{
size_t
count
=
0
;
double
count
=
0
;
//rounding coordinates of Low and High up and down
int
a1
=
(
int
)(
b
.
getLow
(
i
));
int
a2
=
(
int
)(
b
.
getHigh
(
i
)
+
0.9999999
);
//
int a1 = (int)(b.getLow(i));
//
int a2 = (int)(b.getHigh(i) + 0.9999999);
//counting points those get into a box, excluding borders
count
=
a2
-
a1
-
1
;
count
=
ceil
(
b
.
getHigh
(
i
))
-
floor
(
b
.
getLow
(
i
))
-
1
;
//adding negative borders, if the number was integer
if
(
b
.
getLow
(
i
)
==
ceil
(
b
.
getLow
(
i
)))
count
++
;
...
...
This diff is collapsed.
Click to expand it.
src/util/weight_counter_tests.hpp
+
5
−
4
View file @
12066df2
...
...
@@ -22,16 +22,17 @@ BOOST_AUTO_TEST_CASE( weight_counter_grid )
std
::
cout
<<
"Grid weight counter test start"
<<
"
\n
"
;
grid_cpu
<
3
,
Point
<
3
,
float
>>
t
({
5
,
5
,
5
});
const
SpaceBox
<
3
,
float
>
domain
({
0.0
,
0.0
,
0.0
},{
5.0
,
5.0
,
5.0
});
//general case of box, create and check weight
{
SpaceBox
<
3
,
float
>
b
({
0.5
,
0.5
,
0.5
},{
3.
0
,
3.
0
,
3.
0
});
SpaceBox
<
3
,
float
>
b
({
0.5
,
0.5
,
0.5
},{
3.
5
,
3.
5
,
3.
5
});
weight_counter
<
3
,
grid_cpu
<
3
,
Point
<
3
,
float
>>
,
float
,
IS_GRID
>
w
;
size_t
result
=
w
.
weight
(
t
,
b
);
size_t
result
=
w
.
weight
(
t
,
domain
,
b
);
BOOST_REQUIRE_EQUAL
(
result
,
8
);
BOOST_REQUIRE_EQUAL
(
result
,
27
);
}
//case of box with integer Low and High points, create and check weight (positive exclude)
...
...
@@ -40,7 +41,7 @@ BOOST_AUTO_TEST_CASE( weight_counter_grid )
weight_counter
<
3
,
grid_cpu
<
3
,
Point
<
3
,
float
>>
,
float
,
IS_GRID
>
w
;
size_t
result
=
w
.
weight
(
t
,
b
);
size_t
result
=
w
.
weight
(
t
,
domain
,
b
);
BOOST_REQUIRE_EQUAL
(
result
,
27
);
}
...
...
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