fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / chart2 / source / tools / MovingAverageRegressionCurveCalculator.cxx
blobee61c9c7cd9a6ac555759907637bc200cdf7197c
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 .
20 #include "MovingAverageRegressionCurveCalculator.hxx"
21 #include "RegressionCalculationHelper.hxx"
22 #include "ResId.hxx"
23 #include "Strings.hrc"
24 #include "macros.hxx"
26 #include <rtl/math.hxx>
27 #include <rtl/ustrbuf.hxx>
29 using namespace ::com::sun::star;
31 namespace chart
34 MovingAverageRegressionCurveCalculator::MovingAverageRegressionCurveCalculator()
37 MovingAverageRegressionCurveCalculator::~MovingAverageRegressionCurveCalculator()
40 // ____ XRegressionCurveCalculator ____
41 void SAL_CALL MovingAverageRegressionCurveCalculator::recalculateRegression(
42 const uno::Sequence< double >& aXValues,
43 const uno::Sequence< double >& aYValues )
44 throw (uno::RuntimeException, std::exception)
46 ::rtl::math::setNan( & m_fCorrelationCoeffitient );
48 RegressionCalculationHelper::tDoubleVectorPair aValues(
49 RegressionCalculationHelper::cleanup(
50 aXValues, aYValues,
51 RegressionCalculationHelper::isValid()));
53 const size_t aSize = aValues.first.size();
55 aYList.clear();
56 aXList.clear();
58 for( size_t i = mPeriod - 1; i < aSize; ++i )
60 double yAvg;
61 yAvg = 0.0;
63 for (sal_Int32 j = 0; j < mPeriod; j++)
65 yAvg += aValues.second[i - j];
67 yAvg /= mPeriod;
69 double x = aValues.first[i];
70 aYList.push_back(yAvg);
71 aXList.push_back(x);
75 double SAL_CALL MovingAverageRegressionCurveCalculator::getCurveValue( double /*x*/ )
76 throw (lang::IllegalArgumentException,
77 uno::RuntimeException, std::exception)
79 double fResult;
80 rtl::math::setNan(&fResult);
81 return fResult;
84 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)
92 uno::Sequence< geometry::RealPoint2D > aResult( aYList.size() );
94 for( size_t i = 0; i < aYList.size(); ++i )
96 aResult[i].X = aXList[i];
97 aResult[i].Y = aYList[i];
99 return aResult;
102 OUString MovingAverageRegressionCurveCalculator::ImplGetRepresentation(
103 const uno::Reference< util::XNumberFormatter >& /*xNumFormatter*/,
104 ::sal_Int32 /*nNumberFormatKey*/ ) const
106 OUStringBuffer aBuf( "f(x) = N/A");
108 aBuf = SCH_RESSTR( STR_OBJECT_MOVING_AVERAGE_WITH_PARAMETERS );
110 return aBuf.makeStringAndClear();
113 } // namespace chart
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */