File: checktable.cc

package info (click to toggle)
simrisc 16.05.00-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,568 kB
  • sloc: cpp: 6,877; fortran: 665; makefile: 112; ansic: 112; sh: 107
file content (37 lines) | stat: -rw-r--r-- 1,200 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#define XERR
#include "tableparams.ih"

void TableParams::checkTable()
try
{
    if (d_error)
        return;

    if (d_riskTable.size() < 2)     // at least 2 pairs must be specified
        throw "at least 2 pairs must be specified";

    if (d_riskTable.front().first != 0) // ensure a first {0, ..} is available
        d_riskTable.insert(d_riskTable.begin(), DoublePair{0, 0});

    checkIncreasing();
                                                // if no MAX_AGE at the end:
    if (d_riskTable.back().first < MAX_AGE)     // add a final end-age value
    {
        d_riskTable.push_back(
                                DoublePair{ MAX_AGE, 
                                    linear(MAX_AGE, 
                                            *(d_riskTable.rbegin() + 1),
                                            d_riskTable.back() )
                                }
                            );
                                            // ensure the last value is <= 1
        if (DoublePair &last = d_riskTable.back(); last.second > 1.0)
            last.second = 1;
    }
}
catch (char const *txt)
{
    d_error = true;
    Err::msg(Err::TABLEPARAMS) << txt << '\n';
    return;
}