Commit 488c90b9 authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

New function.

2004-10-08  Morten Welinder  <terra@gnome.org>

	* functions.c (gnumeric_hypot): New function.

2004-10-08  Morten Welinder  <terra@gnome.org>

	* src/rangefunc.c (range_hypot): New function.
parent 19a73ab8
2004-10-08 Morten Welinder <terra@gnome.org>
* src/rangefunc.c (range_hypot): New function.
* src/workbook.c (workbook_sheet_unhide_controls): New function.
* src/sheet.c (sheet_set_visibility): Call
......
......@@ -6,6 +6,7 @@ Morten:
* Make File->Open start in the directory where the current file
was loaded. [#143188]
* Make it possible to unhide sheets. [#154710]
* Add HYPOT function. [#148322]
--------------------------------------------------------------------------
......
2004-10-08 Morten Welinder <terra@gnome.org>
* src/rangefunc.c (range_hypot): New function.
* src/workbook.c (workbook_sheet_unhide_controls): New function.
* src/sheet.c (sheet_set_visibility): Call
......
2004-10-08 Morten Welinder <terra@gnome.org>
* functions.c (gnumeric_hypot): New function.
2004-10-05 Jody Goldberg <jody@gnome.org>
* Release 1.3.91
......
......@@ -248,6 +248,33 @@ gnumeric_lcm (FunctionEvalInfo *ei, GnmExprList *nodes)
/***************************************************************************/
static char const *help_hypot = {
N_("@FUNCTION=HYPOT\n"
"@SYNTAX=HYPOT(number1,number2,...)\n"
"@DESCRIPTION="
"HYPOT returns the square root of the sum of the squares of the argumnents.\n"
"\n"
"@EXAMPLES=\n"
"HYPOT(3,4) equals to 5.\n"
"\n"
"@SEEALSO=MIN,MAX")
};
static GnmValue *
gnumeric_hypot (FunctionEvalInfo *ei, GnmExprList *nodes)
{
return float_range_function (nodes, ei,
range_hypot,
COLLECT_IGNORE_STRINGS |
COLLECT_IGNORE_BOOLS |
COLLECT_IGNORE_BLANKS,
GNM_ERROR_NUM);
}
/***************************************************************************/
static char const *help_abs = {
N_("@FUNCTION=ABS\n"
"@SYNTAX=ABS(b1)\n"
......@@ -3204,6 +3231,9 @@ GnmFuncDescriptor const math_functions[] = {
{ "gcd", NULL, N_("number,number"), &help_gcd,
NULL, gnumeric_gcd, NULL, NULL, NULL,
GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
{ "hypot", NULL, "", &help_hypot,
NULL, gnumeric_hypot, NULL, NULL, NULL,
GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_UNIQUE_TO_GNUMERIC, GNM_FUNC_TEST_STATUS_NO_TESTSUITE },
{ "int", "f", N_("number"), &help_int,
gnumeric_int, NULL, NULL, NULL, NULL,
GNM_FUNC_SIMPLE + GNM_FUNC_AUTO_FIRST,
......
......@@ -36,6 +36,7 @@
<function name="combin"/>
<function name="floor"/>
<function name="gcd"/>
<function name="hypot"/>
<function name="int"/>
<function name="lcm"/>
<function name="ln"/>
......
......@@ -80,6 +80,22 @@ range_sumsq (const gnm_float *xs, int n, gnm_float *res)
return 0;
}
int
range_hypot (const gnm_float *xs, int n, gnm_float *res)
{
switch (n) {
case 0: *res = 0; return 0;
case 1: *res = gnumabs (xs[0]); return 0;
case 2: *res = hypotgnum (xs[0], xs[1]); return 0;
default:
if (range_sumsq (xs, n, res))
return 1;
*res = sqrtgnum (*res);
return 0;
}
}
/* Arithmetic average. */
int
range_average (const gnm_float *xs, int n, gnm_float *res)
......
......@@ -11,6 +11,7 @@ int range_multinomial (const gnm_float *xs, int n, gnm_float *res);
int range_sumsq (const gnm_float *xs, int n, gnm_float *res);
int range_avedev (const gnm_float *xs, int n, gnm_float *res);
int range_hypot (const gnm_float *xs, int n, gnm_float *res);
int range_average (const gnm_float *xs, int n, gnm_float *res);
int range_harmonic_mean (const gnm_float *xs, int n, gnm_float *res);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment