line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------- |
2
|
|
|
|
|
|
|
| Copyright (c) 2013-2017, Nucleic Development Team. |
3
|
|
|
|
|
|
|
| |
4
|
|
|
|
|
|
|
| Distributed under the terms of the Modified BSD License. |
5
|
|
|
|
|
|
|
| |
6
|
|
|
|
|
|
|
| The full license is in the file LICENSE, distributed with this software. |
7
|
|
|
|
|
|
|
|----------------------------------------------------------------------------*/ |
8
|
|
|
|
|
|
|
#pragma once |
9
|
|
|
|
|
|
|
#include <algorithm> |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
namespace kiwi |
13
|
|
|
|
|
|
|
{ |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
namespace strength |
16
|
|
|
|
|
|
|
{ |
17
|
|
|
|
|
|
|
|
18
|
32
|
|
|
|
|
|
inline double create( double a, double b, double c, double w = 1.0 ) |
19
|
|
|
|
|
|
|
{ |
20
|
32
|
|
|
|
|
|
double result = 0.0; |
21
|
32
|
|
|
|
|
|
result += std::max( 0.0, std::min( 1000.0, a * w ) ) * 1000000.0; |
22
|
32
|
|
|
|
|
|
result += std::max( 0.0, std::min( 1000.0, b * w ) ) * 1000.0; |
23
|
32
|
|
|
|
|
|
result += std::max( 0.0, std::min( 1000.0, c * w ) ); |
24
|
32
|
|
|
|
|
|
return result; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
8
|
|
|
|
|
|
const double required = create( 1000.0, 1000.0, 1000.0 ); |
29
|
|
|
|
|
|
|
|
30
|
8
|
|
|
|
|
|
const double strong = create( 1.0, 0.0, 0.0 ); |
31
|
|
|
|
|
|
|
|
32
|
8
|
|
|
|
|
|
const double medium = create( 0.0, 1.0, 0.0 ); |
33
|
|
|
|
|
|
|
|
34
|
8
|
|
|
|
|
|
const double weak = create( 0.0, 0.0, 1.0 ); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
5039
|
|
|
|
|
|
inline double clip( double value ) |
38
|
|
|
|
|
|
|
{ |
39
|
5039
|
|
|
|
|
|
return std::max( 0.0, std::min( required, value ) ); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
} // namespace strength |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
} // namespace kiwi |