LCOV - code coverage report
Current view: top level - chart2/source/tools - MovingAverageRegressionCurveCalculator.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 33 0.0 %
Date: 2014-04-14 Functions: 0 7 0.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             : 
      20             : #include "MovingAverageRegressionCurveCalculator.hxx"
      21             : #include "RegressionCalculationHelper.hxx"
      22             : #include "ResId.hxx"
      23             : #include "Strings.hrc"
      24             : #include "macros.hxx"
      25             : 
      26             : #include <rtl/math.hxx>
      27             : #include <rtl/ustrbuf.hxx>
      28             : 
      29             : using namespace ::com::sun::star;
      30             : 
      31             : namespace chart
      32             : {
      33             : 
      34           0 : MovingAverageRegressionCurveCalculator::MovingAverageRegressionCurveCalculator()
      35           0 : {}
      36             : 
      37           0 : MovingAverageRegressionCurveCalculator::~MovingAverageRegressionCurveCalculator()
      38           0 : {}
      39             : 
      40             : // ____ XRegressionCurveCalculator ____
      41           0 : void SAL_CALL MovingAverageRegressionCurveCalculator::recalculateRegression(
      42             :     const uno::Sequence< double >& aXValues,
      43             :     const uno::Sequence< double >& aYValues )
      44             :     throw (uno::RuntimeException, std::exception)
      45             : {
      46           0 :     ::rtl::math::setNan( & m_fCorrelationCoeffitient );
      47             : 
      48             :     RegressionCalculationHelper::tDoubleVectorPair aValues(
      49             :         RegressionCalculationHelper::cleanup(
      50             :             aXValues, aYValues,
      51           0 :             RegressionCalculationHelper::isValid()));
      52             : 
      53           0 :     const size_t aSize = aValues.first.size();
      54             : 
      55           0 :     aYList.clear();
      56           0 :     aXList.clear();
      57             : 
      58           0 :     for( size_t i = mPeriod - 1; i < aSize; ++i )
      59             :     {
      60             :         double yAvg;
      61           0 :         yAvg = 0.0;
      62             : 
      63           0 :         for (sal_Int32 j = 0; j < mPeriod; j++)
      64             :         {
      65           0 :             yAvg += aValues.second[i - j];
      66             :         }
      67           0 :         yAvg /= mPeriod;
      68             : 
      69           0 :         double x = aValues.first[i];
      70           0 :         aYList.push_back(yAvg);
      71           0 :         aXList.push_back(x);
      72           0 :     }
      73           0 : }
      74             : 
      75           0 : double SAL_CALL MovingAverageRegressionCurveCalculator::getCurveValue( double /*x*/ )
      76             :     throw (lang::IllegalArgumentException,
      77             :            uno::RuntimeException, std::exception)
      78             : {
      79             :     double fResult;
      80           0 :     rtl::math::setNan(&fResult);
      81           0 :     return fResult;
      82             : }
      83             : 
      84           0 : uno::Sequence< geometry::RealPoint2D > SAL_CALL MovingAverageRegressionCurveCalculator::getCurveValues(
      85             :     double /*min*/, double /*max*/, sal_Int32 /*nPointCount*/,
      86             :     const uno::Reference< chart2::XScaling >& /*xScalingX*/,
      87             :     const uno::Reference< chart2::XScaling >& /*xScalingY*/,
      88             :     sal_Bool /*bMaySkipPointsInCalculation*/ )
      89             :     throw (lang::IllegalArgumentException,
      90             :            uno::RuntimeException, std::exception)
      91             : {
      92           0 :     uno::Sequence< geometry::RealPoint2D > aResult( aYList.size() );
      93             : 
      94           0 :     for( size_t i = 0; i < aYList.size(); ++i )
      95             :     {
      96           0 :         aResult[i].X = aXList[i];
      97           0 :         aResult[i].Y = aYList[i];
      98             :     }
      99           0 :     return aResult;
     100             : }
     101             : 
     102           0 : OUString MovingAverageRegressionCurveCalculator::ImplGetRepresentation(
     103             :     const uno::Reference< util::XNumberFormatter >& /*xNumFormatter*/,
     104             :     ::sal_Int32 /*nNumberFormatKey*/ ) const
     105             : {
     106           0 :     OUStringBuffer aBuf( "f(x) = N/A");
     107             : 
     108           0 :     aBuf = SCH_RESSTR( STR_OBJECT_MOVING_AVERAGE_WITH_PARAMETERS );
     109             : 
     110           0 :     return aBuf.makeStringAndClear();
     111             : }
     112             : 
     113             : } //  namespace chart
     114             : 
     115             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10