LCOV - code coverage report
Current view: top level - chart2/source/inc - RegressionCalculationHelper.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 13 32 40.6 %
Date: 2015-06-13 12:38:46 Functions: 2 8 25.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : #ifndef INCLUDED_CHART2_SOURCE_INC_REGRESSIONCALCULATIONHELPER_HXX
      20             : #define INCLUDED_CHART2_SOURCE_INC_REGRESSIONCALCULATIONHELPER_HXX
      21             : 
      22             : #include <rtl/math.hxx>
      23             : 
      24             : #include <utility>
      25             : #include <algorithm>
      26             : #include <functional>
      27             : #include <vector>
      28             : 
      29             : #define NUMBER_TO_STR(number) (OStringToOUString(::rtl::math::doubleToString( \
      30             :           number, rtl_math_StringFormat_G1, 4, '.', true ),RTL_TEXTENCODING_ASCII_US ))
      31             : 
      32             : #define UC_SPACE (sal_Unicode(' '))
      33             : #define UC_MINUS_SIGN (sal_Unicode('-'))
      34             : // #define UC_MINUS_SIGN (sal_Unicode(0x2212))
      35             : 
      36             : namespace chart
      37             : {
      38             : namespace RegressionCalculationHelper
      39             : {
      40             : 
      41             : typedef ::std::pair< ::std::vector< double >, ::std::vector< double > > tDoubleVectorPair;
      42             : 
      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.
      46             : 
      47             :     <p>The functors below provide a set of useful predicates that can be
      48             :     used to pass as parameter aPred.</p>
      49             :  */
      50             : template< class Pred >
      51             : tDoubleVectorPair
      52          23 :     cleanup( const ::com::sun::star::uno::Sequence< double > & rXValues,
      53             :              const ::com::sun::star::uno::Sequence< double > & rYValues,
      54             :              Pred aPred )
      55             : {
      56          23 :     tDoubleVectorPair aResult;
      57          23 :     sal_Int32 nSize = ::std::min( rXValues.getLength(), rYValues.getLength());
      58         178 :     for( sal_Int32 i=0; i<nSize; ++i )
      59             :     {
      60         155 :         if( aPred( rXValues[i], rYValues[i] ))
      61             :         {
      62         155 :             aResult.first.push_back( rXValues[i] );
      63         155 :             aResult.second.push_back( rYValues[i] );
      64             :         }
      65             :     }
      66             : 
      67          23 :     return aResult;
      68             : }
      69             : 
      70             : class isValid : public ::std::binary_function< double, double, bool >
      71             : {
      72             : public:
      73         155 :     inline bool operator()( double x, double y )
      74         310 :     { return ! ( ::rtl::math::isNan( x ) ||
      75         310 :                  ::rtl::math::isNan( y ) ||
      76         155 :                  ::rtl::math::isInf( x ) ||
      77         310 :                  ::rtl::math::isInf( y ) );
      78             :     }
      79             : };
      80             : 
      81             : class isValidAndXPositive : public ::std::binary_function< double, double, bool >
      82             : {
      83             : public:
      84           0 :     inline bool operator()( double x, double y )
      85           0 :     { return ! ( ::rtl::math::isNan( x ) ||
      86           0 :                  ::rtl::math::isNan( y ) ||
      87           0 :                  ::rtl::math::isInf( x ) ||
      88           0 :                  ::rtl::math::isInf( y ) ||
      89           0 :                  x <= 0.0 );
      90             :     }
      91             : };
      92             : 
      93             : class isValidAndYPositive : public ::std::binary_function< double, double, bool >
      94             : {
      95             : public:
      96           0 :     inline bool operator()( double x, double y )
      97           0 :     { return ! ( ::rtl::math::isNan( x ) ||
      98           0 :                  ::rtl::math::isNan( y ) ||
      99           0 :                  ::rtl::math::isInf( x ) ||
     100           0 :                  ::rtl::math::isInf( y ) ||
     101           0 :                  y <= 0.0 );
     102             :     }
     103             : };
     104             : 
     105             : class isValidAndBothPositive : public ::std::binary_function< double, double, bool >
     106             : {
     107             : public:
     108           0 :     inline bool operator()( double x, double y )
     109           0 :     { return ! ( ::rtl::math::isNan( x ) ||
     110           0 :                  ::rtl::math::isNan( y ) ||
     111           0 :                  ::rtl::math::isInf( x ) ||
     112           0 :                  ::rtl::math::isInf( y ) ||
     113           0 :                  x <= 0.0 ||
     114           0 :                  y <= 0.0 );
     115             :     }
     116             : };
     117             : 
     118             : } //  namespace RegressionCalculationHelper
     119             : } //  namespace chart
     120             : 
     121             : // INCLUDED_CHART2_SOURCE_INC_REGRESSIONCALCULATIONHELPER_HXX
     122             : #endif
     123             : 
     124             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11