Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gnumeric
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
376
Issues
376
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GNOME
gnumeric
Commits
f22f31a4
Commit
f22f31a4
authored
Jul 27, 2001
by
Morten Welinder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Broken pipe during commit.
parent
50fcdf4d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
166 deletions
+6
-166
plugins/fn-math/functions.c
plugins/fn-math/functions.c
+1
-0
plugins/fn-stat/functions.c
plugins/fn-stat/functions.c
+2
-83
src/functions/fn-math.c
src/functions/fn-math.c
+1
-0
src/functions/fn-stat.c
src/functions/fn-stat.c
+2
-83
No files found.
plugins/fn-math/functions.c
View file @
f22f31a4
...
...
@@ -13,6 +13,7 @@
#include "sheet.h"
#include "str.h"
#include "mathfunc.h"
#include "rangefunc.h"
#include "collect.h"
#include "auto-format.h"
...
...
plugins/fn-stat/functions.c
View file @
f22f31a4
...
...
@@ -11,6 +11,7 @@
#include "func-util.h"
#include "parse-util.h"
#include "mathfunc.h"
#include "rangefunc.h"
#include "regression.h"
#include "sheet.h"
#include "cell.h"
...
...
@@ -21,27 +22,6 @@
#include <stdlib.h>
#include <string.h>
static
guint
float_hash
(
const
gnum_float
*
d
)
{
guint
h
=
0
;
size_t
i
;
const
unsigned
char
*
p
=
(
const
unsigned
char
*
)
d
;
for
(
i
=
0
;
i
<
sizeof
(
gnum_float
);
i
++
)
h
^=
h
/
3
+
(
h
<<
9
)
+
p
[
i
];
return
h
;
}
static
gint
float_equal
(
const
gnum_float
*
a
,
const
gnum_float
*
b
)
{
if
(
*
a
==
*
b
)
return
1
;
return
0
;
}
static
gint
float_compare
(
const
gnum_float
*
a
,
const
gnum_float
*
b
)
{
...
...
@@ -735,50 +715,6 @@ static char *help_mode = {
"@SEEALSO=AVERAGE,MEDIAN"
)
};
static
void
cb_range_mode
(
gpointer
key
,
gpointer
value
,
gpointer
user_data
)
{
g_free
(
value
);
}
static
int
range_mode
(
const
gnum_float
*
xs
,
int
n
,
gnum_float
*
res
)
{
GHashTable
*
h
;
int
i
;
gnum_float
mode
=
0
;
int
dups
=
0
;
if
(
n
<=
1
)
return
1
;
h
=
g_hash_table_new
((
GHashFunc
)
float_hash
,
(
GCompareFunc
)
float_equal
);
for
(
i
=
0
;
i
<
n
;
i
++
)
{
int
*
pdups
=
g_hash_table_lookup
(
h
,
&
xs
[
i
]);
if
(
pdups
)
(
*
pdups
)
++
;
else
{
pdups
=
g_new
(
int
,
1
);
*
pdups
=
1
;
g_hash_table_insert
(
h
,
(
gpointer
)(
&
xs
[
i
]),
pdups
);
}
if
(
*
pdups
>
dups
)
{
dups
=
*
pdups
;
mode
=
xs
[
i
];
}
}
g_hash_table_foreach
(
h
,
cb_range_mode
,
NULL
);
g_hash_table_destroy
(
h
);
if
(
dups
<=
1
)
return
1
;
*
res
=
mode
;
return
0
;
}
static
Value
*
gnumeric_mode
(
FunctionEvalInfo
*
ei
,
GList
*
expr_node_list
)
{
...
...
@@ -2379,29 +2315,12 @@ static char *help_median = {
"@SEEALSO=AVERAGE,COUNT,COUNTA,DAVERAGE,MODE,SUM"
)
};
/* Special Excel-meaning of median. */
static
int
range_excel_median
(
const
gnum_float
*
xs
,
int
n
,
gnum_float
*
res
)
{
if
(
n
>
0
)
{
/* OK, so we ignore the constness here. Tough. */
qsort
((
gnum_float
*
)
xs
,
n
,
sizeof
(
xs
[
0
]),
(
void
*
)
&
float_compare
);
if
(
n
&
1
)
*
res
=
xs
[
n
/
2
];
else
*
res
=
(
xs
[
n
/
2
-
1
]
+
xs
[
n
/
2
])
/
2
;
return
0
;
}
else
return
1
;
}
static
Value
*
gnumeric_median
(
FunctionEvalInfo
*
ei
,
GList
*
expr_node_list
)
{
return
float_range_function
(
expr_node_list
,
ei
,
range_
excel_median
,
range_
median_inter
,
COLLECT_IGNORE_STRINGS
|
COLLECT_IGNORE_BOOLS
|
COLLECT_IGNORE_BLANKS
,
...
...
src/functions/fn-math.c
View file @
f22f31a4
...
...
@@ -13,6 +13,7 @@
#include "sheet.h"
#include "str.h"
#include "mathfunc.h"
#include "rangefunc.h"
#include "collect.h"
#include "auto-format.h"
...
...
src/functions/fn-stat.c
View file @
f22f31a4
...
...
@@ -11,6 +11,7 @@
#include "func-util.h"
#include "parse-util.h"
#include "mathfunc.h"
#include "rangefunc.h"
#include "regression.h"
#include "sheet.h"
#include "cell.h"
...
...
@@ -21,27 +22,6 @@
#include <stdlib.h>
#include <string.h>
static
guint
float_hash
(
const
gnum_float
*
d
)
{
guint
h
=
0
;
size_t
i
;
const
unsigned
char
*
p
=
(
const
unsigned
char
*
)
d
;
for
(
i
=
0
;
i
<
sizeof
(
gnum_float
);
i
++
)
h
^=
h
/
3
+
(
h
<<
9
)
+
p
[
i
];
return
h
;
}
static
gint
float_equal
(
const
gnum_float
*
a
,
const
gnum_float
*
b
)
{
if
(
*
a
==
*
b
)
return
1
;
return
0
;
}
static
gint
float_compare
(
const
gnum_float
*
a
,
const
gnum_float
*
b
)
{
...
...
@@ -735,50 +715,6 @@ static char *help_mode = {
"@SEEALSO=AVERAGE,MEDIAN"
)
};
static
void
cb_range_mode
(
gpointer
key
,
gpointer
value
,
gpointer
user_data
)
{
g_free
(
value
);
}
static
int
range_mode
(
const
gnum_float
*
xs
,
int
n
,
gnum_float
*
res
)
{
GHashTable
*
h
;
int
i
;
gnum_float
mode
=
0
;
int
dups
=
0
;
if
(
n
<=
1
)
return
1
;
h
=
g_hash_table_new
((
GHashFunc
)
float_hash
,
(
GCompareFunc
)
float_equal
);
for
(
i
=
0
;
i
<
n
;
i
++
)
{
int
*
pdups
=
g_hash_table_lookup
(
h
,
&
xs
[
i
]);
if
(
pdups
)
(
*
pdups
)
++
;
else
{
pdups
=
g_new
(
int
,
1
);
*
pdups
=
1
;
g_hash_table_insert
(
h
,
(
gpointer
)(
&
xs
[
i
]),
pdups
);
}
if
(
*
pdups
>
dups
)
{
dups
=
*
pdups
;
mode
=
xs
[
i
];
}
}
g_hash_table_foreach
(
h
,
cb_range_mode
,
NULL
);
g_hash_table_destroy
(
h
);
if
(
dups
<=
1
)
return
1
;
*
res
=
mode
;
return
0
;
}
static
Value
*
gnumeric_mode
(
FunctionEvalInfo
*
ei
,
GList
*
expr_node_list
)
{
...
...
@@ -2379,29 +2315,12 @@ static char *help_median = {
"@SEEALSO=AVERAGE,COUNT,COUNTA,DAVERAGE,MODE,SUM"
)
};
/* Special Excel-meaning of median. */
static
int
range_excel_median
(
const
gnum_float
*
xs
,
int
n
,
gnum_float
*
res
)
{
if
(
n
>
0
)
{
/* OK, so we ignore the constness here. Tough. */
qsort
((
gnum_float
*
)
xs
,
n
,
sizeof
(
xs
[
0
]),
(
void
*
)
&
float_compare
);
if
(
n
&
1
)
*
res
=
xs
[
n
/
2
];
else
*
res
=
(
xs
[
n
/
2
-
1
]
+
xs
[
n
/
2
])
/
2
;
return
0
;
}
else
return
1
;
}
static
Value
*
gnumeric_median
(
FunctionEvalInfo
*
ei
,
GList
*
expr_node_list
)
{
return
float_range_function
(
expr_node_list
,
ei
,
range_
excel_median
,
range_
median_inter
,
COLLECT_IGNORE_STRINGS
|
COLLECT_IGNORE_BOOLS
|
COLLECT_IGNORE_BLANKS
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment