25#include <rtl/math.hxx>
26#include <rtl/ustrbuf.hxx>
34 : m_fSlope(
std::numeric_limits<double>::quiet_NaN())
35 , m_fIntercept(
std::numeric_limits<double>::quiet_NaN())
54 size_t nMax = aValues.first.size();
60 nMax = aValues.first.size();
63 m_fSlope = std::numeric_limits<double>::quiet_NaN();
71 double fAverageX = 0.0, fAverageY = 0.0;
73 for(
i = 0;
i < nMax; ++
i )
75 fAverageX +=
log( aValues.first[
i] );
79 const double fN =
static_cast< double >( nMax );
83 double fQx = 0.0, fQy = 0.0, fQxy = 0.0;
84 for(
i = 0;
i < nMax; ++
i )
86 double fDeltaX =
log( aValues.first[
i] ) - fAverageX;
87 double fDeltaY =
log(
m_fSign * aValues.second[
i] ) - fAverageY;
89 fQx += fDeltaX * fDeltaX;
90 fQy += fDeltaY * fDeltaY;
91 fQxy += fDeltaX * fDeltaY;
109 return std::numeric_limits<double>::quiet_NaN();
113 double min,
double max, ::sal_Int32 nPointCount,
116 sal_Bool bMaySkipPointsInCalculation )
118 if( bMaySkipPointsInCalculation &&
133 sal_Int32 nNumberFormatKey, sal_Int32* pFormulaMaxWidth )
const
135 bool bHasIntercept = !rtl::math::approxEqual( fabs(
m_fIntercept), 1.0 );
137 sal_Int32 nLineLength =
aBuf.getLength();
138 sal_Int32 nValueLength=0;
139 if ( pFormulaMaxWidth && *pFormulaMaxWidth > 0 )
141 sal_Int32 nCharMin = nLineLength +
mXName.getLength() + 3;
147 nValueLength = (*pFormulaMaxWidth - nCharMin) / 2;
149 if ( nValueLength == 0 )
150 nValueLength = *pFormulaMaxWidth - nCharMin;
151 if ( nValueLength <= 0 )
162 OUStringBuffer aTmpBuf(
"");
164 sal_Int32* pValueLength = nValueLength ? &nValueLength :
nullptr;
166 aTmpBuf.append( OUStringChar(
aMinusSign) +
" " );
170 if ( aValueString !=
"1" )
172 aTmpBuf.append( aValueString +
" " );
177 aTmpBuf.append(
mXName +
"^" +
183 return aBuf.makeStringAndClear();
const sal_Unicode aMinusSign
PotentialRegressionCurveCalculator()
virtual double SAL_CALL getCurveValue(double x) override
virtual css::uno::Sequence< css::geometry::RealPoint2D > SAL_CALL getCurveValues(double min, double max, sal_Int32 nPointCount, const css::uno::Reference< css::chart2::XScaling > &xScalingX, const css::uno::Reference< css::chart2::XScaling > &xScalingY, sal_Bool bMaySkipPointsInCalculation) override
virtual OUString ImplGetRepresentation(const css::uno::Reference< css::util::XNumberFormatter > &xNumFormatter, sal_Int32 nNumberFormatKey, sal_Int32 *pFormulaLength=nullptr) const override
virtual void SAL_CALL recalculateRegression(const css::uno::Sequence< double > &aXValues, const css::uno::Sequence< double > &aYValues) override
virtual ~PotentialRegressionCurveCalculator() override
static bool isLogarithmicScaling(const css::uno::Reference< css::chart2::XScaling > &xScaling)
static void addStringToEquation(OUStringBuffer &aStrEquation, sal_Int32 &nLineLength, OUStringBuffer const &aAddString, const sal_Int32 *pMaxLength)
static OUString getFormattedString(const css::uno::Reference< css::util::XNumberFormatter > &xNumFormatter, sal_Int32 nNumberFormatKey, double fNumber, const sal_Int32 *pStringLength)
virtual css::uno::Sequence< css::geometry::RealPoint2D > SAL_CALL getCurveValues(double min, double max, sal_Int32 nPointCount, const css::uno::Reference< css::chart2::XScaling > &xScalingX, const css::uno::Reference< css::chart2::XScaling > &xScalingY, sal_Bool bMaySkipPointsInCalculation) override
double m_fCorrelationCoefficient
std::pair< std::vector< double >, std::vector< double > > tDoubleVectorPair
tDoubleVectorPair cleanup(const css::uno::Sequence< double > &rXValues, const css::uno::Sequence< double > &rYValues, Pred aPred)
takes the given x- and y-values and copies them into the resulting pair, which contains x-values in t...
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)