1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
21 #include <com/sun/star/uno/Sequence.hxx>
27 namespace chart::RegressionCalculationHelper
30 typedef std::pair
< std::vector
< double >, std::vector
< double > > tDoubleVectorPair
;
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.
36 <p>The function below provide a set of useful predicates that can be
37 used to pass as parameter aPred.</p>
39 template< class Pred
>
41 cleanup( const css::uno::Sequence
< double > & rXValues
,
42 const css::uno::Sequence
< double > & rYValues
,
45 tDoubleVectorPair aResult
;
46 sal_Int32 nSize
= std::min( rXValues
.getLength(), rYValues
.getLength());
47 for( sal_Int32 i
=0; i
<nSize
; ++i
)
49 if( aPred( rXValues
[i
], rYValues
[i
] ))
51 aResult
.first
.push_back( rXValues
[i
] );
52 aResult
.second
.push_back( rYValues
[i
] );
62 bool operator()( double x
, double y
)
63 { return ! ( std::isnan( x
) ||
70 class isValidAndXPositive
73 bool operator()( double x
, double y
)
74 { return ! ( std::isnan( x
) ||
82 class isValidAndYPositive
85 bool operator()( double x
, double y
)
86 { return ! ( std::isnan( x
) ||
94 class isValidAndYNegative
97 bool operator()( double x
, double y
)
98 { return ! ( std::isnan( x
) ||
106 class isValidAndBothPositive
109 bool operator()( double x
, double y
)
110 { return ! ( std::isnan( x
) ||
119 class isValidAndXPositiveAndYNegative
122 bool operator()( double x
, double y
)
123 { return ! ( std::isnan( x
) ||
132 } // namespace chart::RegressionCalculationHelper
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */