LCOV - code coverage report
Current view: top level - chart2/source/tools - RegressionCalculationHelper.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 14 31 45.2 %
Date: 2012-08-25 Functions: 2 8 25.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 14 50 28.0 %

           Branch data     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 CHART2_REGRESSIONCALCULATIONHELPER_HXX
      20                 :            : #define CHART2_REGRESSIONCALCULATIONHELPER_HXX
      21                 :            : 
      22                 :            : #include <rtl/math.hxx>
      23                 :            : 
      24                 :            : #include <utility>
      25                 :            : #include <functional>
      26                 :            : #include <vector>
      27                 :            : 
      28                 :            : #define NUMBER_TO_STR(number) (::rtl::OStringToOUString(::rtl::math::doubleToString( \
      29                 :            :           number, rtl_math_StringFormat_G, 4, '.', true ),RTL_TEXTENCODING_ASCII_US ))
      30                 :            : 
      31                 :            : #define UC_SPACE (sal_Unicode(' '))
      32                 :            : #define UC_MINUS_SIGN (sal_Unicode('-'))
      33                 :            : // #define UC_MINUS_SIGN (sal_Unicode(0x2212))
      34                 :            : 
      35                 :            : namespace chart
      36                 :            : {
      37                 :            : namespace RegressionCalculationHelper
      38                 :            : {
      39                 :            : 
      40                 :            : typedef ::std::pair< ::std::vector< double >, ::std::vector< double > > tDoubleVectorPair;
      41                 :            : 
      42                 :            : /** takes the given x- and y-values and copyies them into the resulting pair,
      43                 :            :     which contains x-values in the first element and the y-values in the second
      44                 :            :     one.  All tuples for which aPred is false are not copied.
      45                 :            : 
      46                 :            :     <p>The functors below provide a set of useful predicates that can be
      47                 :            :     used to pass as parameter aPred.</p>
      48                 :            :  */
      49                 :            : template< class Pred >
      50                 :            : tDoubleVectorPair
      51                 :         32 :     cleanup( const ::com::sun::star::uno::Sequence< double > & rXValues,
      52                 :            :              const ::com::sun::star::uno::Sequence< double > & rYValues,
      53                 :            :              Pred aPred )
      54                 :            : {
      55                 :         32 :     tDoubleVectorPair aResult;
      56         [ +  - ]:         32 :     sal_Int32 nSize = ::std::min( rXValues.getLength(), rYValues.getLength());
      57         [ +  + ]:        448 :     for( sal_Int32 i=0; i<nSize; ++i )
      58                 :            :     {
      59         [ +  + ]:        416 :         if( aPred( rXValues[i], rYValues[i] ))
      60                 :            :         {
      61         [ +  - ]:        300 :             aResult.first.push_back( rXValues[i] );
      62         [ +  - ]:        300 :             aResult.second.push_back( rYValues[i] );
      63                 :            :         }
      64                 :            :     }
      65                 :            : 
      66                 :         32 :     return aResult;
      67                 :            : }
      68                 :            : 
      69                 :            : 
      70                 :            : class isValid : public ::std::binary_function< double, double, bool >
      71                 :            : {
      72                 :            : public:
      73                 :          0 :     inline bool operator()( double x, double y )
      74                 :          0 :     { return ! ( ::rtl::math::isNan( x ) ||
      75                 :          0 :                  ::rtl::math::isNan( y ) ||
      76                 :          0 :                  ::rtl::math::isInf( x ) ||
      77 [ #  # ][ #  #  :          0 :                  ::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                 :        416 :     inline bool operator()( double x, double y )
     109                 :        416 :     { return ! ( ::rtl::math::isNan( x ) ||
     110                 :        416 :                  ::rtl::math::isNan( y ) ||
     111                 :        416 :                  ::rtl::math::isInf( x ) ||
     112                 :        416 :                  ::rtl::math::isInf( y ) ||
     113                 :            :                  x <= 0.0 ||
     114 [ +  - ][ +  + ]:       1664 :                  y <= 0.0 );
           [ +  -  +  -  
             +  -  +  - ]
     115                 :            :     }
     116                 :            : };
     117                 :            : 
     118                 :            : } //  namespace RegressionCalculationHelper
     119                 :            : } //  namespace chart
     120                 :            : 
     121                 :            : // CHART2_REGRESSIONCALCULATIONHELPER_HXX
     122                 :            : #endif
     123                 :            : 
     124                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10