activateOptMethods {lgc} | R Documentation |

## Turn on optimized sparse matrix construction (Only relevant for very large models).

### Description

Speed up model fitting by caching sparse matrix patterns
and sharing pointers between them. Currently requires
package `inline`

.

### Usage

activateOptMethods(on = TRUE)

### Arguments

### Details

Building large sparse or semisparse precision matrices
can be very time consuming for large models - even though
major flops takes place elsewhere - after the matrices
have been built. During model fitting, matrices of
identical sparseness pattern are computed repeatedly with
different numerical values. By caching the required
matrix operations we can preallocate an arsenal of sparse
matrix templates and thereby eliminate this overhead.
Furthermore, different matrices with identical sparseness
pattern can share most sparse matrix slots - thereby
reducing memory. Before model fitting call
`activateOptMethods()`

to compile and overload the
methods. Use `.lgc_opt$trace(FALSE)`

to turn off
tracing information. After model fitting use
`.lgc_opt$summary()`

to get an overview of currently
cached methods, and `.lgc_opt$cleanup()`

to cleanup
workspace - Imortant before e.g. saving a fitted object!

### Value

NULL

### Examples

## Not run:
##' === Separable correlation on 1000x1000 grid
##' Without optimization
C <- covStructAR(n=1000);CC <- C%x%C
system.time(Q <- evaluate(CC))
##' Now with optimization
activateOptMethods() ## Turn on
C <- covStructAR(n=1000);CC <- C%x%C
system.time(Q <- evaluate(CC)) ## First call generates template
system.time(Q <- evaluate(CC)) ## Following calls are fast
.lgc_opt$summary() ## List of active methods
activateOptMethods(FALSE) ## Turn off
## End(Not run)

[Package

*lgc* version 1.4

Index]