Skip to content

Commit

Permalink
Modernise C function declarations; begin version 3 rollout
Browse files Browse the repository at this point in the history
  • Loading branch information
baddstats committed Oct 19, 2022
1 parent f576e33 commit 11828c2
Show file tree
Hide file tree
Showing 12 changed files with 123 additions and 103 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: spatstat.utils
Version: 2.999-999.001
Date: 2022-06-17
Version: 3.0-0
Date: 2022-10-19
Title: Utility Functions for 'spatstat'
Authors@R: c(person("Adrian", "Baddeley",
role = c("aut", "cre"),
Expand Down
7 changes: 3 additions & 4 deletions R/utilseq.R
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,9 @@ adjustthinrange <- function(ur,vstep,vr) {
fastFindInterval <- function(x, b, labels=FALSE, reltol=0.001, dig.lab=3L) {
nintervals <- length(b) - 1
nx <- length(x)
if(nx == 0)
return(rep(0, nintervals))
##
if(equispaced(b, reltol)) {
if(nx == 0) {
y <- integer(0)
} else if(equispaced(b, reltol)) {
## breaks are equally spaced
zz <- .C(C_fastinterv,
x = as.double(x),
Expand Down
2 changes: 1 addition & 1 deletion inst/doc/packagesizes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ date version nhelpfiles nobjects ndatasets Rlines srclines
"2021-03-15" "2.1-0" 33 180 0 3549 1966
"2021-06-14" "2.2-0" 34 181 0 3568 2012
"2021-12-12" "2.3-0" 35 183 0 3594 2012
"2022-06-17" "2.999-999.001" 39 186 0 3643 2012
"2022-10-19" "3.0-0" 39 186 0 3642 2031
2 changes: 2 additions & 0 deletions man/macros/defns.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
% Names with accents
\newcommand{\Bogsted}{\ifelse{latex}{\out{B\o gsted}}{Bogsted}}
\newcommand{\Cramer}{\ifelse{latex}{\out{Cram\'er}}{Cramer}}
\newcommand{\Francois}{\ifelse{latex}{\out{Fran\c{c}ois}}{Francois}}
\newcommand{\Frederic}{\ifelse{latex}{\out{Fr{\'e}d{\'e}ric}}{Frederic}}
\newcommand{\Hogmander}{\ifelse{latex}{\out{H{\"o}gmander}}{Hogmander}}
\newcommand{\Jyvaskyla}{\ifelse{latex}{\out{Jyv\"askyl\"a}}{Jyvaskyla}}
\newcommand{\Lucia}{\ifelse{latex}{\out{Luc\'{\i{}}a}}{Lucia}}
\newcommand{\Matern}{\ifelse{latex}{\out{Mat\'ern}}{Matern}}
\newcommand{\Moller}{\ifelse{latex}{\out{M\o ller}}{Moller}}
\newcommand{\Oehlschlaegel}{\ifelse{latex}{\out{Oehlschl\"{a}gel}}{Oehlschlaegel}}
Expand Down
22 changes: 13 additions & 9 deletions src/distseg.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
nndist2segs: minimum distance from point to any line segment (with index)
prdist2segs: pairwise distances from each point to each line segment
$Revision: 1.11 $ $Date: 2021/05/20 08:27:04 $
$Revision: 1.12 $ $Date: 2022/10/19 02:56:36 $
Author: Adrian Baddeley
Expand Down Expand Up @@ -36,17 +36,21 @@


void
prdist2segs(xp, yp, npoints, x0, y0, x1, y1, nsegments, epsilon, dist2)
prdist2segs(
/* input */
double *xp, *yp; /* point/pixel coordinates */
int *npoints;
double *x0, *y0, *x1, *y1; /* line segment endpoints */
int *nsegments;
double *epsilon; /* tolerance for short segments */
double *xp,
double *yp, /* point/pixel coordinates */
int *npoints,
double *x0,
double *y0,
double *x1,
double *y1, /* line segment endpoints */
int *nsegments,
double *epsilon, /* tolerance for short segments */
/* output */
double *dist2; /* squared distances from each pixel
double *dist2 /* squared distances from each pixel
to each line segment */
{
) {
int i,j, np, nseg, maxchunk;
double dx,dy,leng,co,si; /* parameters of segment */
double xdif0,ydif0,xdif1,ydif1,xpr,ypr; /* vectors */
Expand Down
33 changes: 16 additions & 17 deletions src/distseg.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,30 @@
Copyright (C) Adrian Baddeley, Ege Rubak and Rolf Turner 2001-2021
Licence: GNU Public Licence >= 2
$Revision: 1.1 $ $Date: 2021/05/20 08:29:45 $
$Revision: 1.3 $ $Date: 2022/10/19 02:58:46 $
*/

void
FNAME(xp, yp, npoints, x0, y0, x1, y1, nsegments, epsilon, dist2
#ifdef WANT_INDEX
, index
#endif
)
FNAME(
/* input */
double *xp, *yp; /* point/pixel coordinates */
int *npoints;
double *x0, *y0, *x1, *y1; /* line segment endpoints */
int *nsegments;
double *epsilon; /* tolerance for short segments */
double *xp,
double *yp, /* point/pixel coordinates */
int *npoints,
double *x0,
double *y0,
double *x1,
double *y1, /* line segment endpoints */
int *nsegments,
double *epsilon, /* tolerance for short segments */
/* output */
double *dist2; /* squared distance from pixel
to nearest line segment
INITIALISED TO LARGE VALUE
*/
double *dist2 /* squared distance from pixel
to nearest line segment
INITIALISED TO LARGE VALUE */
#ifdef WANT_INDEX
int *index; /* which line segment is closest */
, int *index /* which line segment is closest */
#endif
{
) {
int i,j, np, nseg, maxchunk;
double dx,dy,leng,co,si; /* parameters of segment */
double xdif0,ydif0,xdif1,ydif1,xpr,ypr; /* vectors */
Expand Down
14 changes: 8 additions & 6 deletions src/fastinterv.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,20 @@
Fast version of findInterval when breaks are known to be evenly spaced
and are known to embrace the data.
$Revision: 1.3 $ $Date: 2018/12/18 02:43:11 $
$Revision: 1.5 $ $Date: 2022/10/19 03:29:04 $
Copyright (C) Adrian Baddeley, Ege Rubak and Rolf Turner 2001-2018
Licence: GNU Public Licence >= 2
*/

void fastinterv(x, n, brange, nintervals, y)
double *x, *brange;
int *n, *nintervals;
int *y;
{
void fastinterv(
double *x, /* values to be classified */
int *n, /* number of x values */
double *brange, /* range of breakpoints */
int *nintervals, /* number of intervals */
int *y /* resulting indices (start from 1) */
) {
double bmin, bmax, db;
int i, j, m, N;

Expand Down
18 changes: 10 additions & 8 deletions src/inxyp.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
NB: relative to other versions, 'score' is multiplied by 2
(and is an integer)
$Revision: 1.8 $ $Date: 2018/12/18 02:43:11 $
$Revision: 1.11 $ $Date: 2022/10/19 03:38:17 $
Copyright (C) Adrian Baddeley, Ege Rubak and Rolf Turner 2001-2018
Licence: GNU Public Licence >= 2
Expand All @@ -16,15 +16,17 @@
#include <R_ext/Utils.h>
#include "chunkloop.h"

void inxyp(x,y,xp,yp,npts,nedges,score,onbndry)
void inxyp(
/* inputs */
double *x, *y; /* points to be tested */
int *npts;
double *xp, *yp; /* polygon vertices */
int *nedges;
double *x,
double *y, /* points to be tested */
double *xp,
double *yp, /* polygon vertices */
int *npts,
int *nedges,
/* outputs */
int *score;
int *onbndry;
int *score,
int *onbndry)
{
int i, j, Npts, Nedges, Ne1, contrib, maxchunk;
double x0, y0, x1, y1, dx, dy, xj, yj, xcrit, ycrit;
Expand Down
66 changes: 41 additions & 25 deletions src/matchindices.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
matchindices.c
$Revision$ $Date$
$Revision: 1.3 $ $Date: 2022/10/19 03:35:51 $
CSmatch2int Find matches between two sorted lists of pairs of integers
CSmatch3int Find matches between two sorted lists of triples of integers
Expand All @@ -28,16 +28,19 @@
*/

void CUmatch2int(na, xa, ya, nb, xb, yb, match)
void CUmatch2int(
/* inputs */
int *na, *nb;
int *xa, *ya;
int *xb, *yb;
int *na,
int *xa,
int *ya,
int *nb,
int *xb,
int *yb,
/* output */
int *match;
int *match
/* match[i] = j+1 if xb[j], yb[j] matches xa[i], ya[i] */
/* match[i] = 0 if no such point matches xa[i], ya[i] */
{
) {
int i, j, Na, Nb, maxchunk;
int xai, yai;

Expand Down Expand Up @@ -69,16 +72,21 @@ void CUmatch2int(na, xa, ya, nb, xb, yb, match)
*/

void CUmatch3int(na, xa, ya, za, nb, xb, yb, zb, match)
void CUmatch3int(
/* inputs */
int *na, *nb;
int *xa, *ya, *za;
int *xb, *yb, *zb;
int *na,
int *xa,
int *ya,
int *za,
int *nb,
int *xb,
int *yb,
int *zb,
/* output */
int *match;
int *match
/* match[i] = j+1 if xb[j], yb[j], zb[j] matches xa[i], ya[i], za[i] */
/* match[i] = 0 if no such point matches xa[i], ya[i], za[i] */
{
) {
int i, j, Na, Nb, maxchunk;
int xai, yai, zai;

Expand Down Expand Up @@ -117,16 +125,19 @@ void CUmatch3int(na, xa, ya, za, nb, xb, yb, zb, match)
*/

void CSmatch2int(na, xa, ya, nb, xb, yb, match)
void CSmatch2int(
/* inputs */
int *na, *nb;
int *xa, *ya; /* sorted into increasing order of (xa, ya) */
int *xb, *yb; /* sorted into increasing order of (xb, yb) */
int *na,
int *xa,
int *ya, /* sorted into increasing order of (xa, ya) */
int *nb,
int *xb,
int *yb, /* sorted into increasing order of (xb, yb) */
/* output */
int *match;
int *match
/* match[i] = j+1 if xb[j], yb[j] matches xa[i], ya[i] */
/* match[i] = 0 if no such point matches xa[i], ya[i] */
{
) {
int i, j, Na, Nb, maxchunk;
int xai, yai;

Expand Down Expand Up @@ -161,16 +172,21 @@ void CSmatch2int(na, xa, ya, nb, xb, yb, match)
*/

void CSmatch3int(na, xa, ya, za, nb, xb, yb, zb, match)
void CSmatch3int(
/* inputs */
int *na, *nb;
int *xa, *ya, *za; /* sorted into increasing order of (xa, ya, za) */
int *xb, *yb, *zb; /* sorted into increasing order of (xb, yb, zb) */
int *na,
int *xa,
int *ya,
int *za, /* sorted into increasing order of (xa, ya, za) */
int *nb,
int *xb,
int *yb,
int *zb, /* sorted into increasing order of (xb, yb, zb) */
/* output */
int *match;
int *match
/* match[i] = j+1 if xb[j], yb[j], zb[j] matches xa[i], ya[i], za[i] */
/* match[i] = 0 if no such point matches xa[i], ya[i], za[i] */
{
) {
int i, j, Na, Nb, maxchunk;
int xai, yai, zai;

Expand Down
16 changes: 10 additions & 6 deletions src/matchpoints.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
matchpoints.c
$Revision: 1.2 $ $Date: 2018/12/18 02:43:11 $
$Revision: 1.4 $ $Date: 2022/10/19 03:39:15 $
Copyright (C) Adrian Baddeley, Ege Rubak and Rolf Turner 2001-2018
Licence: GNU Public Licence >= 2
Expand All @@ -23,15 +23,19 @@
*/

void Cmatchxy(na, xa, ya, nb, xb, yb, match)
void Cmatchxy(
/* inputs */
int *na, *nb;
double *xa, *ya, *xb, *yb;
int *na,
double *xa,
double *ya,
int *nb,
double *xb,
double *yb,
/* output */
int *match;
int *match
/* match[i] = j+1 if xb[j], yb[j] matches xa[i], ya[i] */
/* match[i] = 0 if no such point matches xa[i], ya[i] */
{
){
int i, j, Na, Nb, maxchunk;
double xai, yai;

Expand Down
31 changes: 11 additions & 20 deletions src/ply.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,30 @@
Adrian Baddeley and Tilman Davies
$Revision: 1.3 $ $Date: 2017/11/13 08:43:37 $
$Revision: 1.4 $ $Date: 2022/10/19 03:13:26 $
*/


void FNAME(nin,
xin,
iin,
void FNAME(int *nin,
double *xin,
int *iin,
#if (NDIM > 1)
jin,
int *jin,
#if (NDIM > 2)
kin,
int *kin,
#endif
#endif
nout,
xout,
iout
int *nout,
double *xout,
int *iout
#if (NDIM > 1)
, jout
, int *jout
#if (NDIM > 2)
, kout
, int *kout
#endif
#endif
)
int *nin, *nout;
double *xin, *xout;
int *iin, *iout;
#if (NDIM > 1)
int *jin, *jout;
#if (NDIM > 2)
int *kin, *kout;
#endif
#endif
{
int Nin, l, m, icur;
#if (NDIM > 1)
Expand Down
Loading

0 comments on commit 11828c2

Please sign in to comment.