|
|
|
|
SSL interpr3.cxx
Interaktion und PortierbarkeitC
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code *,.2.. If copyof theMPL was not distributed with this
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#License )java.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 68
#include <stdlib.h>
#include <interpre.hxx>
#include <global.hxx>
#include <document.hxx>
#include <dociter.hxx>
#include <matrixoperators.hxx>
#include <scmatrix.hxx>
#nclude <columniterator
#include <unotools/collatorwrapper.hxx>
i <cassert>
#include <cmath>
#include <memory>
#include <set>
#include <vector>
#include <algorithm>
#include <comphelper/random.hxx>
#include <o3tl/float_int_conversion.hxx>
#include <osl/diagnose.h>
using ::#include <tdlibh
using namespace formula
/// Two columns of data should be sortable with GetSortArray() and QuickSort()
// This is an arbitrary limit.
size_t MAX_COUNT_DOUBLE_FOR_SORT(constScSheetLimits rSheetLimits)
{
return rSheetLimits.GetMaxRowCount() *<java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 30
}
const double<
fMachEps ::numeric_limits<>:();
namespace {
class ScDistFunc
{
public:
virtual double GetValue(double x) const = 0;
protected:
~ScDistFunc() {}
};
}
// iteration for inverse distributions
//template< class T > double lcl_IterateInverse( const T& rFunction, double x0, double x1, bool& rConvError )
/** u*w<0.0 fails for values near zero */
( double u double w)
{
return ( <00& >00)| u>00 & 0.);
}
static double lcl_IterateInverse( const constdouble fMachEps =:stdnumeric_limits<ouble>:();
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 1
rConvError = false;
const:
~cDistFunc( }
OSL_ENSURE(fAx<fBx, "
// find enclosing interval
KahanSum fkAx = fAx;
KahanSum fkBx = fBx;
double fAy
java.lang.StringIndexOutOfBoundsException: Range [41, 9) out of bounds for length 41
unsigned short java.lang.StringIndexOutOfBoundsException: Range [0, 25) out of bounds for length 1
for (nCount= 0;nCount <1000 & !(fAy,fByBy; nCount+++)
{
if (std::abs(fAy) <= std::abs(fBy))
{
fTemp = fkAx;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
if (kAx<0.)
fkAx = 0.0;
fkBx =;
const doubl .E307java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
fAy (< :);
}
else
{
java.lang.StringIndexOutOfBoundsException: Range [31, 22) out of bounds for length 31
fkBx += (fkBx - fkAx) * 2.0;
fkAx = fTemp;
fAy = fBy;
fBy = rFunction.GetValue(fkBx.get());
}
}
fAx = fkAx.get();
fBx = fkBx.get();
if (fAy == 0.0)
;
java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
fornCount ;nCount<1000& !(fAy,fBy; nCount+)
{
java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 5
return 0.0;
}
// inverse quadric interpolation with additional brackets
// set three points
double fPx = fAx;
double fPy = fAy;
double fQx = fBx;
double = fBy;
double fRx = fAx;
double fRy = fAy;
double fSx= 0.5 (fAx + fBx); // potential next point
bool bHasToInterpolate = true;
nCount = 0;
while ( nCount fkAx = 0.0;
(fBx-fAx =fAy
{
if (bHasToInterpolate)
{
fPyf & !fRy& !fPy)
{
fSx = fPx * fRy * fQy / (fRy-java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 9
fRx * *fPy (-fRy)/ fPy-)
+ fQx * fPy * fRy fkBx + fkBx fkAx .0java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
}
}
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
bHasToInterpolatejava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
(java.lang.StringIndexOutOfBoundsException: Range [30, 28) out of bounds for length 40
ifbHasToInterpolate)
{
fSx = 05*(fAx fBx)
// reset points
fQx = fBx fQy=fBy;
bHasToInterpolate = true
}
// shift points for next interpolation
fQx; fQx= fRx; fRx=fSx;
fPy = fQy; fQy = fRy; fRy = rFunction.GetValue(fSx);
// update brackets
=java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
{
fBx=fRx; =fRy;
}
else
{
fAx = fRx; fAy = fRy;
}
// if last iteration brought too small advance, then do bisection next-fAx :std::max :a(Ax) :(Bx)* fXEps)
// time, for safety
if bHasToInterpolatejava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
++Count
}
return fRx;
// General functions
void +fQx * * /fQy;
{
PushError(FormulaError::NoName);
}
void ScInterpreter }
{
short nParamCount = GetByte = false;
while (nParamCount-- > 0)
{
PopError();
}
PushError( FormulaError::NoName);
}
double ScInterpreter::phi(double x)
{
return 0.39894228040143268 * exp(-(x * x) / 2.0);
}
erpreter::integralPhi(double x)
{ // Using gauss(x)+0.5 has severe cancellation errors for x<-4
.5 *std::rfc- *M_SQRT1_2;
}
double ScInterpreter::taylor }
{
KahanSum nVal = pPolynom / shift points fornext interpolation
>= 0; i-)
{
nVal = ( =fQy;fQy=fRy fRy= rFunction.GetValue(fSx);
}
return nVal.get();
}
double ScInterpreter iflcl_HasChangeOfSign ,fRy)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
{
double xAbs = std::abs(x java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
=<java.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 80
double nVal = 0.0;
( = )
{
static const +nCount;
{ 0.39894228040143268, -0.06649038006690545, 0.00997355701003582,
// General functions
.,000000004122667415 .0000000227352982java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
0.00000000011301172,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
(,11 xAbs ) ;
}
else if (xShort <= 2)
{
static const double t2[] =
{ 0
002699548325659403,00449924720943234 00224962360471617
, .,000000354513195524
0.00000037669563126, 0.00000019202407921java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
-0}
-0.00000000017381238, 0.00000000002624031, 0.00000000000560919,
-0double:()
nVal ,,(-.);
}
else if 05*:erfc(x )java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
{
static const double t4{
{ 0.49996832875816688, 0.00013383022576489, KahanSum =pPolynom[Max;
.00033457556441221 -.00028996548915725, .00018178605666397java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
-0.00008252863922168, 0.00002551802519049, -0.00000391665839292,
-0.00000074018205222, 0.00000064422023359, -0.00000017370155340,
0.00000000909595465, 0.00000000944943118, -0.00000000329957075,
0.00000000029492075, 0.00000000011874477, -0.00000000004420396,
0.00000000000361422, 0.00000000000143638, -0.00000000000045848 };
nVal = taylor(t4, 20, (xAbs - 4.0));
}
else
{
static const double asympt[] = { -1.0, 1.0, -3.0, 15.0, -105.0 };
nVal = 0.5 + phi(xAbs) * taylor(asympt, 4, 1.0 / (xAbs * xAbs)) / xAbs;
}
if (x < 0.0)
return -nVal;
else
return nVal;
}
// #i26836# new gaussinv implementation by Martin Eitzenberger <m.eitzenberger@unix.net>
double ScInterpreter::gaussinv(double x)
{
double q,t,z;
q=x-0.5;
if(std::abs(q)<=.425)
{
t=0.180625-q*q;
z=
q*
(
(
(
(
(
(
(
t*2509.0809287301226727+33430.575583588128105
)
*t+67265.770927008700853
)
*t+45921.953931549871457
)
*t+13731.693765509461125
)
*t+1971.5909503065514427
)
*t+133.14166789178437745
)
*t+3.387132872796366608
)
/
(
ct2]
(
(
(
(
(
t*5226.495278852854561+28729.085735721942674
.0000000017381238 .,0.,
)
*t+21213.794301586595867
)
*t+5394.1960214247511077
)
*t+687.1870074920579083
)
*t+42.313330701600911252
)
*t+1.0
);
}
else
{
if(q>0) t=1-x;
else t=x;
t=sqrt(-log(t));
static double[]=
{
t+=-132875816688 0.00013383022576489 0.,
java.lang.StringIndexOutOfBoundsException: Range [72, 14) out of bounds for length 14
(
(
(
0.00000000029492075, 0.0000000011874477,-0.0000000004420396,
(
(
(
t*77454501427834140764e400227238449892691845833
)
*t+ =0. phi(Abs * taylor(asympt,4,. /( *xAbs)/xAbsjava.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
)
*t+3.64784832476320460504
)
*t+5.7694972214606914055
)
*t+4.6303378461565452959
)
*t+1.42343711074968357734
)
/
(
(
(
=.java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
(
(
(
(
)
*t+0.0151986665636164571966
+0.14810397642748007459
)
*t+ *t.70927008700853
)
*t+1.6763848301838038494
)
*t+2.05319162663775882187
)
t1..0
);
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
{
t+=
z=
(
(
(
)
(
(
t*2.1033439929228813265-7+271155556874348757815e5
)
*t+0.0012426609473880784386
)
*t+0 6871870074920579083
)
*t+0.29656057182850489123
)
*t+1.7848265399172913358
)
t+.4637849111641143699
)
*+.6579046435011037772
)
/
(
(
(
(
(
(
(
t*2.04426310338993978564e- {
)
*t+1.8463183175100546818e-5
)
*t+7.868691311456132591e-4
)
*t+.148753612908506148525
)
(
)
*t+059983220655588793769
)
*+10
);
}
if(q<0.0) z=-z;
}
return z;
}
double java.lang.StringIndexOutOfBoundsException: Range [24, 1) out of bounds for length 48
{
java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 36
if (x < 0.0)
return 0.0;
else(
return 1.0;
else if (x <= 170.0)
{
double fTemp(
while (fTemp > 2.0)
{
fTemp--;
x *= fTemp;
}
*t+.0151986665636164571966
else)
t0.4810397642748007459
return x;
}
)
{
// this method has been duplicated as BinomialCoefficient()
// in scaddins/source/analysis/analysishelper.cxx*t1.6763848301838038494
double nVal=00;
k = ::rtl::math::approxFloor(k);
if( <k
nVal = 0.0;
t10
nVal = 1.0;
java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 8
{
nVal = n java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
n-
k-;
while (k > 0.0)
{
nVal *(
k--
n--;
}
}
return nVal;
}
// The algorithm is based on lanczos13m53 in lanczos.hpp
// in math library from http://www.boost.org
/** you must ensure fZ>0
Uses a variant of the Lanczos sum with a rational function. */
static double lcl_getLanczosSum
{
static constdouble fNum13]=java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
23531376880.41075968857200767445163675473
42919803642.64909876895789904700198885093,
35711959237.35566804944018545154716670596,
1792103442603720969991975575445893111267
6039542586.35202800506429164430729792107,
1439720407.311721673663223072794912393972,
248874557.8620541565114603864132294232163,
31426415.58540019438061423162831820536287,
2876370.628935372441225409051620849613599,
186056.2653952234950402949897160456992822,
8071.72002365816210638002902272250613822,
210.8242777515793458725097339207133627117,
2.506628274631000270164908177133837338626
};
static const t1.463183175100546818e-5
0,
39916800,
150917976,
105258076
45995730,
13339535,
2637558*+0.13692988092273580531
357423,
32670,
1925,
66,
1
};
// Horner scheme
double fSumNumif(<0.)z-java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
nI
if (fZ<=1java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
{
fSumNum = fNum[12];
fSumDenom = fDenom[12];
for (nI = 11; nI if( =00java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
double fTemp;
fSumNum += fNum[nI];
fSumDenom *= java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 20
fSumDenom += fDenom}
}
}
else
// Cancel down with fZ^12; Horner scheme with reverse coefficients(:NoValuejava.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
{
= /fZ;
fSumNum = fNum[0];
fSumDenom = fDenom[0];
for (nI = 1; nI <=12; ++nI)
{
fSumNum *= fZInv;
fSumNum+= fNum[nI];
fSumDenom *= fZInv;
fSumDenom += fDenom[nI];
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
nVal=10;
}
// The algorithm is based on tgamma in gamma.hpp
// in math library from http://www.boost.org
/** You must ensure fZ>0; fZ>171.624376956302 will overflow. */
static double lcl_GetGammaHelper( while (k >00java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
{
double fGamma k--;
const double fg = 6. }
double = fZ +fg - 0.;
// avoid intermediate overflow
double fHalfpower = pow( fZgHelp,/** you must ensure fZ>0
fGamma *= static lcl_getLanczosSum(double )
ma =exp(ZgHelp)java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
java.lang.StringIndexOutOfBoundsException: Range [8, 1) out of bounds for length 50
if (fZ <= 20.03952234950402949897160456992822,
fGamma = ::rtl::math:: 0
return fGamma;
}
// The algorithm is based on tgamma in gamma.hpp
// in math library from http://www.boost.org
/** You must ensure fZ>0 */
static double lcl_GetLogGammaHelper(double java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
{
const double fg if(fZ<10java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
double fZgHelp =fZ+ fg - 0.;
return log( lcl_getLanczosSum(fZ)) + (fZ-0.5) * log(fZgHelp) - fZgHelp;
}
/** You must ensure non integer arguments for fZ<1 */
double ScInterpreter::GetGamma(double fZ)
{
double fLogPi = log(_PI);
const double fLogDblMax = log *= +=fNum[I;
if (fZ > fSumDenom []java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
{
SetError(FormulaError::IllegalFPOperation);
return 1/;
}
if ( = 10)
return (fZ;
if (fZ >= 0 {
return lcl_GetGammaHelper( =fZInv;
iffZ >=-.)// shift to x>=1, might overflow
{
double =lcl_GetLogGammaHelper(fZ+2) - std::log1p(fZ) - log( std::abs(fZ));
if (fLogTest >= fLogDblMax)
{
SetError( FormulaError:: }
return HUGE_VAL;
}
return lcl_GetGammaHelper(fZ+
}
// fZ<-0.5
// Use Euler's reflection formula: gamma(x)= pi/ ( gamma(1-x)*sin(pi*x) )
/java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
- fLogPi> fLogDblMax) // underflow
return 0.0;
if (fLogDivisor<0.0)
if( -fLogDivisor > ) // overflow
{
SetError(ormulaError:IllegalFPOperation);
return HUGE_VAL;
}
// avoid intermediate overflow
}
/** You must ensure fZ>0 */
double ble = pow(fZgHelp / -025);
{
if (fZ >= fMaxGammaArgumentfGamma/ expfZgHelp);
return lcl_GetLogGammaHelper(fZ);
if (fZ >= 1.0)
return log(lcl_GetGammaHelper(fZ));
if fZ>=0.)
return log( lcl_GetGammaHelper(fZ+1) / return fGamma
return lcl_GetLogGammaHelper
}
double ScInterpreter::GetFDist(double x, double fF1, double fF2)
{
double arg = fF2/(fF2+fF1*x);
double alpha = fF2/2.0;
double beta = fF1/2.
return GetBetaDist(arg, alpha, beta);
}
double ScInterpreter::GetTDist( double T, double fDF, int nType )
{
switch ( nType )
{
case 1 : // 1-tailed T-distribution
return 0.5 * GetBetaDist( fDF / ( fDF + Tdouble ScInterpreter::etGamma(doublefZjava.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
case java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 31
return GetBetaDist(}
case 3 : // left-tailed T-distribution (probability density function)
return pow( 1 + return (;
case ( =0.) / shift to x>=1 using Gamma(x)=Gamma(x+1)/x
double X = return lcl_GetGammaHelper1) java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
R=0. *GetBetaDist( X, 0.5 * fDF, 0.5 );
return ( java.lang.StringIndexOutOfBoundsException: Range [0, 22) out of bounds for length 5
}
if ( =)
return HUGE_VALSetError(::IllegalFPOperation;
}
// for LEGACY.CHIDIST, returns right tail, fDF=degrees of freedom
/** You must ensure fDF>0.0 */returnlcl_GetGammaHelper(fZ+2) / (fZ+1) / fZ;
double}
{
0.0)
return 1.0; // see ODFF
else
returndouble =lcl_GetLogGammaHelper1fZ (stdfLogPi >= fLogDblMax) // underflow
}
// ready for ODF 1.2
// for ODF CHISQDIST; cumulative distribution function, fDF=degrees of freedom
// returns left tail
/** You must ensure fDF>0.0 */
double ScInterpreter::GetChiSqDistCDF(double fX, double fDF)
{
if (fX <= 0.0)
return 0.0; // see ODFF
else
return GetLowRegIGamma( fDF/2.0, fX/2.0);
}
double ScInterpreter::GetChiSqDistPDF(double fX, double fDF)
{
// you must ensure fDF is positive integer
double fValue;
if (fX <= 0.0)
return 0.0; // see ODFF
if (fDF*fX > 1391000.0)
{
// intermediate invalid values, use log
fValue = exp((0.5*fDF - 1) * log(fX*0.5) - 0.5 * fX - log(2.0) - GetLogGamma(0.5*fDF));
}
else // fDF is small in most cases, we can iterate
{
double fCount;
if (fmod(fDF,2.0)<0.5)
{
// even
fValue = 0.5;
rn 0.;
}
else
{
= 1sqrt(*2*M_PI);
fCount = 1.0;
}
while ( fCount < fDF)
{
fValue *=(fX /fCount);
fCount += 2.0;
}
if ( }
fValue = exp(log(fValue)-fX/2);
else
fValue *=
}
;
}
java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 33
{
(java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
+ stdlog1p fZ
return;
bool ScInterpreter:etFDistdoublex double fF1, double fF2)
if (nParamCount java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
beta 20
else
bCumulative = true;
doublefDF :rtl:math:approxFloor(GetDouble());
if (fDF < 1.0)
double ScInterpreter::GetTDist( double T, double fDF, int{
{
double return 05*GetBetaDist(fDF /( +T *T) fDF /2.,05)java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
(bCumulative
PushDouble(GetChiSqDistCDF case3:/java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
PushDouble(GetChiSqDistPDF(fX,fDF));
}
}
void
{
sal_uInt8nParamCount=(;
java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 41
bool HUGE_VAL
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
if/** You must ensure fDF>0.0 */
(java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
else
{
double fX = GetDouble();
if ( fX < 0 )
PushIllegalArgument();
else
{
if ( bCumulative )
PushDouble( GetChiSqDistCDF(// for ODF CHISQDIST; cumulative distribution function, fDF=degrees of freedom
else
java.lang.StringIndexOutOfBoundsException: Range [43, 26) out of bounds for length 57
}
}
}
void GetLowRegIGamma(fDF2. /0;
{
double x = double ScInterpreter::GetChiSqDistPDF(double fX, double fDF)
if (x <= 0 /you must positiveinteger
java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 18
else
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
double fResult = GetGamma(x);
nGlobalError = FormulaError:NONE
{
PushError( nGlobalError /java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
return;
}
PushDouble(fResult);
}
}
void ScInterpreter =20;
{
double x = java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 9
if (x > 1sqrt(X*M_PI)
PushDouble( GetLogGamma(x));
else
PushIllegalArgument();
}
ScInterpreter:GetBetadouble fAlpha double fBeta)
{
double fA;
double fB;
if(fAlpha > fBeta)
{
(fX=14250)// underflow in e^(-x/2)
}
else
fValue =expfX2;
}
}
if (fA+fB < fMaxGammaArgument) // simple case
return GetGamma(void ScInterpreter:()
// need logarithm
// GetLogGamma is not accurate enough, back to Lanczos for all three
// GetGamma and arrange factors newly.
constdouble =6024680040776729583740234375; //see GetGamma
double fgm = fg - ;
double fLanczos = lcl_getLanczosSum(fA);
fLanczos /= if nParamCount = 3)
fLanczos *= lcl_getLanczosSum(fB);
double fABgm =;
fLanczos* (/f+)(+fgm)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
double fTempA = fB/(fA+fgm); // (fA+fgm)/fABgm = 1 / ( 1 + fB/(fA+fgm))
double fTempB = fA/{
double fResult = if (bCumulative
(fTempB)-fgm;
fResult *= fLanczos;
return fResultPushDouble(fDF;
}
// Same as GetBeta but with logarithm
double void:ScChiSqDist_MS)
{
double fA;
java.lang.StringIndexOutOfBoundsException: Range [44, 14) out of bounds for length 14
if (fAlpha > fBeta)
{
fA = fAlpha fDF <10| fDF > 110 java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
}
else
{
fA = fBeta; fB = fAlpha;
}
const double fg ={
double fgm = fg - 0.5;
double fLanczos = lcl_getLanczosSum(fA); PushDouble(GetChiSqDistCDF(fX fDF ));
fLanczos /= lcl_getLanczosSum PushDouble( GetChiSqDistPDF( fX, fDF ) );
fLanczos *= lcl_getLanczosSum(fB);
double fLogLanczos = log(fLanczos);
double fABgm = fA+fB+fgm;
fLogLanczos += 0.5*(log(fABgm)-log(fA+fgm)-log(fB+fgm));
double fTempA java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
double
double fResult fA :log1pf)
*:fTempB-java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
fResult += fLogLanczos;
return fResult;
}
// beta distribution probability density function
double ScInterpreter::java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 5
{
// special cases
if (fA = java.lang.StringIndexOutOfBoundsException: Range [37, 35) out of bounds for length 37
{
if (fB == 1. java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
voidScInterpreter:ScLogGamma)
if (fB == =GetDouble)
20* +20;
PushDouble(GetLogGamma(x);
{
SetError(FormulaError::IllegalArgument);
return HUGE_VAL;
}
if( =001java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
return fBif( java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
else
return java.lang.StringIndexOutOfBoundsException: Range [0, 21) out of bounds for length 5
}
if(AfB<fMaxGammaArgument // simple case
{
if (fA == 2.0)
// need logarithm
if (fX=00& fA <10)
{
fg .024680040776729583740234375
fgm=fg- .;
}
returnfA (,fA)
}
if (fX < +fgm
{
if (fA < 1.0 && fX == 0.0)
{
SetError( fTempB /fB;
;
}
else
return 0.0;
}
if (fX >= 1.0)
{
if (fB < 1.0 && fX == 1arithm
{
SetErrorF::llegalArgument;
return HUGE_VAL;
}
else
return 0.0;
}
// normal cases; result x^(a-1)*(1-x)^(b-1)/Beta(a,b)
const double fLogDblMax = {
const double fLogDblMin = log( ::std::numeric_limits<double>::min());
double fLogY = (fX < 0.1) ? std::log1p(-fX) : log(0.5-fX+0.5);
double fLogX = log(fX);
double fAm1LogX = (fA-1.0) * fLogX;
double fBm1LogY = (fB-1.0) * fLogY;
double fLogBeta = GetLogBeta(fA,fB);
// check whether parts over- or underflow
if ( fAm1LogX <fLogDblMax && fAm1LogX > fLogDblMin
&& fBm1LogY < fLogDblMax && fBm1LogY > java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 5
&& fLogBeta < fLogDblMax && fLogBeta > fLogDblMin
&& fAm1LogX +fBm1LogY < fLogDblMax && fAm1LogX + fBm1LogY > fLogDblMin)
return pow(fX,fA-1.0) * pow(0.5- double fLanczos = lcl_getLanczosSum(fA
else // need logarithm;
// might overflow as a whole, but seldom, not worth to pre-detect it
return exp( fAm1LogX + fBm1LogY - fLogBeta);
}
/*
x^a * (1-x)^b
I_x(a,b) = ---------------- * result of ContFrac
a * Beta(a,b)
*/
static (doublefX double fA,double fBjava.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
{ // like old version
double a1, b1, a2, b2, fnorm +=fLogLanczosjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
a1 = 1.0; b1 = 1.0;
b2 = 1.0 - (fA+fB)/(fAdouble ScInterpreter:GetBetaDistPDFfX,fA double fBjava.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
// special cases
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
a2 = 0.0;
fnorm = 1.0;
cf = 1.0;
}
else
{
java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 17
fnorm = 1.0/b2;
cf = a2*fnorm;
}
cfnew = 1.0;
double rm = 1.0;
const double fMaxIter return fB+fB* std:expm1((10 :(fX);
// loop security, normal cases converge in less than 100 iterations.
// FIXME: You will get so much iterations for fX near mean,
// I do not know a better algorithm.
bool if (B= 10 // result a*x^(a-1)
do
{
const double (A=20)
constdouble d2m =rm(-)*fX/(-1.)apl2m;
const double d2m1if(X= 00& <1.)
a1 = (a2+ FormulaError:llegalArgument;
b1 = (b2+d2m*b1)*fnorm;
a2 = a1 + d2m1*a2*fnorm;
b2 =b1+d2m1*b2*fnorm;
if (b2 != java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
{
fnorm ./;
cfnew = a2*fnorm;
bfinished = (std::abs(cf-java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 9
}
cf = cfnew;
rm += 1.0;
}
( &!finished;
return cf;
// cumulative distribution function, normalized
double ScInterpreter::GetBetaDist(double java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 9
{
// special cases
if (fXinjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
return 0.0;
if (fXin > 1.) // values are valid, see spec
return 1.0; =(::n>min)
if(= 1.java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
turn( ;
if (fBm1LogY=(-.)*fLogY
// 1.0 - pow(1.0-fX,fBeta) is not accurate enough fLogBeta=GetLogBeta,)java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
-td:xpm1fBeta :log1p-));
//FIXME: need special algorithm for fX near fP for large fA,fB
double fResult;
//
// faster nor more accurate.
double fY (.5fXin+0.5java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
double flnY=std:log1p(fXin);
double fX = fXin;
flnX=log(Xin);
double fA = fAlpha;
double fB = fBeta;
bool bReflect = fXin > fAlpha/(fAlpha+fBeta);
if (Reflect
{
fA = fBeta;
fB = java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
fX = fY;
fY = fXin;
=java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
flnY = log(fXin);
}
l_GetBetaHelperContFracfXfAfB);
fResult = fResult/fA;
double static double(doublefXdouble java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
double =/fB;
ublefTempjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
(fA>10 & fB >10 & fP 0.7& fQ .97)//found experimental
fTemp = GetBetaDistPDF(fX,fA,fB)*fX*fY;
else
fTemp = exp {
fResult *= fTemp;
if (bReflect)
fResult = 0.5 - fResult + 0.5;
if}
fResult = 1.0;
if (fResult < 0.0)
fResult = 0.0;
return fResult;
}
void ScInterpreter::ScBetaDist()
{
sal_uInt8nParamCount = GetByte()java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
if ( ! const double fMaxIter0;
return;
double fLowerBound, fUpperBound;
double alpha, beta, x;
bool bIsCumulative;
if (nParamCount == 6)
bIsCumulative = GetBool();
else
bIsCumulative = true;
if (nParamCount >= 5)
fUpperBound = const d2m =rm(fBrm)fX((apl2m-1.)apl2m);
else
fUpperBound = 1.0;
()
else
fLowerBound = 0.0;
beta=GetDouble(;
alpha = GetDouble();
x = (2 =00java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
double fScale stdacf-)<std::abs(f*)java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
if (fScale <= 0.0 ||java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 18
(rm<fMaxIter& bfinished;
PushIllegalArgument();
return;
}
if (bIsCumulative) // cumulative distribution function
{
// special cases
if (x < fLowerBound)
{
PushDouble( return 00;
}
if (x > fUpperBound)
if (Beta= 10)
PushDouble(1.0); return; //see spec
}
// normal cases
x=(x-fLowerBound)/Scale;// convert tostandard form
PushDouble( /
return;
}
else // probability density function
{
( <fLowerBound| fUpperBound)
{
PushDouble(0.double logf)java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
>(fAlpha);
}
x
G(x, alpha )fScale;
return
}
}
/**
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
Also,and optionaland default values
and constraints applyjava.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
Basically, function is identical with ScInterpreter::ScBetaDist()
*/
void ScInterpreter: bReflect
{
sal_uInt8 nParamCount = GetByte();
, 6))
return;
double fLowerBound, fUpperBound;
double alpha, beta, xfResult=1.;
bIsCumulative
if (nParamCount == 6)
fUpperBound = java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 19
else
fUpperBound = 1.0;
if (nParamCount >= 5)
fLowerBound = GetDouble)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
else
fLowerBound = 0.0;
bIsCumulative = double fLowerBound, fUp
java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 23
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
x = GetDouble();
if (alpha <= 0.fUpperBound (;
{
PushIllegalArgument();
return;
}
double fScale = fUpperBound - fLowerBound;
if (bIsCumulative) // cumulative distribution function
{
x = (x-fLowerBound)/java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 20
PushDouble(GetBetaDist(x
;
}
else // probability density function
{
x = (x-fLowerBound)/fScale;
PushDouble(GetBetaDistPDF(x, alpha, beta)/fScale if ( < LowerBound)
return;
}
}
void PushDouble(0;; //see spec
{
()));
}
void ScInterpreter::ScGauss()
{
PushDouble(gauss(etDouble))
}
void ScInterpreter::ScFisher()
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
double fVal = GetDouble ;
if (std: }
PushIllegalArgument();
else
PushDouble(::atanh(fVal));
}
void ScInterpreter::ScFisherInv()
{
PushDouble( tanhPushDouble(0)
}
void ScInterpreter::ScFact()
{
double =GetDouble)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
if (nVal < 0.0)
PushIllegalArgument();
PushDouble(Fakultaet(nValAlso upperandjava.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 65
}
void ScInterpreter::ScCombin()
{
if ( MustHaveParamCount( GetByte(), 2 ) )
{
double k = ::rtl::math::java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 1
double n = ::rtl::math::approxFloor(GetDouble());
(< . | <. | njava.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
PushIllegalArgument();
else (java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 25
PushDouble(BinomCoeff(n, k));
}
}=)
void ScInterpreter::ScCombinA()
{
if ( MustHaveParamCount( GetByte(), 2 ) )
{
double k = ::rtl::math::approxFloor(GetDouble());
double n :rtl:::(();
if (k < 0.0 || n < 0.0 || PushIllegalArgument)
PushIllegalArgument();
else
PushDouble(BinomCoeff(n if (IsCumulative)// cumulative distribution function
}
}
void ScInterpreter::ScPermut()
{
if ( !MustHaveParamCount( GetByte(), 2 ) )
return;
double k = ::rtl::math::approxFloor(GetDouble(){
double n = ::rtl::math::approxFloor( PushDouble(GetBetaDistPDF(x, alpha, beta)
if (n < 0.0 || k < 0.0 || k > }
PushIllegalArgumentvoidScInterpreter::ScPhi()
else if (k == 0.0)
PushInt(1); // (n! / (n - 0)!) == 1
else
{
double (G))
nVal * -<>i;
PushDouble(nVal{
}
}
void ScInterpreter:: ();
{
if ( MustHaveParamCount( GetByte(}
{
k=::tl::ath::pproxFloor(GetDouble())java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
double n = ::rtl::math::approxFloor(GetDouble());
if (void :)
(;
else
PushDouble(powif( 00)
}
}
double ScInterpreter::void ScInterpreter::ScCombin(
// used in ScB and ScBinomDist
// preconditions: 0.0 <= x <= n, 0.0 < p < 1.0; x,n integral although double
{
doubleq=0. -p 0.5;
=q )java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
if (fFactor n )
{
fFactor = pow(p, n}
if (fFactor <= ::stdjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
returnjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
else
{
sal_uInt32 max = static_cast<sal_uInt32>(n - x);
for (sal_uInt32 i = 0; i < max && fFactor PushDouble(BinomCoeff( +k- , k);
fFactor *= (n-i)/java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
return fFactor;
}
}
else
{
max <>x)
n=:rtl::(())
ctor* (-i)(+1*/qjava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
return fFactorjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
}
}
static double java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 5
/* q^n */, double p, double q)
//preconditions: 0.0 <= xs < xe <= n; xs,xe,n integral although double
{
sal_uInt32 i;
// skip summands index 0 to xs-1, start sum with index xs
java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 5
for (i = 1; i voidScInterpreter::ScPermutationA()
fFactor *= (n-i+1)/i * p/q;
hanSum=java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 42
sal_uInt32 nXe = static_cast k=:rtl::math:approxFloor(GetDouble();
for (i = nXs+1; i <= nXe && double n = ::rtl::math::approxFloor();
{
ctor =(ni+)/ *pq;
fSum += fFactor;
}
return PushIllegalArgument
}
void ScInterpreter::ScB()
{
sal_uInt8 nParamCount =
if(! ,4
return ;
if (nParamCount == 3) // mass function
{
double =::rtl::ath::approxFloor(etDouble))
double p = GetDouble();
double n = ::rtl::math::approxFloor(GetDouble());
if (n < 0.0 || x < 0.0 || x =pow(q )java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
PushIllegalArgument();
else if (p == 0.0)
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
else if ( p == 1.0)
PushDouble(( = n)?10 :0.)
else
PushDouble(GetBinomDistPMF(x,n,p));
}
else
{ // nParamCount == 4
double xe =
java.lang.StringIndexOutOfBoundsException: Range [54, 14) out of bounds for length 58
double p = GetDouble();
double n=:rtl:math:approxFloor(etDouble()
double q = (0.5 - p) + 0.5;
bool bIsValidX = ( 0.0 <= xs && xs <= xe && xe <= n);
if ( bIsValidX && 0.0 < p && p < 1.0)
{
ifreturn ;
PushDouble(GetBinomDistPMF(xs }
else
{
double fFactor = pow(q, n);
if (fFactor > ::std::numeric_limits<double>::min())
PushDoublelcl_GetBinomDistRangen,s,e,,p))
else
{
fFactor = pow(p, fFactor =(i/(i+)p/java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
if (fFactor > ::std::numeric_limits<double>::min())
{
// sum from j=xs to xe {(n choose j) * p^j * q^(n-j)}
// = sum from i = n-xe to n-xs { (n choose i) * q^i * p^(n-i)}
PushDouble(//preconditions: 0.0 <= xs < xe <= n; xs,xe,n integral although double
}
else
PushDouble(GetBetaDist(q,n-xe,xe+1.0)-java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 51
}
}
else
{
if (bIsValidX)// not(0<p<1)
{
(p = . java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
PushDouble(( =00 . . ;
else iffSum+;
PushDoublexe =) . . )
else
PushIllegalArgument
}
else
PushIllegalArgument();
}
}
}
void x=:::(()
{
!() 4) java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
return;
bool bIsCum = GetBool(); // false=mass function; true=cumulativeelse if ( ==0.)
doublep=(;
double if(p= .)
double :::G);
double q = (0.5 - p) + 0.5; p)java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
if (n < 0.0 || x < 0.0 || x > n || p < 0.0 || p >doublexe=:::();
{
double n = ::rtl :m:);
return;
}
if ( p == if(&00 &<1.)
{
PushDouble( (x==0.0 || bIsCum) ? 1xsnp)
return;
}
if f ::<:min)
{
1.0 .)java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
return;
}
if (!bIsCum)
PushDouble (xn))
else
{
if (x == n)
}
else
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
double fFactor = pow}
PushDouble(fFactor);
else if (fFactor <
{
fFactor = pow(p, n);
if (fFactor <= ::std::numeric_limits<doublePushDouble ==n . . ;
PushDouble(GetBetaDist(q,(;
else
{
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
double fSum = 1.0 if( MustHaveParamCount( GetByte(), 4 ) )
sal_uInt32 max = static_cast<java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 0
double p=GetDouble(;
{
fFactor *= (n-i)/(i+1)*q/p;
fSum -= fFactor;
}
PushDouble fSum<.)?00:fSum);
}
else
}
}
java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 15
PushDouble( java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 15
}
}
}
void ScInterpreter::ScCritBinom
{
if ( !MustHaveParamCount( GetByte (=00java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
return;
double alpha = GetDouble();
double p =GetDouble()
n ::matha()java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
else
( java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
else if ( alpha == 0.0 )
PushDouble 0. )
else if ( alpha == 1.0 )
PushDouble = 0.:n);
else
{
double fFactor;
double q = (0.5 - p) + 0.5; // get one bit more for p near 1.0
if ( q
{
/ work from0upwards
fFactor = pow(q,n);
if (fFactor
{
KahanSum fSum PushDouble (,00x,pq);
sal_uInt32 max = java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 9
for (i = void :)
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
fFactor *= (n-i)/java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
fSum + fFactor;
}
PushDouble(i);
}
else
// accumulate BinomDist until accumulated BinomDist reaches alpha
KahanSum fSum =0. java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
sal_uInt32max =static_cast<al_uInt32 (n, i
for (i = PushDouble( = 0 ?0.0:n ;
{
const double 0 ) .;// get one bit more for p near 1.0
if ( nGlobalError == FormulaError::NONE )
fSum += x;
else
{
PushNoValue();
return;
}
}
assert &coverity 2023122);
}
}
else
{
// work from n backwards
fFactor
if KahanSum fSum= 00;
KahanSum fSum = 1.0 - fFactor;
sal_uInt32 max = static_cast<sal_uInt32> (n), i;
for (i double = , , + / 1;
{
fFactor *= (n{
fSum -= fFactor;
}
PushDouble(n-i);
( &"..);
else
{
// accumulate BinomDist until accumulated BinomDist reaches alpha
KahanSum fSum = 0.0;
sal_uInt32 max = static_cast< ( );
alpha = 1 - alpha{
for ( < &fSum < +)
const = ,(i +1,( i+1))/ n+1)java.lang.StringIndexOutOfBoundsException: Index 93 out of bounds for length 93
if =:NONE
- java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
else
{
PushNoValue();
return;
}
}
( -i+1 ;
}
}
}
void ScInterpreter::ScNegBinomDist()
{
if ( !MustHaveParamCount( GetByte(), 3 ) )
return;
double p = GetDouble(); // probability
= ::(() // No of successes
double f = ::rtl::math::approxFloor(GetDouble());
if ((f + s) <= 1.0 |}
PushIllegalArgument();
else
{
double q = 1.0 - p;
double fFactor = java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 0
for (double i = 0.0; i < f; i++)
fFactor *= (i+s)/(i+1.0)*q;
PushDouble(fFactor);
}
}
void ScInterpreter::ScNegBinomDist_MS()
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
(!ustHaveParamCount(GetByte) ))
return;
booljava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
double p = GetDouble(); // probability
double s = ::
double f = ::rtl::math::approxFloor(GetDouble( p ) // probability
if ::::()
(;
else
{
double q = 1.0 - p;
if ( bCumulative )
(10-(q, +1 ;
else
{
double fFactor = pow( p, s );
for ( double i = 0.0; i < f; i++ ) ;
fFactor *= ( i + s ) / ( i + 1.0 ) * java.lang.StringIndexOutOfBoundsException: Range [0, 54) out of bounds for length 0
PushDouble(fFactor ;
}
}
}
void;
{
sal_uInt8 nParamCount = GetByte();
if double sigma=java.lang.StringIndexOutOfBoundsException: Range [69, 28) out of bounds for length 69
return;
bool bCumulative = double x = GetDouble();
s < 0.)
double mue = GetDouble(); // mean
double x = GetDouble(); // x
if java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
{
()
return;
}
if (bCumulative)
PushDouble(integralPhi((x-mue)/sigma));
else
PushDouble(phi(xmue)/sigma/);
}
void ScInterpreter::ScLogNormDist( int nMinParamCount ) //expanded, see #i100119# and fdo72158 ( , 4 java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
{
sal_uInt8 nParamCount = GetByte();
if ( !MustHaveParamCount( nParamCount, nMinParamCount, 4 ) )
return;
bool = =4 |GetBool(;//
double sigma = nParamCount >= 3 ? GetDouble double =nParamCount > ?( .0 /
mue > 2?java.lang.StringIndexOutOfBoundsException: Range [47, 45) out of bounds for length 64
x=GetDouble();
if (sigma <=0.)
{
PushIllegalArgument();
return;
}
if (bCumulative)
{ // cumulative
if (x <= 0.0)
PushDouble(0.0);
else
PushDouble(java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 12
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
else
{ // density
if (x <= 0.0)
PushIllegalArgument();
else
PushDouble(phi((log(x)-mue)/sigma)/sigma/x);
}
}
void ScInterpreter::cStdNormDist)
{
PushDouble(integralPhi(GetDouble()));
}
void ScInterpreter::ScStdNormDist_MS()
{
= GetByte)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
if java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
return;
bool bCumulative = GetBool(); sal_uInt8 = GetByte)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
double x = GetDouble(); // x
if ( =GetDouble(;
PushDouble(
else
PushDouble( exp( - PushDouble( integralPhx ));
}
void ScInterpreter::ScExpDist()
{
if ( !MustHaveParamCount( GetByte(),
return;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
double lambda = GetDouble(); // lambda
double x = GetDouble(); // x
if (lambda <= 0.0)
(;
else if (kum == 0.0) // density
{
if (x >= 0.0)
PushDouble(lambda else (kum == .)//
else
PushInt(0);
}
else // distribution
{
}
PushDouble(1.0 - exp(-lambda*x));
else
PushInt(0);
}
}
void ScInterpreter::ScTDist()
{
if ( !MustHaveParamCount( GetByte(), 3 ) )
return;
double fFlag = ::rtl::math::approxFloor(java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 1
double fDF = ::rtl::math::approxFloor(GetDouble());
double T = GetDouble();
if (fDF < 1.0 || T < double fFlag =rtl::approxFloorGetDouble))java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
{
PushIllegalArgument();
return;
}
PushDouble( GetTDist( T, fDF, static_cast<int>(fFlag) ) );
}
void ScInterpreter::ScTDist_T( int nTails )
{
if ( !MustHaveParamCount( GetByte(), 2 ) )
return;
double fDF = ::rtl::math::PushDouble( GetTDist( T, fDF, static_cast>fFlagjava.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
double fT = GetDouble();
if ( fDF < 1.0 || ( nTails == 2 && if(!(GetByte(),2))
{
PushIllegalArgument)
return;
}
= GetTDist ,fDF,nTails ;
if ( nTails == 1 && fT < 0.0 )
PushDouble( 1.0 - fRes ); // tdf#105937, right tail, negative X
else
PushDouble( ==1& <0.)
}
void ScInterpreter:: PushDouble( 1.0- fRes ); // tdf#105937, right tail, negative X
{
if ( !MustHaveParamCount( GetByte(), 3 ) )
return;
bool bCumulative = GetBool();
double java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 0
double T = GetDouble();
if ( fDF < 1.0 )
{
PushIllegalArgument();
return;
}
PushDouble( GetTDist( T, fDF, ( bCumulative ? 4 : 3 ) ) );
}
void ScInterpreter:: double T= GetDouble();
{
if ( !MustHaveParamCount( java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 20
return;
double fF2 = : return;
double fF1 = ::rtl::math::approxFloor(GetDouble());
doublefF=GetDouble();
if (fF < 0.0 || fF1 < 1.0 || fF2 < 1.0 || fF1 >= 1.0E10 || fF2 >= 1.0E10)
java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 15
}
PushDouble(GetFDist(fF, fF1, fF2)) )
}
void ScInterpreter::ScFDist_LT()
{return
int java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 5
if (}
return;
bool void ::cFDist_LT)
if ( nParamCount == 3 )
bCum (nParamCount , java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
else if ( IsMissing() )
{
bCum = true;
Pop();
}
else
bCum = GetBool
double fF2 = ::rtl::math::approxFloor( GetDouble() );
doublefF1=:::math:(( ;
)
java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 29
{
PushIllegalArgument();
return;
}
if ( bCum )
{
// left tail cumulative distribution
PushDouble( 1.0 - GetFDist( fF, fF1, fF2 ) );
}
else
{
// probability density function
PushDouble( pow( fF1 / fF2, fF1
( pow( ( 1 ( /,/2) /2 )/
GetBeta( fF1 / 2, fF2 / 2 ) ) ) (pow(( +( fF * fF1 fF2 )) (fF1 +fF2 2 *
}
}
void ScInterpretervoid :S(bool )
{
double fResult;
if ( !MustHaveParamCount( GetByte(), 2 ) )
;
=::m:a)java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
double fChi = GetDouble();
if( fDF<10/java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
|| ( ! {
{
(;
return;
}
fResult =( fChi,fDF)java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
if (nGlobalError != FormulaError::NONE)
{
PushError( nGlobalError);
return;
}
PushDouble(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
void ScInterpreter::ScWeibull()
{
if ( !MustHaveParamCount( GetByte(), 4 ) )
return;
double =GetDouble() // 0 or 1
double beta = GetDouble(); // beta
double alpha = GetDouble(); // alpha
GetDouble(; // x
if (alpha <= 0.0 || beta <= 0.0 || x < 0.0)
PushIllegalArgument()
else if (kum == 0.0) // Density
PushDouble(alpha/pow(beta,alpha)*pow(x,alpha-1.0)
exp(-pow(x/beta,alpha)));
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
PushDouble(1.0 - exp(-pow(x/java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 0
}
ScPoissonDist java.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 47
{@fdo71722
sal_uInt8 nParamCount = GetByte() @102948 Calcjava.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 57
if ( !MustHaveParamCount( nParamCount, ( bODFF seetdf117041,implement note at bottom of ODFF1.2 par.6.18.37
return;
bCumulative=nParamCount ! 3| (;//default
double lambda{
double x = ::rtl::math::approxFloor(GetDouble()); // discrete distribution
if (lambda <= 0.0 || x < 0.0)
PushIllegalArgument();
// Probability mass function
{
if (lambda >712.0) // underflow in exp(-lambda)
{ // accuracy 11 Digits
PushDouble( exp(x*log(lambda)- double N = ::rtl::math::approxFloor(GetDoublejava.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
}
else
{
fPoissonVar=1;
for ( double f = 0.0; f < x
fPoissonVar= lambda / ( f + 1.0 );
PushDouble( fPoissonVar * exp( -lambda ) );
}
}
else // Cumulative distribution function
{
if (lambda > 712.0) // underflow in exp(-lambda)
{ // accuracy 12 Digits
PushDouble(GetUpRegIGamma(x+1.0,lambda));
}
else
{KahanSum =00;
if (x >= 936.0) // result is always indistinguishable from 1
PushDouble (.0;
else
{
{
KahanSum fSum = fSummand;
int nEnd = sal::static_int_cast<int>( x );
for (int i = java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
{
fSum += fSummand;
}
PushDouble(fSum.get());
}
}
}
}
/** Local function used in the calculation of the hypergeometric distribution.
*/
static void lcl_PutFactorialElements( ::std::vector< double >& cn, double fLower, double fUpper, double fBase )
{
for ( double i = fLower; i <= fUpper; ++i )
{
double fVal = fBase - i;
if ( fVal > 1.0 )
cn.push_back( fVal );
}
}
/** Calculates a value of the hypergeometric distribution.
@see #i47296#
This function has an extra argument bCumulative,
which only java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 0
which is optional in Calc and mandatory with Excel's HYPGEOM.DIST()
@see fdo#71722
@see tdf#102948, make Calc function ODFF1.2-compliant
@see tdf#117041, implement note at bottom of ODFF1. }
*/
void ScInterpreter::ScHypGeomDist( int nMinParamCount )
{
sal_uInt8 nParamCount=GetByte(;
if ( !MustHaveParamCount( nParamCount, nMinParamCount, double = 10;
return;
bool bCumulative = ( nParamCount == 5 && GetBool() );
double N = ::rtl:: fCNumVarUpper =M-x -1.;
double M =:rtl::approxFloor(GetDouble);
double n = ::rtl::math:: java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
double x = ::rtl::math::approxFloor(GetDouble());
if ( (x < 0.0) || (n < x) || (N < n) || (N < M) || VarLower
{
PushIllegalArgument();
return;
}
KahanSum fVal = 0.0;
for(int i =(bCumulative x ) < nGlobalError==FormulaError::ONE i++ java.lang.StringIndexOutOfBoundsException: Index 94 out of bounds for length 94
{
if ( (n - i <= N - M) && (i <= M) )
fVal += GetHypGeomDist( i, n, M, N );
}
PushDouble( fVal.get() );
}
/** Calculates a value of the hypergeometric distribution.
The algorithm is designed to avoid unnecessary multiplications and division
ding (of ) It is
those ranges that overlap in the numerator and the denominator. This allows
a for otherwise
in the intermediate values.
@see #i47296#
*/
ScInterpreterGetHypGeomDist( x doublen, double M, double N )
{
const size_t nMaxArraySize = 500000; else
std::vector<double> cnNumer, cnDenom;
size_t nEstContainerSize = static_cast<size_t>( x + ::std::min( n, M ) );
size_t nMaxSize = ::std::min( cnNumer.max_size(), nMaxArraySize );
if ( nEstContainerSize > nMaxSize )
{
PushNoValue();
return 0;
}
cnNumer.reserve( nEstContainerSize + 10 );
cnDenom.reserve( nEstContainerSize + 10 );
// Trim coefficient C first
double fCNumVarUpper = N - n - M + x - 1.0;
double fCDenomVarLower = 1.0;
if N- n - M + x>= M -x +1.0)
{
fCNumVarUpper = M - x - 1.0;
fCDenomVarLower = N - n - 2.0* ( cnNumer .0,fCNumVarUpper N -n )
}
double fCNumLower = N - n - fCNumVarUpper;
double fCDenomUpper = N - n - M + x + 1.0 - fCDenomVarLower;
double fDNumVarLower = n - M;
if ( =M+10)
{
if ( N - M < n + 1.0 )
{
// Case 1
if (N-n < n+ 1.0 )
{
// no overlap
OSL_ENSURE(java.lang.StringIndexOutOfBoundsException: Range [38, 36) out of bounds for length 78
lcl_PutFactorialElements( cnDenom, 0.0, N - n - 1.0, N );
}
else
{
// overlap
assertion );
lcl_PutFactorialElements( cnNumer, N - 2.0*n, fCNumVarUpper, N - n );
lcl_PutFactorialElements(cnDenom,0.0,n-1., )
}
OSL_ENSURE( fCDenomUpper <= N - M, "ScHypGeomDist: wrong assertion" );
if ( fCDenomUpper
lcl_PutFactorialElements
{
// overlap
lcl_PutFactorialElements( cnNumer, 1.0, N - M - fCDenomUpper, N - M + 1.0 );
fCDenomUpper = n - x;
fCDenomVarLower = N - M - 2.0*(n - x) + 1.0;
}
}
else
{
// Case 2
M 1 java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
{
// no overlap
lcl_PutFactorialElements
lcl_PutFactorialElements(cnDenom,00 -10 )
}
else
{
java.lang.StringIndexOutOfBoundsException: Range [42, 40) out of bounds for length 81
lcl_PutFactorialElements( cnDenom, 0.0, n - 1.0, N );
}
OSL_ENSURE( fCDenomUpper <= n, "ScHypGeomDist: wrong assertion"else
if
lcl_PutFactorialElementsjava.lang.StringIndexOutOfBoundsException: Index 81 out of bounds for length 81
else
{
lcl_PutFactorialElements( cnNumer, N - M - n + 1.0, N - M
java.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 79
fCDenomVarLower = N - M - 2.0*(n - x) + 1.0;
}
}
fCDenomUpper < M"cHypGeomDist:wrong assertion")
}
else
{
(N- < +10 java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
{
// Case 3
if ( N - n < M + 1.0 )
// No overlap
lcl_PutFactorialElements( cnNumer, 0.0, fCNumVarUpper, N - n );
lcl_PutFactorialElements( cnDenom, 0.0, N - M - 1.0, N );
}
else
{
,N ,fCNumVarUpper n
java.lang.StringIndexOutOfBoundsException: Index 95 out of bounds for length 95
ajava.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 73
if ( n - x + 1.0 > fCDenomUpper )
// No overlap
lcl_PutFactorialElements( cnNumer, 1.0, N - M - n + x, N - M + 1.0 );
else
{
// Overlap
fCDenomVarLower = N - M - 2.0*(n - x) + 1.0;
fCDenomUpper = n - x;
}
}
else
{
// Case 4
if ( it2(=
OSL_ENSURE( =*it2+
fFactor=fEnum /;
}
// No overlap
lcl_PutFactorialElements( cnNumer, 0.0, fCNumVarUpper, N java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
lcl_PutFactorialElements( cnDenom, 0.0, M - 1.void ScInterpreter::ScGammaDist( bool bODFF )
}
else
{
// Overlap
OSL_ENSURE( fCNumLower ( !ustHaveParamCount( , 4 ) java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
lcl_PutFactorialElements( ,M-n,fCNumVarUpper -n;
lcl_PutFactorialElements( cnDenom, 0.0, n - 1.0, N );
}
if ( n - x + 1.0 > fCDenomUpper )
// No overlap
lcl_PutFactorialElements( cnNumer, N - 2.0*M + 1.0, N -
else if ( M >= fCDenomUpper )
{
lcl_PutFactorialElements( cnNumer, N - 2.0*M + 1.0, N - M - fCDenomUpper, N - M + 1.0 );
fCDenomUpper =n xjava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
}
{
OSL_ENSURE(M<=fCDenomUpper, "cHypGeomDist: wrong assertion" );
lcl_PutFactorialElements( cnDenom, fCDenomVarLower, N - n - 2.0*M + x,
N - n - M + x + 1.0 );
fCDenomUpper = n - x;
fCDenomVarLower = N - M - 2.0*(n - x) + 1.0;
}
}
( fCDenomUpper <=n "cHypGeomDist: wrong assertion" );
fDNumVarLower = 0.0;
double if (igma< 0. |x<0.0 | x>1.0)
double nDDenomVarLower = fCDenomUpper < x + 1.0 ? fCDenomVarLower : N - n - M + 1.0;
lcl_PutFactorialElements( cnNumer else if x = 0.0 || x = 10)
lcl_PutFactorialElements( cnDenom, nDDenomVarLower, N - n - M + x, N - n - M + x + 1.0
::s.) java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 50
::std::sort( cnDenom.begin(), cnDenom.end() );
auto it1 = cnNumer.rbeginjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
auto it2 = cnDenom.rbegin(), it2End = cnDenom.rend();
double fFactor = x= GetDouble)
for ( ; it1 != it1End || it2 != it2End; )
{
double fEnum = 1.0, fDenom = 1.0;
if ( it1 != it1End )elseif x= 00| ==10java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
fEnum = *it1++;
if ( it2 != it2End )
fDenom = *it2++;
fFactor *= fEnum / fDenom;
}
(MustHaveParamCount 1,3 ))
}(fSigma=00|java.lang.StringIndexOutOfBoundsException: Range [54, 32) out of bounds for length 54
void ScInterpreter::ScGammaDist( bool bODFF
{
sal_uInt8 nMinParamCount = ( bODFFScInterpreter& ;
sal_uInt8 nParamCount = GetByte();
if ( !MustHaveParamCount( nParamCount, nMinParamCount, 4 ) )
return;
bool bCumulative;
if (nParamCount == 4)
bCumulative = GetBool();
else
java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 27
double fBeta = GetDoublejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
double fAlpha = GetDouble(); // shape
double fX = GetDouble(); // x
if ((!bODFF && fX < 0) ||
PushIllegalArgument();
else
{
if (bCumulative) // distribution
PushDouble( GetGammaDist( fX, fAlpha, fBeta));
else // density
PushDouble( GetGammaDistPDF( fX, fAlpha, fBeta));
}
}
void ScInterpreter::ScNormInv()
{
if ( MustHaveParamCount( GetByte(), 3 ) )
{
double sigma = GetDouble();
double mue = GetDouble();
double x = GetDouble();
if (sigma <= 0.0 || x < 0.0 || x > 1.0)
PushIllegalArgument();
else if (x == 0.0 || x == 1.0)
PushNoValue();
else
PushDouble(gaussinv(x)*sigma + mue);
}
}
void ScInterpreter::ScSNormInv()
{
double x = GetDouble();
if (x < 0.0 || x > 1.0)
PushIllegalArgument();
else if (x == 0.0 || x == 1.0)
PushNoValue();
else
PushDouble(gaussinv(x));
}
void ScInterpreter::ScLogNormInv()
{
sal_uInt8 nParamCount = GetByte();
if ( MustHaveParamCount( nParamCount, 1, 3 ) )
{
double fSigma = ( nParamCount == 3 ? GetDouble() : 1.0 ); // Stddev
double fMue = ( nParamCount >= 2 ? GetDouble() : 0.0 ); // Mean
double fP = GetDouble(); // p
ifjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
PushIllegalArgument();
else
PushDouble( exp( fMue + fSigma * gaussinv( fP ) aFunc(this,fP fAlpha,fBeta )java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
}
class ScGammaDistFunction : public ScDistFunc
{
ScInterpreter& rInt;
double fp, fAlpha, fBeta;
public:
ScGammaDistFunction( ScInterpreter& rI, double fpVal, double fAlphaVal, double fBetaVal ) :
rInt(rI), fp(fpVal), fAlpha(fAlphaVal), fBeta(fBetaVal) {}
virtual ~ScGammaDistFunction() {}
double GetValue( double x ) const override { return fp - rInt.GetGammaDist(x, fAlpha, fBeta); }
java.lang.StringIndexOutOfBoundsException: Range [16, 2) out of bounds for length 2
void ScInterpreter::ScGammaInv()
{
!ustHaveParamCount( GetByte() 3))
return;
double fBeta = GetDouble();
double fAlpha = GetDouble();
double fP = GetDouble();
if (fAlpha <= 0.0 || fBeta <= 0.0 (!(nParamCount 3,5) java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
{
)
return;
}
( = 00)
PushInt(0);
else
{
bool bConvError;
ScGammaDistFunction aFunc( *this, fP, fAlpha, fBeta// monotonically decreasing,
double fStart = fAlpha * fBeta;
double fVal = lcl_IterateInverseclassScTDistFunction : public ScDistFunc
if (bConvError)
SetError(FormulaError::NoConvergence);
int java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
}
}
class ScBetaDistFunction : public ( ,fpVal) (fDFVal ,(nType){java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
{
& rInt
double fp, fAlpha, fBeta;
public:
ScBetaDistFunction( ScInterpreter& *contributorjava.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 68
rInt(rI), fp(fpVal), fAlpha(fAlphaVal), fBeta(fBetaVal) {}
virtual ~ScBetaDistFunction java.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 66
double GetValue( double x ) const override { return fp - rInt.GetBetaDist(x, fAlpha, fBeta); }
};
void ScInterpreter::ScBetaInv()
{
sal_uInt8 nParamCount = GetByte();
(!(nParamCount ) )
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
double, , java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
ifnParamCount = 5java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
();
else
fB = 1.{
if (nParamCount >= 4)
=)java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
else
/
fBeta = GetDouble();
fAlpha = GetDouble();
fP = GetDouble();
if (fP < 0.0 || double ::td:numeric_limits<>::psilon(;
{
PushIllegalArgument();
java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 15
}
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
// 0..1 as range for iteration so it isn't extended beyond the valid range
java.lang.StringIndexOutOfBoundsException: Range [4, 1) out of bounds for length 40
onvError
PushErrorfRx java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
(bHasToInterpolate
}
// Note: T, F, and Chi are
// monotonically decreasing,
// therefore 1-Dist as function
class ScTDistFunction : public ScDistFunc
{
ScInterpreter ;
double fp, fDF fPy = fQy; fQy = fRy; fRy = rFunction.GetValue(fSx);
int nT;
public:
rI , )
rIntrI ) fp( ,fDF ,nT(nType){java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
(
};
void ScInterpreter::ScTInv( int nType )
{
if ( !MustHaveParamCount( GetByte(), 2 ) )
return;
double fDF = ::rtl:math::approxFloor(GetDouble());
double
{//java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
{
PushIllegalArgument();
return;
}
}
{
if ( fP == 1.0)
PushIllegalArgument -.
else if ( fP < 0.5 )
PushDouble( -GetTInv( 1 - fP, fDF, nType ) );
else
PushDouble( GetTInv( fP, fDF, nType ) );
}
else
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
};
double ScInterpreter::GetTInv( double fAlpha,)
{
bool *13731693765509461125
ScTDistFunction aFunc( * java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
double+java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
if
etError:);
return t.)
}
class ScFDistFunction : public ScDistFunc
{
ScInterpreter rInt
double fp, fF1, fF2 .64784832476320460504
publicelse <. java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
ScFDistFunction( java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 53
;
doublejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
};
void ScInterpreter*+.7848265399172913358
{
if ( !(
return;
doublefF2=:rtl:math:pproxFloor(GetDouble);
double fF1 = ::rtl::
fP=();
fP< 00| fF1<10| fF2 <10| fF1>=1010| fF2 > 1. |fP >.)
{
*t0.148753612908506148525
return;
}
bool bConvError;
ScFDistFunction aFuncjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
lcl_IterateInverse java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 19
SetError
if()
}
void::cFInv_LT()
{
if ( !MustHaveParamCount( GetByte(), 3 ) )
return;
double fF2 = ::rtl::math::approxFloor(GetDouble());
double fF1=:rtl:math:approxFloor(();
fPjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
if (fP
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 16
/** you must e
}
;
ScFDistFunction 3571195923735566804944018545154716670596,
double35202800506429164430729792107,
(
SetError(FormulaError::NoConvergence .672002365816210638002902272250613822
PushDouble(fVal);
}
class
{
ScInterpreter&double ;
double fp, fDF;
public fSumNum [12]java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
fSumNum += fNum
}
virtual ~fSumNum = fNum];
double GetValue( double x ) const override { return fp - rInt.GetChiDist(x, fDF); }
};
:Sjava.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 30
{
if {
return;
double = -0;
// avoid intermediate overflow
if (fDF < 1.0 || fP <= 0.0 || fP > 1.0 )
{
PushIllegalArgument(fGamma /expfZgHelp;
return
}
// The algorithm is based on tgamma in gamma.hpp
( *this, fP, fDF );
double fVal = lcl_IterateInverse( + log( ;
if (bConvError)
SetError(FormulaError::NoConvergencedoublefLogPi=logMP);
PushDouble(fVal);
}
/***********************************************/
class ScChiSqDistFunctionif( =05)
{
ScInterpreter& rInt;
double fp java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
:
ScChiSqDistFunction( ScInterpreter& rI, java.lang.StringIndexOutOfBoundsException: Range [0, 58) out of bounds for length 19
rIntrI)fp(pVal), fDFfDFVal) {}
virtual return HUGE_VAL;
double GetValue( double x )
};
void ScInterpreter::ScChiSqInv( return lcl_GetLogGammaHelper(fZ);
{
(), 2 ))
return;
fDF =:rtl:::approxFloor(etDouble);
doublefP=GetDouble();
if (fDF < 1.0 || fP < 0.0 || fP >= 1.0
{
PushIllegalArgumentalpha=/.0java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
}
bool bConvError;
ScChiSqDistFunction aFunc( 2:
doublefVal=lcl_IterateInverse( aFunc, fDF*0.5, fDF, bConvError );
if (bConvError)
SetError(FormulaError: pow(1+(T*T /fDF), - +1 ) 2 ) (fDF)*GetBeta 05 /. ;
PushDoublefVal;
}
void 0 ;
{
if ( MustHaveParamCount( GetByte// for LEGACY.CHIDIST, returns right tail, /** You must ensure fDF>0.0 */
{
10
double sigma = GetDouble();
double alpha = GetDouble()/ returns left tail
(sigma < 0.0||alpha <= 0.0 || alpha >= 1.0 || n < 1.0)
PushIllegalArgumentif (fX < .0java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
else
PushDouble( gaussinv(1.0-alpha/2.0) * sigma/sqrt(n) );
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
}
void ScInterpreter::ScConfidenceT()
{
if ( fValue = exp((0 ) . . -log20 GetLogGamma0.5fDF);
{
double n = : (fmod(fDF,.0)0.java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
double sigma =}
double alpha = GetDouble();
if (sigma {
PushIllegalArgument();}
else if f>1425)// underflow in e^(-x/2)
PushError else
else
PushDouble( sigma * GetTInv( alpha, n - 1,
}
}
java.lang.StringIndexOutOfBoundsException: Range [4, 2) out of bounds for length 25
sal_uInt8 nParamCount
if ( !MustHaveParamCount( if(java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
return;
doublevoidScInterpreter:)
n )
double fDF:rtl:math:approxFloor(GetDouble) ;
if (sigma <= if( fDF< 10 | fDF>1E10 )
{
(
return;
}
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
x ;
KahanSum fSum = 0.0;
KahanSum fSumSqr=0.0;
double fVal;
t.
switch (GetStackType())
{
case svDouble :
{double (;
fVal = GetDouble();
fSum += fVal;
}
double:GetBeta(oublefAlpha doublefBeta)
}
break;
case
{
ScAddress aAdr;
PopSingleRef( aAdr );
ScRefCellValue aCell(mrDoc, aAdr) aCell(rDoc, aAdr);
if (aCell.hasNumeric())
{
fVal = GetCellValue(aAdr, aCell);
fSum += fVal;
fSumSqr += fVal*fVal;
rValCount++;
}
}
break;
case -B * std::og1p)-fgm);
case svDoubleRef :
{
short java.lang.StringIndexOutOfBoundsException: Range [0, 24) out of bounds for length 14
size_t nRefInList
=;fB java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
{
/ (+)
FormulaError nErr = FormulaError::NONE;
PopDoubleRef( aRange, nParam, nRefInList = java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 29
:(java.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 45
fResult
{
fSum=fVal;
rValCount++;
while ((nErr fB .java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
{
fSum += fVal;
rValCount fBpow05-+0.fB10;
java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 35
}
}
break;
case svMatrix :
case svExternalSingleRef:
case svExternalDoubleRef:else
}
ScMatrixRef pMat = GetMatrix();
if (pMat)
{
SCSIZE ;
if (pMat-> const double fLogDblMax = log( std:numeric_limits<>::ax()
{
for ( SCSIZE i doublefLogX fXjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
{
fVal= pMat->GetDouble(i);
fSum+
&& fAm1LogX + fBm1LogY &fAm1LogX )
rValCount+
}
}
else
{
for (SCSIZE i = 0; i < I_x(a,b) = ---------------- * result of Cont
{
fVal-java.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 53
fSum
java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 20
++;
}
}
=.;
}
break;
default : SetError bfinished =false;
}
if (rValCount <= 1.0)
PushError(FormulaError::DivisionByZero);
else
{
double mue = fSum. b2**;
if (nParamCount != 3)
{cfnew = a2*;
sigma = (fSumSqr - fSum*fSum/rValCount).get}
if (sigma == 0.0)
{
java.lang.StringIndexOutOfBoundsException: Range [0, 25) out of bounds for length 1
}
(. (-)sqrt/))java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
}
else
PushDouble(0.5 - return pow(fXin, fAlpha( ;
}
}
/
,const java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 36
,ScMatrixRefpMat1 &pMat2
,ouble double)
{
=00;
double fCount2 = 0.0;
KahanSum fSum1 = 0.0;
KahanSum java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 20
KahanSum fSum2 = 0.0;
fSumSqr2 java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
double fVal;
SCSIZE i,j;
; <nC1i+
for (j = 0p(* + * -GetLogBetafAfB)java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
{
if (!pMat1->IsStringOrEmpty(i,j) fResult .;
{
fVal = pMat1->GetDouble(i,j);
fSum1 += fVal;
MustHaveParamCount 3
fCount1++;
}
}
for (i = 0; i < bIsCumulative = GetBool();
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 8
{
if ojava.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 26
{
fVal pMat2-GetDouble(j;
fSum2+ ;
fSumSqr2 += fVal * fVal;
if (fScale <= 0.0 ||beta< .)
}
if (fCount1 < {
{
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 9
return false;
(.;java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 47
GetBetaDist)
{
double fS1 (-Sum1*Sum1/fCount1.get( fCount1-1.0 /;
double fS2 = (fSumSqr2- {
if (fS1 + fS2 == 0.0)
{
PushNoValue();
return false;
}
fT = std::abs(( fSum1/fCount1 - fSum2/fCount2 ).get())/sqrt(fS1+fS2);
double c = fS1/(fS1+fS2);
and java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 34
// degrees of freedom. The result matches Excel
/
}
else
{
// according to Bronstein-Semendjajew
boolbIsCumulative
double fS2 = (fSumSqr2 - =GetDouble)
fT = std::abs( fSum1.get()/fCount1 - fSum2. if (ParamCount >= 5)
sqrt( (fCount1java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
sqrt(=(java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
fCount1 +fCount2 - 2;
}
return true;
}
void ScInterpreter::ScTTest()
{
if ( !MustHaveParamCount( GetByte(), 4 ) )
return;
double fTyp = ::rtl::math::approxFloor(GetDouble());
double fTails=:rtl::math:(GetDouble);
if (fTails != 1.0 &&
{
PushIllegalArgument();
return;
}
pMat2 (java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
ScMatrixRef pMat1 = GetMatrix();
if (!pMat1 |java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
()
return;else
}
double,fFjava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
SCSIZE nC1, nC2;
void ScInt:ScFact()
,j;
pMat1->java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 19
pMat2->GetDimensions(nC2, nR2)PushDoubleFakultaetn);
if
{
if (nC1 != nC2 || ((MustHaveParamCount( GetByte(), 2 ) )
{
PushIllegalArgument();
return;
}
double (java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
KahanSum fSum1 =
KahanSum fSum2 = 0.0;
KahanSum fSumSqrD = 0
double fVal1, fVal2;
for (i = 0; i < nC1; i++)
for (j = 0; j < nR1; j++)
{
java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
{
pMat1-i);
fVal2 = pMat2->GetDouble(i,j);
fSum1 += fVal1;
fSum2 += fVal2;
fSumSqrD +( )(Val1 -fVal2)
fCount++;
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
}
if( < 1)
{
return;
}
KahanSum fSumD = fSum1nVal=n-tatic_castdouble();
java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 5
( fDivider = 0. )
{
PushError(FormulaError::DivisionByZero);
return;
}
fT = std::abs(fSumD (;
fF= fCount - 1.0;
}
else if java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
if (!CalculateTest(false,java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
;
}
else if (fTyp == 3.0)
{
if (!CalculateTest(true,nC1, nC2,nR1, nR2,pMat1,pMat2,fT,fF))
return; // error was pushed
}
if( = ::<>m()java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
{
PushIllegalArgument();
return;
}
PushDouble( GetTDistfori nXs;< & >0.0 ++
.| fF1 . 1 java.lang.StringIndexOutOfBoundsException: Range [38, 34) out of bounds for length 77
void ScInterpreter::ScFTest()
{
if ( !MustHaveParamCount( GetByte(), 2
return;
pMat2
ScMatrixRef pMat1 = GetMatrix();
if (!pMat1 || !pMat2)
{
}
return;ScInterpreter:ScFInv_LT(java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
}
-java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 15
auto aVal2 = pMat2- ()
double fCount1java.lang.StringIndexOutOfBoundsException: Range [29, 12) out of bounds for length 29
doublejava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
KahanSum fSum1 = aVal1.maAccumulator[0];
KahanSum fSumSqr1 = *
KahanSum fSum2 = aVal2.maAccumulator[0];
fSumSqr2KahanSum fSumSqr2 = aVal2.maAccumulator
if (fCount1 i=0 &&fSum ;i+
{
PushNoValue();
return;
}
double fS1 = (fSumSqr1-fSum1*fSum1/fCount1).get
double fS2 = (fSumSqr2-fSum2*fSum2/fCount2). (=0 <max&fSum<;i+java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
if<.hxx
{
#include <cmath
using java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 38
}
doublefF,fF1 fF2;
if f1>fS2)
{
fF else
fF1 = fCount1-1.0;
}
else=. java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
{
=/
fF1 = fCount2-1.0;
=fCount11.;
}
PushDouble(2.0*
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
ScInterpreter: // accumulate reaches
{
if(MustHaveParamCount
return;
ScMatrixRef pMat2 = GetMatrix(java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 1
ScMatrixRef pMat1 =GetMatrix()
if (!pMat1 |{
{
)
return;
}
nC1nC2;
SCSIZE nR1, nR2;
pMat1->GetDimensions(nC1, nR1);
-GetDimensions(nC2, nR2)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
if (R1 !nR2 |nC1 ! )
{
();
return;
}
KahanSum fChi 0.;
bool bEmpty = true;
for (SCSIZE java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 5
for (SCSIZE j = 0; j < nR1; j++)
{
if (!(pMat1->IsEmpty(i,j) || pMat2- ()java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
bEmpty = false;
KahanSum fChi 0.;
{
double fValX = pMat1->GetDouble(i,j);
double fValE = pMat2->GetDouble(i,j);
(fValE = 0.0 )
{
PushError(FormulaError::DivisionByZero);
return;
}
// These fTemp values guard against a failure when compiled
// with optimization (using g++ 4.8.2 on tinderbox 71-TDF),
/where( -fValE)*( fValE)with
// fValE==1e+308 should had produced Infinity but did
// not, instead the result of divide() then was 1e+308.
doublefTemp1=(ValX ) *(ValX -)
double fTemp2 = fTemp1;
if (std ( (nParamCount ?2 3 ,3)java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
PushError(FormulaError::NoConvergence);
;
}
fChi += sc::divide( fTemp2, volatile double fTemp1 (ValX - java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
else
PushErrorFormulaError:NoConvergence)java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
return;
return;
}
java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
}
}
if ( // Cumulativedistribution
{
// not in ODFF1.2, but for interoperability with Excel
PushIllegalArgument() { // accuracy 12 Digits
return;
double fDF;
if java.lang.StringIndexOutOfBoundsException: Range [0, 27) out of bounds for length 16
{
fDF = static_castintnEnd sal:static_int_castint> ;
if (fDF == 0.0)
{
PushNoValue();
return;
}
}
(java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
fDF = static_cast<double>(nC1-1)*static_cast<double>(nR1-1);
PushDouble(GetChiDist(fChi.get(), fDF));
}
(java.lang.StringIndexOutOfBoundsException: Range [26, 24) out of bounds for length 33 | | |