Coverage Report

Created: 2025-12-08 09:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/chart2/source/inc/RegressionCalculationHelper.hxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
5
 * This Source Code Form is subject to the terms of the Mozilla Public
6
 * License, v. 2.0. If a copy of the MPL was not distributed with this
7
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
11
 *   Licensed to the Apache Software Foundation (ASF) under one or more
12
 *   contributor license agreements. See the NOTICE file distributed
13
 *   with this work for additional information regarding copyright
14
 *   ownership. The ASF licenses this file to you under the Apache
15
 *   License, Version 2.0 (the "License"); you may not use this file
16
 *   except in compliance with the License. You may obtain a copy of
17
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18
 */
19
#pragma once
20
21
#include <com/sun/star/uno/Sequence.hxx>
22
23
#include <cmath>
24
#include <utility>
25
#include <vector>
26
27
namespace chart::RegressionCalculationHelper
28
{
29
30
typedef std::pair< std::vector< double >, std::vector< double > > tDoubleVectorPair;
31
32
/** takes the given x- and y-values and copies them into the resulting pair,
33
    which contains x-values in the first element and the y-values in the second
34
    one.  All tuples for which aPred is false are not copied.
35
36
    <p>The function below provide a set of useful predicates that can be
37
    used to pass as parameter aPred.</p>
38
 */
39
template< class Pred >
40
tDoubleVectorPair
41
    cleanup( const css::uno::Sequence< double > & rXValues,
42
             const css::uno::Sequence< double > & rYValues,
43
             Pred aPred )
44
0
{
45
0
    tDoubleVectorPair aResult;
46
0
    sal_Int32 nSize = std::min( rXValues.getLength(), rYValues.getLength());
47
0
    for( sal_Int32 i=0; i<nSize; ++i )
48
0
    {
49
0
        if( aPred( rXValues[i], rYValues[i] ))
50
0
        {
51
0
            aResult.first.push_back( rXValues[i] );
52
0
            aResult.second.push_back( rYValues[i] );
53
0
        }
54
0
    }
55
56
0
    return aResult;
57
0
}
Unexecuted instantiation: std::__1::pair<std::__1::vector<double, std::__1::allocator<double> >, std::__1::vector<double, std::__1::allocator<double> > > chart::RegressionCalculationHelper::cleanup<chart::RegressionCalculationHelper::isValidAndYPositive>(com::sun::star::uno::Sequence<double> const&, com::sun::star::uno::Sequence<double> const&, chart::RegressionCalculationHelper::isValidAndYPositive)
Unexecuted instantiation: std::__1::pair<std::__1::vector<double, std::__1::allocator<double> >, std::__1::vector<double, std::__1::allocator<double> > > chart::RegressionCalculationHelper::cleanup<chart::RegressionCalculationHelper::isValidAndYNegative>(com::sun::star::uno::Sequence<double> const&, com::sun::star::uno::Sequence<double> const&, chart::RegressionCalculationHelper::isValidAndYNegative)
Unexecuted instantiation: std::__1::pair<std::__1::vector<double, std::__1::allocator<double> >, std::__1::vector<double, std::__1::allocator<double> > > chart::RegressionCalculationHelper::cleanup<chart::RegressionCalculationHelper::isValidAndXPositive>(com::sun::star::uno::Sequence<double> const&, com::sun::star::uno::Sequence<double> const&, chart::RegressionCalculationHelper::isValidAndXPositive)
Unexecuted instantiation: std::__1::pair<std::__1::vector<double, std::__1::allocator<double> >, std::__1::vector<double, std::__1::allocator<double> > > chart::RegressionCalculationHelper::cleanup<chart::RegressionCalculationHelper::isValid>(com::sun::star::uno::Sequence<double> const&, com::sun::star::uno::Sequence<double> const&, chart::RegressionCalculationHelper::isValid)
Unexecuted instantiation: std::__1::pair<std::__1::vector<double, std::__1::allocator<double> >, std::__1::vector<double, std::__1::allocator<double> > > chart::RegressionCalculationHelper::cleanup<chart::RegressionCalculationHelper::isValidAndBothPositive>(com::sun::star::uno::Sequence<double> const&, com::sun::star::uno::Sequence<double> const&, chart::RegressionCalculationHelper::isValidAndBothPositive)
Unexecuted instantiation: std::__1::pair<std::__1::vector<double, std::__1::allocator<double> >, std::__1::vector<double, std::__1::allocator<double> > > chart::RegressionCalculationHelper::cleanup<chart::RegressionCalculationHelper::isValidAndXPositiveAndYNegative>(com::sun::star::uno::Sequence<double> const&, com::sun::star::uno::Sequence<double> const&, chart::RegressionCalculationHelper::isValidAndXPositiveAndYNegative)
58
59
class isValid
60
{
61
public:
62
    bool operator()( double x, double y )
63
0
    { return ! ( std::isnan( x ) ||
64
0
                 std::isnan( y ) ||
65
0
                 std::isinf( x ) ||
66
0
                 std::isinf( y ) );
67
0
    }
68
};
69
70
class isValidAndXPositive
71
{
72
public:
73
    bool operator()( double x, double y )
74
0
    { return ! ( std::isnan( x ) ||
75
0
                 std::isnan( y ) ||
76
0
                 std::isinf( x ) ||
77
0
                 std::isinf( y ) ||
78
0
                 x <= 0.0 );
79
0
    }
80
};
81
82
class isValidAndYPositive
83
{
84
public:
85
    bool operator()( double x, double y )
86
0
    { return ! ( std::isnan( x ) ||
87
0
                 std::isnan( y ) ||
88
0
                 std::isinf( x ) ||
89
0
                 std::isinf( y ) ||
90
0
                 y <= 0.0 );
91
0
    }
92
};
93
94
class isValidAndYNegative
95
{
96
public:
97
    bool operator()( double x, double y )
98
0
    { return ! ( std::isnan( x ) ||
99
0
                 std::isnan( y ) ||
100
0
                 std::isinf( x ) ||
101
0
                 std::isinf( y ) ||
102
0
                 y >= 0.0 );
103
0
    }
104
};
105
106
class isValidAndBothPositive
107
{
108
public:
109
    bool operator()( double x, double y )
110
0
    { return ! ( std::isnan( x ) ||
111
0
                 std::isnan( y ) ||
112
0
                 std::isinf( x ) ||
113
0
                 std::isinf( y ) ||
114
0
                 x <= 0.0 ||
115
0
                 y <= 0.0 );
116
0
    }
117
};
118
119
class isValidAndXPositiveAndYNegative
120
{
121
public:
122
    bool operator()( double x, double y )
123
0
    { return ! ( std::isnan( x ) ||
124
0
                 std::isnan( y ) ||
125
0
                 std::isinf( x ) ||
126
0
                 std::isinf( y ) ||
127
0
                 x <= 0.0 ||
128
0
                 y >= 0.0 );
129
0
    }
130
};
131
132
} //  namespace chart::RegressionCalculationHelper
133
134
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */