-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef6c2c4
commit 75481f0
Showing
12 changed files
with
580 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
c712d225ecd0632ecdb61d856652e048 *DESCRIPTION | ||
4f2e1bb438b4a47b611cba8b8c7fa6e2 *DESCRIPTION | ||
8978180e2735e69064cef803abafe717 *NAMESPACE | ||
eb5e3dd144d47e8547b1a2103cb1e8b8 *NEWS | ||
bc2c446941b5d490cd38d9d0c37d8ce6 *R/diag.R | ||
2ed492dd4faec5c6788023dbb74a99fa *NEWS | ||
02cff18352477edf52936f5595e13a1c *R/diagonals.R | ||
5af0caad0e4182b4b84fafeeda171316 *R/fatdiag.R | ||
4377a30de60cad31bfb694ae662cec8f *R/fatdiag.R | ||
298c36468bfb2d9975a29144beef49a2 *R/matricise.R | ||
2691863cc52ccddc31bd1827f4d36316 *R/split_vector.R | ||
26fe789783dc13f51938b45052cecf69 *README.md | ||
1dd6f9352cf54f6af30e0843bd7c3b1b *build/vignette.rds | ||
2e893a67e041f980be9686901d7705c2 *README.md | ||
de11144bf9e5ebbd75ece150afed8766 *build/vignette.rds | ||
33f6179f4338f18d0cf1e5835082901e *inst/CITATION | ||
45fdf83e44b249d29b6b7b9692f26615 *inst/doc/fatdiag.R | ||
e23972aca3ae53b88b14f101b238abf2 *inst/doc/fatdiag.Rmd | ||
e958b5271fa92f93515aa5550e0a7367 *inst/doc/fatdiag.html | ||
0af75b2f297a085f04552c174498edfb *man/diag-set.Rd | ||
8953ecbcc4cd5fb807db69b3b90aef0c *inst/doc/fatdiag.html | ||
63c593eac8c9f0d5894c21fa56350bdf *man/diagonals.Rd | ||
540357d29ae3e0d39187c4c67f1d3025 *man/fatdiag.Rd | ||
bd788ef8fb02ae4f78922fd926962b16 *man/fatdiag.Rd | ||
1d283b65348018be7e9a126d40783b95 *man/matricise.Rd | ||
eb40293ad564fe7a042c28c1f5b6a1f2 *man/split_vector.Rd | ||
93a1e65fece34405d313bc933811acfa *tests/testthat.R | ||
9232d7b7bb1ed4bdf0cd3afc6e6d24d0 *tests/testthat/test_fatdiag.R | ||
e23972aca3ae53b88b14f101b238abf2 *vignettes/fatdiag.Rmd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
diagonals 0.4.0 | ||
=================== | ||
|
||
* various small fixes | ||
|
||
|
||
diagonals 0.3.0 | ||
=================== | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#' Matricise | ||
#' | ||
#' @name matricise | ||
#' @param x a higher-order array (length(dim(x)) >= 3) | ||
#' @param row_dim the input array dimension which should be added to the row dimension of the output matrix, the value has to be 3 or 4. | ||
#' @param col_dim the input array dimension which should be added to the column dimension of the output matrix, the value has to be 3 or 4. | ||
#' @return a matrix (length(dim(x)) == 2 ) | ||
|
||
matricise <- function(x, row_dim = c(NULL,3,4), col_dim = c(NULL,3,4) ) { | ||
|
||
# save dimensions | ||
dx <- dim(x) | ||
|
||
# create row and col dims | ||
if (!is.null(row_dim)) { | ||
dr <- dx[row_dim] | ||
} else { | ||
dr <- 1L | ||
} | ||
if (!is.null(col_dim)) { | ||
dc <- dx[col_dim] | ||
} else { | ||
dc <- 1L | ||
} | ||
|
||
# create intermediate array | ||
a <- array( dim=c(nrow=(dx[1]*dr), ncol=dx[2], dc ) ) | ||
|
||
# sort in lists | ||
s1 <- split_vector( 1:(dx[1]*dr), steps=dx[dr] ) | ||
|
||
if (row_dim == 3) { | ||
# fill output matrix | ||
for (i in 1:length(s1) ) { | ||
a[s1[[i]], ,] <- x[,,i,] | ||
} | ||
} else if (row_dim == 4) { | ||
# fill output matrix | ||
for (i in 1:length(s1) ) { | ||
a[s1[[i]], ,] <- x[,,,i] | ||
} | ||
} else { | ||
stop("row_dim is not a valid array dimension") | ||
} | ||
|
||
# use new dimensions | ||
dx <- dim(a) | ||
|
||
# create output matrix | ||
m <- matrix(nrow=dx[1],ncol=(dx[2]*dc) ) | ||
|
||
# sort in lists | ||
s2 <- split_vector( 1:(dx[2]*dc), steps=dc ) | ||
|
||
# fill output matrix | ||
for (i in 1:length(s2) ) { | ||
m[, s2[[i]] ] <- a[,,i] | ||
} | ||
|
||
# return output matrix | ||
return(m) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.