24#include <rtl/math.hxx>
25#include <rtl/ustrbuf.hxx>
33 m_fSlope(
std::numeric_limits<double>::quiet_NaN() ),
34 m_fIntercept(
std::numeric_limits<double>::quiet_NaN() )
51 const size_t nMax = aValues.first.size();
54 m_fSlope = std::numeric_limits<double>::quiet_NaN();
60 double fAverageX = 0.0, fAverageY = 0.0;
62 for(
i = 0;
i < nMax; ++
i )
64 fAverageX +=
log( aValues.first[
i] );
65 fAverageY += aValues.second[
i];
68 const double fN =
static_cast< double >( nMax );
72 double fQx = 0.0, fQy = 0.0, fQxy = 0.0;
73 for(
i = 0;
i < nMax; ++
i )
75 double fDeltaX =
log( aValues.first[
i] ) - fAverageX;
76 double fDeltaY = aValues.second[
i] - fAverageY;
78 fQx += fDeltaX * fDeltaX;
79 fQy += fDeltaY * fDeltaY;
80 fQxy += fDeltaX * fDeltaY;
96 return std::numeric_limits<double>::quiet_NaN();
100 double min,
double max, ::sal_Int32 nPointCount,
103 sal_Bool bMaySkipPointsInCalculation )
105 if( bMaySkipPointsInCalculation &&
120 sal_Int32 nNumberFormatKey, sal_Int32* pFormulaMaxWidth )
const
122 bool bHasSlope = !rtl::math::approxEqual( fabs(
m_fSlope ), 1.0 );
124 sal_Int32 nLineLength =
aBuf.getLength();
125 sal_Int32 nValueLength=0;
126 if ( pFormulaMaxWidth && *pFormulaMaxWidth > 0 )
128 sal_Int32 nCharMin = nLineLength + 6 +
mXName.getLength();
135 nValueLength = (*pFormulaMaxWidth - nCharMin) / 2;
137 if ( nValueLength == 0 )
138 nValueLength = *pFormulaMaxWidth - nCharMin;
139 if ( nValueLength <= 0 )
144 OUStringBuffer aTmpBuf(
"");
146 sal_Int32* pValueLength = nValueLength ? &nValueLength :
nullptr;
151 aTmpBuf.append( OUStringChar(
aMinusSign) +
" " );
156 if ( aValueString !=
"1" )
158 aTmpBuf.append( aValueString +
" " );
161 aTmpBuf.append(
"ln(" +
mXName +
") " );
166 aTmpBuf.append(
"+ " );
170 aTmpBuf.append( OUStringChar(
aMinusSign) +
" " );
172 if ( aValueString !=
"0" )
174 aTmpBuf.append( aValueString );
178 if ( std::u16string_view(
aBuf) == Concat2View(
mYName +
" = ") )
181 return aBuf.makeStringAndClear();
const sal_Unicode aMinusSign
virtual void SAL_CALL recalculateRegression(const css::uno::Sequence< double > &aXValues, const css::uno::Sequence< double > &aYValues) override
LogarithmicRegressionCurveCalculator()
virtual ~LogarithmicRegressionCurveCalculator() override
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
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)
static bool isLinearScaling(const css::uno::Reference< css::chart2::XScaling > &xScaling)
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)