File: SparseArray-dim-tuning.R

package info (click to toggle)
r-bioc-sparsearray 1.6.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,768 kB
  • sloc: ansic: 16,138; makefile: 2
file content (33 lines) | stat: -rw-r--r-- 1,317 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
### =========================================================================
### Dim tuning of a SparseArray object
### -------------------------------------------------------------------------
###
### See R/dim-tuning-utils.R in the S4Arrays package for more information
### about "dim tuning" and the tune_Array_dims() generic.


### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### tune_Array_dims() method for SVT_SparseArray objects
###
### This is the workhorse behind drop() and dim<-() on SVT_SparseArray
### objects.
###
### Unlike with S4Arrays:::tune_dims() and S4Arrays:::tune_dimnames(),
### the 'dim_tuner' vector passed to .tune_SVT_SparseArray_dims() must
### be normalized. See src/SparseArray_dim_tuning.c for more information.

.tune_SVT_SparseArray_dims <- function(x, dim_tuner)
{
    stopifnot(is(x, "SVT_SparseArray"), is.integer(dim_tuner))
    check_svt_version(x)

    ans_SVT <- SparseArray.Call("C_tune_SVT_dims",
                                x@dim, x@type, x@SVT, dim_tuner)
    ans_dim <- S4Arrays:::tune_dims(x@dim, dim_tuner)
    ans_dimnames <- S4Arrays:::tune_dimnames(x@dimnames, dim_tuner)

    new_SVT_SparseArray(ans_dim, ans_dimnames, x@type, ans_SVT, check=FALSE)
}

setMethod("tune_Array_dims", "SVT_SparseArray", .tune_SVT_SparseArray_dims)