Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
12a393f3
Commit
12a393f3
authored
Oct 21, 2012
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code cleanup
parent
4cd1855e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
12 deletions
+12
-12
bsp_ex.cpp
examples/bsp_ex.cpp
+12
-12
No files found.
examples/bsp_ex.cpp
View file @
12a393f3
...
...
@@ -32,7 +32,7 @@ double f ( double x)
// ----------------------------------------------------------------------------------------
void
bsp_job_node_0
(
bsp_context
&
context
,
bsp_context
&
bsp
,
double
&
min_value
,
double
&
optimal_x
)
...
...
@@ -43,15 +43,15 @@ void bsp_job_node_0 (
min_value
=
std
::
numeric_limits
<
double
>::
infinity
();
double
interval_width
=
std
::
abs
(
right
-
left
);
for
(
int
i
=
0
;
i
<
100
00
;
++
i
)
for
(
int
i
=
0
;
i
<
100
;
++
i
)
{
context
.
broadcast
(
left
);
context
.
broadcast
(
right
);
bsp
.
broadcast
(
left
);
bsp
.
broadcast
(
right
);
for
(
unsigned
int
k
=
1
;
k
<
context
.
number_of_nodes
();
++
k
)
for
(
unsigned
int
k
=
1
;
k
<
bsp
.
number_of_nodes
();
++
k
)
{
std
::
pair
<
double
,
double
>
val
;
context
.
receive
(
val
);
bsp
.
receive
(
val
);
if
(
val
.
second
<
min_value
)
{
min_value
=
val
.
second
;
...
...
@@ -68,17 +68,17 @@ void bsp_job_node_0 (
// ----------------------------------------------------------------------------------------
void
bsp_job_other_nodes
(
bsp_context
&
context
,
bsp_context
&
bsp
,
long
grid_resolution
)
{
double
left
,
right
;
while
(
context
.
try_receive
(
left
))
while
(
bsp
.
try_receive
(
left
))
{
context
.
receive
(
right
);
bsp
.
receive
(
right
);
const
double
l
=
(
context
.
node_id
()
-
1
)
/
(
context
.
number_of_nodes
()
-
1.0
);
const
double
r
=
context
.
node_id
()
/
(
context
.
number_of_nodes
()
-
1.0
);
const
double
l
=
(
bsp
.
node_id
()
-
1
)
/
(
bsp
.
number_of_nodes
()
-
1.0
);
const
double
r
=
bsp
.
node_id
()
/
(
bsp
.
number_of_nodes
()
-
1.0
);
const
double
width
=
right
-
left
;
const
matrix
<
double
>
values_to_check
=
linspace
(
left
+
l
*
width
,
left
+
r
*
width
,
grid_resolution
);
...
...
@@ -95,7 +95,7 @@ void bsp_job_other_nodes (
}
}
context
.
send
(
make_pair
(
best_x
,
best_val
),
0
);
bsp
.
send
(
make_pair
(
best_x
,
best_val
),
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