fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / chart2 / source / inc / RegressionCalculationHelper.hxx
blob32456cf8dbb4980e6459335d9ad87f5f90215842
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_CHART2_SOURCE_INC_REGRESSIONCALCULATIONHELPER_HXX
20 #define INCLUDED_CHART2_SOURCE_INC_REGRESSIONCALCULATIONHELPER_HXX
22 #include <rtl/math.hxx>
24 #include <utility>
25 #include <algorithm>
26 #include <functional>
27 #include <vector>
29 #define NUMBER_TO_STR(number) (OStringToOUString(::rtl::math::doubleToString( \
30 number, rtl_math_StringFormat_G1, 4, '.', true ),RTL_TEXTENCODING_ASCII_US ))
32 #define UC_SPACE (sal_Unicode(' '))
33 #define UC_MINUS_SIGN (sal_Unicode('-'))
34 // #define UC_MINUS_SIGN (sal_Unicode(0x2212))
36 namespace chart
38 namespace RegressionCalculationHelper
41 typedef ::std::pair< ::std::vector< double >, ::std::vector< double > > tDoubleVectorPair;
43 /** takes the given x- and y-values and copyies them into the resulting pair,
44 which contains x-values in the first element and the y-values in the second
45 one. All tuples for which aPred is false are not copied.
47 <p>The functors below provide a set of useful predicates that can be
48 used to pass as parameter aPred.</p>
50 template< class Pred >
51 tDoubleVectorPair
52 cleanup( const ::com::sun::star::uno::Sequence< double > & rXValues,
53 const ::com::sun::star::uno::Sequence< double > & rYValues,
54 Pred aPred )
56 tDoubleVectorPair aResult;
57 sal_Int32 nSize = ::std::min( rXValues.getLength(), rYValues.getLength());
58 for( sal_Int32 i=0; i<nSize; ++i )
60 if( aPred( rXValues[i], rYValues[i] ))
62 aResult.first.push_back( rXValues[i] );
63 aResult.second.push_back( rYValues[i] );
67 return aResult;
70 class isValid : public ::std::binary_function< double, double, bool >
72 public:
73 inline bool operator()( double x, double y )
74 { return ! ( ::rtl::math::isNan( x ) ||
75 ::rtl::math::isNan( y ) ||
76 ::rtl::math::isInf( x ) ||
77 ::rtl::math::isInf( y ) );
81 class isValidAndXPositive : public ::std::binary_function< double, double, bool >
83 public:
84 inline bool operator()( double x, double y )
85 { return ! ( ::rtl::math::isNan( x ) ||
86 ::rtl::math::isNan( y ) ||
87 ::rtl::math::isInf( x ) ||
88 ::rtl::math::isInf( y ) ||
89 x <= 0.0 );
93 class isValidAndYPositive : public ::std::binary_function< double, double, bool >
95 public:
96 inline bool operator()( double x, double y )
97 { return ! ( ::rtl::math::isNan( x ) ||
98 ::rtl::math::isNan( y ) ||
99 ::rtl::math::isInf( x ) ||
100 ::rtl::math::isInf( y ) ||
101 y <= 0.0 );
105 class isValidAndBothPositive : public ::std::binary_function< double, double, bool >
107 public:
108 inline bool operator()( double x, double y )
109 { return ! ( ::rtl::math::isNan( x ) ||
110 ::rtl::math::isNan( y ) ||
111 ::rtl::math::isInf( x ) ||
112 ::rtl::math::isInf( y ) ||
113 x <= 0.0 ||
114 y <= 0.0 );
118 } // namespace RegressionCalculationHelper
119 } // namespace chart
121 // INCLUDED_CHART2_SOURCE_INC_REGRESSIONCALCULATIONHELPER_HXX
122 #endif
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */