sc/source/core/inc/interpre.hxx | 4 +- sc/source/ui/optdlg/calcoptionsdlg.cxx | 64 +++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 2 deletions(-)
New commits: commit eaddf7dfb51df779922f24e31240a8a2a7708fe2 Author: Tor Lillqvist <[email protected]> Date: Wed Jan 28 18:46:37 2015 +0200 Add NORMDIST test Change-Id: I9c3d5b94d22566d63f49d9dcd73a97df97e9802e diff --git a/sc/source/ui/optdlg/calcoptionsdlg.cxx b/sc/source/ui/optdlg/calcoptionsdlg.cxx index 6483562..a460f54 100644 --- a/sc/source/ui/optdlg/calcoptionsdlg.cxx +++ b/sc/source/ui/optdlg/calcoptionsdlg.cxx @@ -506,6 +506,68 @@ struct Round : Area }; +struct Normdist : Area +{ + Normdist() : + Area("Normdist") + { + } + + virtual ~Normdist() + { + } + + virtual void addHeader(ScDocument *pDoc, int nTab) const SAL_OVERRIDE + { + pDoc->SetString(ScAddress(0,0,nTab), "num"); + pDoc->SetString(ScAddress(1,0,nTab), "avg"); + pDoc->SetString(ScAddress(2,0,nTab), "stdev"); + pDoc->SetString(ScAddress(3,0,nTab), "type"); + pDoc->SetString(ScAddress(4,0,nTab), "NORMDIST(num,avg,stdev,type)"); + pDoc->SetString(ScAddress(5,0,nTab), "expected"); + } + + virtual void addRow(ScDocument *pDoc, int nRow, int nTab) const SAL_OVERRIDE + { + const double nNum(comphelper::rng::uniform_real_distribution(0, 100)); + const double nAvg(comphelper::rng::uniform_real_distribution(0, 100)); + const double nStDev(comphelper::rng::uniform_real_distribution(1, 10)); + const int nType(comphelper::rng::uniform_int_distribution(0, 1)); + + pDoc->SetValue(ScAddress(0,1+nRow,nTab), nNum); + pDoc->SetValue(ScAddress(1,1+nRow,nTab), nAvg); + pDoc->SetValue(ScAddress(2,1+nRow,nTab), nStDev); + pDoc->SetValue(ScAddress(3,1+nRow,nTab), nType); + + pDoc->SetString(ScAddress(4,1+nRow,nTab), + "=NORMDIST(" + ScAddress(0,1+nRow,nTab).Format(SCA_VALID_COL|SCA_VALID_ROW) + + "," + ScAddress(1,1+nRow,nTab).Format(SCA_VALID_COL|SCA_VALID_ROW) + + "," + ScAddress(2,1+nRow,nTab).Format(SCA_VALID_COL|SCA_VALID_ROW) + + "," + ScAddress(3,1+nRow,nTab).Format(SCA_VALID_COL|SCA_VALID_ROW) + + ")"); + + if (nType == 1) + pDoc->SetValue(ScAddress(5,1+nRow,nTab), ScInterpreter::integralPhi((nNum-nAvg)/nStDev)); + else + pDoc->SetValue(ScAddress(5,1+nRow,nTab), ScInterpreter::phi((nNum-nAvg)/nStDev)/nStDev); + + pDoc->SetString(ScAddress(6,1+nRow,nTab), + "=IF(ABS(" + ScAddress(4,1+nRow,nTab).Format(SCA_VALID_COL|SCA_VALID_ROW) + + "-" + ScAddress(5,1+nRow,nTab).Format(SCA_VALID_COL|SCA_VALID_ROW) + + ")<=3e-10" + ",0,1)"); + } + + virtual OUString getSummaryFormula(ScDocument *pDoc, int nTab) const SAL_OVERRIDE + { + return "=SUM(" + + ScRange(ScAddress(6,1,nTab), + ScAddress(6,1+mnRows-1,nTab)).Format(SCA_VALID|SCA_TAB_3D|SCA_VALID_COL|SCA_VALID_ROW|SCA_VALID_TAB, pDoc) + + ")"; + } + +}; + struct Reduction : Op { int mnNum; @@ -682,6 +744,8 @@ IMPL_LINK( ScCalcOptionsDialog, TestClickHdl, PushButton*, ) xTestDocument->addTest(Round()); + xTestDocument->addTest(Normdist()); + xTestDocument->addTest(Reduction("Sum", "SUM", 100, 0, -1000, 1000, 3e-10, [] (double nAccum, double nArg) { commit 36941076bc245373423dec1a2422269e8492e548 Author: Tor Lillqvist <[email protected]> Date: Wed Jan 28 18:44:37 2015 +0200 Make phi() and integralPhi() static and public Needed for the NORMDIST() OpenCL implementation test doc. Change-Id: I40f0d5d7ccf5963fa47d6648873ab23f8adf7aea diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx index ff7fb11..094292a 100644 --- a/sc/source/core/inc/interpre.hxx +++ b/sc/source/core/inc/interpre.hxx @@ -737,12 +737,12 @@ void ScForecast(); void ScNoName(); void ScBadName(); // Statistics: -double phi(double x); -double integralPhi(double x); double taylor(const double* pPolynom, sal_uInt16 nMax, double x); double gauss(double x); public: +static SC_DLLPUBLIC double phi(double x); +static SC_DLLPUBLIC double integralPhi(double x); static SC_DLLPUBLIC double gaussinv(double x); private: _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
