Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
benchmark
Project
Overview
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
Chen Yisong
benchmark
Commits
37ab858e
Commit
37ab858e
authored
May 26, 2016
by
Ismael
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initialized doubles to 0.0
parent
17158856
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
11 deletions
+11
-11
complexity.h
include/benchmark/complexity.h
+6
-6
complexity.cc
src/complexity.cc
+5
-5
No files found.
include/benchmark/complexity.h
View file @
37ab858e
...
@@ -48,23 +48,23 @@ enum BigO {
...
@@ -48,23 +48,23 @@ enum BigO {
struct
LeastSq
{
struct
LeastSq
{
LeastSq
()
:
LeastSq
()
:
coef
(
0
),
coef
(
0
.
0
),
rms
(
0
),
rms
(
0
.
0
),
complexity
(
benchmark
::
oNone
)
{}
complexity
(
oNone
)
{}
double
coef
;
double
coef
;
double
rms
;
double
rms
;
benchmark
::
BigO
complexity
;
BigO
complexity
;
};
};
// Function to return an string for the calculated complexity
// Function to return an string for the calculated complexity
std
::
string
GetBigOString
(
benchmark
::
BigO
complexity
);
std
::
string
GetBigOString
(
BigO
complexity
);
// Find the coefficient for the high-order term in the running time, by
// Find the coefficient for the high-order term in the running time, by
// minimizing the sum of squares of relative error.
// minimizing the sum of squares of relative error.
LeastSq
MinimalLeastSq
(
const
std
::
vector
<
int
>&
n
,
LeastSq
MinimalLeastSq
(
const
std
::
vector
<
int
>&
n
,
const
std
::
vector
<
double
>&
time
,
const
std
::
vector
<
double
>&
time
,
const
benchmark
::
BigO
complexity
=
benchmark
::
oAuto
);
const
BigO
complexity
=
oAuto
);
}
// end namespace benchmark
}
// end namespace benchmark
#endif // COMPLEXITY_H_
#endif // COMPLEXITY_H_
src/complexity.cc
View file @
37ab858e
...
@@ -86,10 +86,10 @@ std::string GetBigOString(BigO complexity) {
...
@@ -86,10 +86,10 @@ std::string GetBigOString(BigO complexity) {
LeastSq
CalculateLeastSq
(
const
std
::
vector
<
int
>&
n
,
LeastSq
CalculateLeastSq
(
const
std
::
vector
<
int
>&
n
,
const
std
::
vector
<
double
>&
time
,
const
std
::
vector
<
double
>&
time
,
std
::
function
<
double
(
int
)
>
fitting_curve
)
{
std
::
function
<
double
(
int
)
>
fitting_curve
)
{
double
sigma_gn
=
0
;
double
sigma_gn
=
0
.0
;
double
sigma_gn_squared
=
0
;
double
sigma_gn_squared
=
0
.0
;
double
sigma_time
=
0
;
double
sigma_time
=
0
.0
;
double
sigma_time_gn
=
0
;
double
sigma_time_gn
=
0
.0
;
// Calculate least square fitting parameter
// Calculate least square fitting parameter
for
(
size_t
i
=
0
;
i
<
n
.
size
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
n
.
size
();
++
i
)
{
...
@@ -106,7 +106,7 @@ LeastSq CalculateLeastSq(const std::vector<int>& n,
...
@@ -106,7 +106,7 @@ LeastSq CalculateLeastSq(const std::vector<int>& n,
result
.
coef
=
sigma_time_gn
/
sigma_gn_squared
;
result
.
coef
=
sigma_time_gn
/
sigma_gn_squared
;
// Calculate RMS
// Calculate RMS
double
rms
=
0
;
double
rms
=
0
.0
;
for
(
size_t
i
=
0
;
i
<
n
.
size
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
n
.
size
();
++
i
)
{
double
fit
=
result
.
coef
*
fitting_curve
(
n
[
i
]);
double
fit
=
result
.
coef
*
fitting_curve
(
n
[
i
]);
rms
+=
pow
((
time
[
i
]
-
fit
),
2
);
rms
+=
pow
((
time
[
i
]
-
fit
),
2
);
...
...
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