summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWinfried Donkers <osc@dci-electronics.nl>2013-02-06 19:09:00 +0100
committerEike Rathke <erack@redhat.com>2013-02-08 09:50:20 +0000
commitdf931a5b0f48707e34ebfacb695996198ece8f44 (patch)
tree517fc845a0fcd123c7837e1ea7563ebdd871733e
parent35cda416ce9c23abc9075ef22068d098017efd55 (diff)
fdo#60322 add calc function SKEWP as in ODFF v1.2
Change-Id: I4851df1473fc7788af1ac642bb0fb527ec872821 Reviewed-on: https://gerrit.libreoffice.org/2020 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
-rw-r--r--formula/inc/formula/compiler.hrc5
-rw-r--r--formula/inc/formula/opcode.hxx1
-rw-r--r--formula/source/core/resource/core_resource.src6
-rw-r--r--sc/inc/helpids.h1
-rw-r--r--sc/qa/unit/ucalc.cxx1
-rw-r--r--sc/source/core/inc/interpre.hxx1
-rw-r--r--sc/source/core/tool/interpr3.cxx33
-rw-r--r--sc/source/core/tool/interpr4.cxx1
-rw-r--r--sc/source/core/tool/parclass.cxx1
-rw-r--r--sc/source/filter/excel/xlformula.cxx2
-rw-r--r--sc/source/filter/oox/formulabase.cxx2
-rw-r--r--sc/source/ui/src/scfuncs.src24
12 files changed, 74 insertions, 4 deletions
diff --git a/formula/inc/formula/compiler.hrc b/formula/inc/formula/compiler.hrc
index 7f976ae3a163..da27a19b6cd8 100644
--- a/formula/inc/formula/compiler.hrc
+++ b/formula/inc/formula/compiler.hrc
@@ -398,8 +398,9 @@
#define SC_OPCODE_SUM_IFS 403
#define SC_OPCODE_AVERAGE_IFS 404
#define SC_OPCODE_COUNT_IFS 405
-#define SC_OPCODE_STOP_2_PAR 406
-#define SC_OPCODE_LAST_OPCODE_ID 405 /* last OpCode */
+#define SC_OPCODE_SKEWP 406
+#define SC_OPCODE_STOP_2_PAR 407
+#define SC_OPCODE_LAST_OPCODE_ID 406 /* last OpCode */
/*** Internal ***/
#define SC_OPCODE_INTERNAL_BEGIN 9999
diff --git a/formula/inc/formula/opcode.hxx b/formula/inc/formula/opcode.hxx
index 007bcd92adf0..b94c066a624b 100644
--- a/formula/inc/formula/opcode.hxx
+++ b/formula/inc/formula/opcode.hxx
@@ -328,6 +328,7 @@ enum OpCodeEnum
ocStandard = SC_OPCODE_STANDARD,
ocAveDev = SC_OPCODE_AVE_DEV,
ocSchiefe = SC_OPCODE_SCHIEFE,
+ ocSkewp = SC_OPCODE_SKEWP,
ocDevSq = SC_OPCODE_DEV_SQ,
ocMedian = SC_OPCODE_MEDIAN,
ocModalValue = SC_OPCODE_MODAL_VALUE,
diff --git a/formula/source/core/resource/core_resource.src b/formula/source/core/resource/core_resource.src
index f02f8068923e..de8e8d4c251f 100644
--- a/formula/source/core/resource/core_resource.src
+++ b/formula/source/core/resource/core_resource.src
@@ -284,6 +284,7 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH_ODFF
String SC_OPCODE_STANDARD { Text = "STANDARDIZE" ; };
String SC_OPCODE_AVE_DEV { Text = "AVEDEV" ; };
String SC_OPCODE_SCHIEFE { Text = "SKEW" ; };
+ String SC_OPCODE_SKEWP { Text = "SKEWP" ; };
String SC_OPCODE_DEV_SQ { Text = "DEVSQ" ; };
String SC_OPCODE_MEDIAN { Text = "MEDIAN" ; };
String SC_OPCODE_MODAL_VALUE { Text = "MODE" ; };
@@ -624,6 +625,7 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH
String SC_OPCODE_STANDARD { Text = "STANDARDIZE" ; };
String SC_OPCODE_AVE_DEV { Text = "AVEDEV" ; };
String SC_OPCODE_SCHIEFE { Text = "SKEW" ; };
+ String SC_OPCODE_SKEWP { Text = "SKEWP" ; };
String SC_OPCODE_DEV_SQ { Text = "DEVSQ" ; };
String SC_OPCODE_MEDIAN { Text = "MEDIAN" ; };
String SC_OPCODE_MODAL_VALUE { Text = "MODE" ; };
@@ -1675,6 +1677,10 @@ Resource RID_STRLIST_FUNCTION_NAMES
{
Text [ en-US ] = "SKEW" ;
};
+ String SC_OPCODE_SKEWP
+ {
+ Text [ en-US ] = "SKEWP" ;
+ };
String SC_OPCODE_DEV_SQ
{
Text [ en-US ] = "DEVSQ" ;
diff --git a/sc/inc/helpids.h b/sc/inc/helpids.h
index e273ce415444..d5563371a1c1 100644
--- a/sc/inc/helpids.h
+++ b/sc/inc/helpids.h
@@ -530,6 +530,7 @@
#define HID_FUNC_SUMQUADABW "SC_HID_FUNC_SUMQUADABW"
#define HID_FUNC_MITTELABW "SC_HID_FUNC_MITTELABW"
#define HID_FUNC_SCHIEFE "SC_HID_FUNC_SCHIEFE"
+#define HID_FUNC_SKEWP "SC_HID_FUNC_SKEWP"
#define HID_FUNC_KURT "SC_HID_FUNC_KURT"
#define HID_FUNC_GEOMITTEL "SC_HID_FUNC_GEOMITTEL"
#define HID_FUNC_HARMITTEL "SC_HID_FUNC_HARMITTEL"
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index ed67ad1034bb..58fde7aae2d6 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -4560,6 +4560,7 @@ void Test::testFunctionLists()
"RANK",
"RSQ",
"SKEW",
+ "SKEWP",
"SLOPE",
"SMALL",
"STANDARDIZE",
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index cd44780dbc62..64d48bea1914 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -762,6 +762,7 @@ void ScHarMean();
void ScGeoMean();
void ScStandard();
void ScSkew();
+void ScSkewp();
void ScMedian();
double GetMedian( ::std::vector<double> & rArray );
double GetPercentile( ::std::vector<double> & rArray, double fPercentile );
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index 1b0e85a20d4c..df78713f6226 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -3038,6 +3038,39 @@ void ScInterpreter::ScSkew()
PushDouble(((xcube * fCount) / (fCount - 1.0)) / (fCount - 2.0));
}
+//fdo#60322
+void ScInterpreter::ScSkewp()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScSkewp" );
+ double fSum,fCount,vSum;
+ std::vector<double> values;
+ if ( !CalculateSkew( fSum, fCount, vSum, values ) )
+ return;
+
+ double fMean = fSum / fCount;
+
+ for ( size_t i = 0; i < values.size(); i++ )
+ vSum += ( values[ i ] - fMean ) * ( values[ i ] - fMean );
+
+ double fStdDevp = sqrt( vSum / fCount );
+ double dx = 0.0;
+ double xcube = 0.0;
+
+ if ( fStdDevp == 0 )
+ {
+ PushIllegalArgument();
+ return;
+ }
+
+ for ( size_t i = 0; i < values.size(); i++ )
+ {
+ dx = ( values[ i ] - fMean ) / fStdDevp;
+ xcube = xcube + ( dx * dx * dx );
+ }
+
+ PushDouble( xcube / fCount );
+}
+
double ScInterpreter::GetMedian( vector<double> & rArray )
{
size_t nSize = rArray.size();
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index bc7aa6fbfe14..d7df23fa13bb 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -4110,6 +4110,7 @@ StackVar ScInterpreter::Interpret()
case ocDevSq : ScDevSq(); break;
case ocKurt : ScKurt(); break;
case ocSchiefe : ScSkew(); break;
+ case ocSkewp : ScSkewp(); break;
case ocModalValue : ScModalValue(); break;
case ocMedian : ScMedian(); break;
case ocGeoMean : ScGeoMean(); break;
diff --git a/sc/source/core/tool/parclass.cxx b/sc/source/core/tool/parclass.cxx
index 6f3cae07861e..b4187c593d8f 100644
--- a/sc/source/core/tool/parclass.cxx
+++ b/sc/source/core/tool/parclass.cxx
@@ -163,6 +163,7 @@ const ScParameterClassification::RawData ScParameterClassification::pRawData[] =
{ ocRows, {{ Reference }, 1 }},
{ ocRSQ, {{ ForceArray, ForceArray }, 0 }},
{ ocSchiefe, {{ Reference }, 1 }},
+ { ocSkewp, {{ Reference }, 1 }},
{ ocSlope, {{ ForceArray, ForceArray }, 0 }},
{ ocSmall, {{ Reference, Value }, 0 }},
{ ocStDev, {{ Reference }, 1 }},
diff --git a/sc/source/filter/excel/xlformula.cxx b/sc/source/filter/excel/xlformula.cxx
index 27cbab0d2670..a96b263a4582 100644
--- a/sc/source/filter/excel/xlformula.cxx
+++ b/sc/source/filter/excel/xlformula.cxx
@@ -459,7 +459,7 @@ static const XclFunctionInfo saFuncTable_2013[] =
EXC_FUNCENTRY_V_VR_IMPORT( ocSecantHyp, 1, 1, 0, "SECH" ),
EXC_FUNCENTRY_V_RO( ocTable, 0, 1, 0, "SHEET" ),
EXC_FUNCENTRY_V_RO( ocTables, 0, 1, 0, "SHEETS" ),
- EXC_FUNCENTRY_V_RX( ocNoName, 1, MX, 0, "SKEW.P" ),
+ EXC_FUNCENTRY_V_RX( ocSkewp, 1, MX, 0, "SKEW.P" ),
EXC_FUNCENTRY_V_VR( ocUnichar, 1, 1, 0, "UNICHAR" ),
EXC_FUNCENTRY_V_VR( ocUnicode, 1, 1, 0, "UNICODE" ),
EXC_FUNCENTRY_V_VR( ocNoName, 1, 1, 0, "WEBSERVICE" ),
diff --git a/sc/source/filter/oox/formulabase.cxx b/sc/source/filter/oox/formulabase.cxx
index 623b10548b8a..efe95146b15f 100644
--- a/sc/source/filter/oox/formulabase.cxx
+++ b/sc/source/filter/oox/formulabase.cxx
@@ -810,7 +810,7 @@ static const FunctionData saFuncTable2013[] =
{ "SECH", "SECH", NOID, NOID, 1, 1, V, { VR }, FUNCFLAG_MACROCALL_NEW },
{ "SHEET", "SHEET", NOID, NOID, 0, 1, V, { RO }, FUNCFLAG_MACROCALL_NEW },
{ "SHEETS", "SHEETS", NOID, NOID, 0, 1, V, { RO }, FUNCFLAG_MACROCALL_NEW },
- { 0/*"SKEWP"*/, "SKEW.P", NOID, NOID, 1, MX, V, { RX }, FUNCFLAG_MACROCALL_NEW },
+ { "SKEWP", "SKEW.P", NOID, NOID, 1, MX, V, { RX }, FUNCFLAG_MACROCALL_NEW },
{ "UNICHAR", "UNICHAR", NOID, NOID, 1, 1, V, { VR }, FUNCFLAG_MACROCALL_NEW },
{ "UNICODE", "UNICODE", NOID, NOID, 1, 1, V, { VR }, FUNCFLAG_MACROCALL_NEW },
{ 0, "WEBSERVICE", NOID, NOID, 1, 1, V, { VR }, FUNCFLAG_MACROCALL_NEW },
diff --git a/sc/source/ui/src/scfuncs.src b/sc/source/ui/src/scfuncs.src
index 5f4c54024634..433e6fdb78f9 100644
--- a/sc/source/ui/src/scfuncs.src
+++ b/sc/source/ui/src/scfuncs.src
@@ -5374,6 +5374,30 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2
Text [ en-US ] = "Number 1, number 2, ... are 1 to 30 numerical arguments portraying a sample of the distribution." ;
};
};
+ // -=*# Resource for function SKEWP #*=-
+ Resource SC_OPCODE_SKEWP
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the skewness of a distribution using the population of a random variable." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_SKEWP );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number " ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Number 1, number 2, ... are 1 to 30 numerical arguments portraying the population." ;
+ };
+ };
// -=*# Resource for function KURT #*=-
Resource SC_OPCODE_KURT
{