Skip to content

Commit c647519

Browse files
committed
Tidied
1 parent aee62eb commit c647519

8 files changed

Lines changed: 48 additions & 28 deletions

File tree

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: spatstat.sparse
2-
Version: 3.1-0.005
3-
Date: 2026-04-11
2+
Version: 3.1-0.006
3+
Date: 2026-04-23
44
Title: Sparse Three-Dimensional Arrays and Linear Algebra Utilities
55
Authors@R: c(person("Adrian", "Baddeley",
66
role = c("aut", "cre", "cph"),

NEWS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
CHANGES IN spatstat.sparse VERSION 3.1-0.005
2+
CHANGES IN spatstat.sparse VERSION 3.1-0.006
33

44
OVERVIEW
55

R/sparseMarkov.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ runSparseMarkovChain <- function(P, x0, nsteps, ...,
3636
if(rx[1L] < 1 || rx[2L] > nrow(P))
3737
stop("Some indices in x0 are out of range", call.=FALSE)
3838
}
39+
40+
nentries <- length(P@x)
41+
if(nentries > .Machine$integer.max || is.na(as.integer(nentries)))
42+
stop("Sorry, long vectors are not yet supported", call.=FALSE)
43+
3944
## >>>>>>>>>>>> run chain <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
4045
switch(method,
4146
interpreted = {

inst/doc/packagesizes.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ date version nhelpfiles nobjects ndatasets Rlines srclines
1919
"2023-03-12" "3.0-1" 15 48 0 2092 740
2020
"2023-10-24" "3.0-3" 15 48 0 2092 740
2121
"2024-06-21" "3.1-0" 15 48 0 2092 740
22-
"2026-04-11" "3.1-0.005" 16 49 0 2189 944
22+
"2026-04-23" "3.1-0.006" 16 49 0 2194 943

inst/info/packagesizes.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ date version nhelpfiles nobjects ndatasets Rlines srclines
1919
"2023-03-12" "3.0-1" 15 48 0 2092 740
2020
"2023-10-24" "3.0-3" 15 48 0 2092 740
2121
"2024-06-21" "3.1-0" 15 48 0 2092 740
22-
"2026-04-11" "3.1-0.005" 16 49 0 2189 944
22+
"2026-04-23" "3.1-0.006" 16 49 0 2194 943

man/macros/defns.Rd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
\newcommand{\spatstatAuthorsComma}{\adrian, \rolf, \ege}
88
%% Contributors with emails (alphabetical order)
99
\newcommand{\abdollah}{Abdollah Jalilian \email{jalilian@razi.ac.ir}}
10+
\newcommand{\bethany}{Bethany Macdonald \email{bethany.macdonald@canterbury.ac.nz}}
1011
\newcommand{\colette}{Marie-Colette van Lieshout \email{Marie-Colette.van.Lieshout@cwi.nl}}
1112
\newcommand{\dominic}{Dominic Schuhmacher \email{dominic.schuhmacher@mathematik.uni-goettingen.de}, URL \code{http://dominic.schuhmacher.name/}}
1213
\newcommand{\martinH}{Martin Hazelton \email{Martin.Hazelton@otago.ac.nz}}

src/rmarkovchain.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
2424
The indices in 'colindex' and 'rowstart' are zero-based.
2525
26-
$Revision: 1.8 $ $Date: 2026/04/11 09:54:48 $
26+
$Revision: 1.9 $ $Date: 2026/04/15 03:49:20 $
2727
2828
Copyright (c) Adrian Baddeley 2026
2929
GNU Public Licence (>= 2.0)
@@ -35,9 +35,9 @@
3535
#include <math.h>
3636

3737
/* rMCspMF
38-
Run 'M'ultiple independent realisations
39-
from different starting points,
40-
and return only the 'F'inal states
38+
'r'un 'M'arkov 'C'hain for 'sp'arse matrix
39+
'M'ultiple independent realisations from different starting points,
40+
return only the 'F'inal states
4141
*/
4242

4343
void rMCspMF(
@@ -114,9 +114,9 @@ void rMCspMF(
114114

115115

116116
/* rMCspMH
117-
Run 'M'ultiple independent realisations
118-
from different starting points,
119-
and return the 'H'istory of each point.
117+
'r'un 'M'arkov 'C'hain for 'sp'arse matrix
118+
'M'ultiple independent realisations from different starting points
119+
return the 'H'istory of each point.
120120
*/
121121

122122
void rMCspMH(
@@ -197,4 +197,3 @@ void rMCspMH(
197197
PutRNGstate();
198198
}
199199

200-

tests/sparsemarkov.R

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ require(spatstat.sparse)
55
ALWAYS <- FULLTEST <- TRUE
66
#' tests/sparsemarkov.R
77
#' Tests of code for Markov chain with sparse transition matrix
8-
#' $Revision: 1.1 $ $Date: 2026/04/11 04:29:47 $
8+
#' $Revision: 1.3 $ $Date: 2026/04/23 05:20:03 $
99

1010
if(!exists("ALWAYS")) ALWAYS <- TRUE
1111
if(!exists("FULLTEST")) FULLTEST <- ALWAYS
1212

1313
if(FULLTEST) {
1414
local({
15-
testit <- function(P, Pname, xstart=50, ns=10, np=3, walkies=TRUE) {
15+
testit <- function(P, Pname, xstart=50, ns=10, np=3,
16+
walkies=FALSE, absorb=NULL) {
1617
cat(paste(">>>>>> ", Pname, " <<<<<<<\n"))
1718
cat("\tsingle particle, final state..\n")
1819
X1 <- runSparseMarkovChain(P, x0=xstart, nsteps=ns, result="l")
@@ -26,24 +27,40 @@ if(FULLTEST) {
2627
result="h")
2728
if(length(X1) != 1)
2829
stop(paste(Pname, "end state was not a single particle"))
29-
if(abs(X1 - xstart) > ns)
30-
stop(paste(Pname, "wandered impossibly far"))
3130
if(length(X2) != (ns + 1))
3231
stop(paste(Pname, "history has wrong length"))
33-
if(walkies && !all(abs(diff(X2)) == 1))
34-
stop(paste(Pname, "jumps were not all +- 1"))
3532
if(length(X3) != np)
3633
stop(paste(Pname, "final number of particles was not preserved"))
37-
if(max(abs(X3 - xstart)) > ns)
38-
stop(paste(Pname, "some particles wandered impossibly far"))
3934
if(!is.matrix(X4))
4035
stop(paste(Pname, "a matrix was expected for the history"))
4136
if(nrow(X4) != np)
4237
stop(paste(Pname, "number of particles was not preserved"))
4338
if(ncol(X4) != (ns + 1))
4439
stop(paste(Pname, "histories have wrong length"))
45-
if(walkies && !all(abs(apply(X4, 1, diff)) == 1))
46-
stop(paste(Pname, "jumps were not all +- 1"))
40+
41+
if(walkies) {
42+
## jumps are all +-1
43+
if(abs(X1 - xstart) > ns)
44+
stop(paste(Pname, "wandered impossibly far"))
45+
if(!all(abs(diff(X2)) == 1))
46+
stop(paste(Pname, "jumps were not all +- 1"))
47+
if(max(abs(X3 - xstart)) > ns)
48+
stop(paste(Pname, "some particles wandered impossibly far"))
49+
if(!all(abs(apply(X4, 1, diff)) == 1))
50+
stop(paste(Pname, "jumps of particles were not all +- 1"))
51+
}
52+
53+
if(!is.null(absorb)) {
54+
if(X1 != absorb)
55+
stop("Absorbing chain didn't absorb (final)")
56+
if(X2[ns+1] != absorb)
57+
stop("Absorbing chain didn't absorb (history)")
58+
if(any(X3 != absorb))
59+
stop("Absorbing chains didn't absorb (final)")
60+
if(any(X4[,ns+1] != absorb))
61+
stop("Absorbing chains didn't absorb (history)")
62+
}
63+
4764
cat("OK\n")
4865
return(invisible(list(X1=X1, X2=X2, X3=X3, X4=X4)))
4966
}
@@ -52,15 +69,13 @@ if(FULLTEST) {
5269
Pwalk <- matrix(0, 100, 100)
5370
Pwalk[abs(row(Pwalk) - col(Pwalk)) == 1] <- 1
5471
Pwalk <- Pwalk/rowSums(Pwalk)
55-
testit(Pwalk, "Simple random walk")
72+
testit(Pwalk, "Simple random walk", walkies=TRUE)
5673

5774
#' Absorbing
5875
Pabsorb <- matrix(0, 10, 10)
5976
Pabsorb[row(Pabsorb) < col(Pabsorb)] <- 1
60-
Pabsorb[10,10] <- 1
77+
Pabsorb[,10] <- 1
6178
Pabsorb <- Pabsorb/rowSums(Pabsorb)
62-
a <- testit(Pabsorb, "Absorbing chain", xstart=1, ns=10, walkies=FALSE)
63-
if(a$X1 != 10) stop("Absorbing chain didn't absorb")
64-
if(any(a$X3 != 10)) stop("Absorbing chains didn't absorb")
79+
a <- testit(Pabsorb, "Absorbing chain", xstart=1, ns=10, absorb=10)
6580
}
6681
)}

0 commit comments

Comments
 (0)