LibreOffice Module chart2 (master) 1
RegressionCalculationHelper.hxx
Go to the documentation of this file.
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
28{
29
30typedef std::pair< std::vector< double >, std::vector< double > > tDoubleVectorPair;
31
39template< class Pred >
41 cleanup( const css::uno::Sequence< double > & rXValues,
42 const css::uno::Sequence< double > & rYValues,
43 Pred aPred )
44{
45 tDoubleVectorPair aResult;
46 sal_Int32 nSize = std::min( rXValues.getLength(), rYValues.getLength());
47 for( sal_Int32 i=0; i<nSize; ++i )
48 {
49 if( aPred( rXValues[i], rYValues[i] ))
50 {
51 aResult.first.push_back( rXValues[i] );
52 aResult.second.push_back( rYValues[i] );
53 }
54 }
55
56 return aResult;
57}
58
60{
61public:
62 bool operator()( double x, double y )
63 { return ! ( std::isnan( x ) ||
64 std::isnan( y ) ||
65 std::isinf( x ) ||
66 std::isinf( y ) );
67 }
68};
69
71{
72public:
73 bool operator()( double x, double y )
74 { return ! ( std::isnan( x ) ||
75 std::isnan( y ) ||
76 std::isinf( x ) ||
77 std::isinf( y ) ||
78 x <= 0.0 );
79 }
80};
81
83{
84public:
85 bool operator()( double x, double y )
86 { return ! ( std::isnan( x ) ||
87 std::isnan( y ) ||
88 std::isinf( x ) ||
89 std::isinf( y ) ||
90 y <= 0.0 );
91 }
92};
93
95{
96public:
97 bool operator()( double x, double y )
98 { return ! ( std::isnan( x ) ||
99 std::isnan( y ) ||
100 std::isinf( x ) ||
101 std::isinf( y ) ||
102 y >= 0.0 );
103 }
104};
105
107{
108public:
109 bool operator()( double x, double y )
110 { return ! ( std::isnan( x ) ||
111 std::isnan( y ) ||
112 std::isinf( x ) ||
113 std::isinf( y ) ||
114 x <= 0.0 ||
115 y <= 0.0 );
116 }
117};
118
120{
121public:
122 bool operator()( double x, double y )
123 { return ! ( std::isnan( x ) ||
124 std::isnan( y ) ||
125 std::isinf( x ) ||
126 std::isinf( y ) ||
127 x <= 0.0 ||
128 y >= 0.0 );
129 }
130};
131
132} // namespace chart::RegressionCalculationHelper
133
134/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
float y
float x
std::pair< std::vector< double >, std::vector< double > > tDoubleVectorPair
tDoubleVectorPair cleanup(const css::uno::Sequence< double > &rXValues, const css::uno::Sequence< double > &rYValues, Pred aPred)
takes the given x- and y-values and copies them into the resulting pair, which contains x-values in t...
int i