Debian Codegraph @

kiwi/strength.h

raw
1 /*-----------------------------------------------------------------------------
2 | Copyright (c) 2013-2026, 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 inline double create( double a, double b, double c, double w = 1.0 )
19 {
20 double result = 0.0;
21 result += std::max( 0.0, std::min( 1000.0, a * w ) ) * 1000000.0;
22 result += std::max( 0.0, std::min( 1000.0, b * w ) ) * 1000.0;
23 result += std::max( 0.0, std::min( 1000.0, c * w ) );
24 return result;
25 }
26
27
28 const double required = create( 1000.0, 1000.0, 1000.0 );
29
30 const double strong = create( 1.0, 0.0, 0.0 );
31
32 const double medium = create( 0.0, 1.0, 0.0 );
33
34 const double weak = create( 0.0, 0.0, 1.0 );
35
36
37 inline double clip( double value )
38 {
39 return std::max( 0.0, std::min( required, value ) );
40 }
41
42 } // namespace strength
43
44 } // namespace kiwi