cloneMatrix: Creates a deep copy of a matrix

View source: R/RcppExports.R

cloneMatrixR Documentation

Creates a deep copy of a matrix

Description

Useful when calling ERE_step_cycle or GibbsSteps_kcycle to ensure that there are no side effects for the return values.

Usage

cloneMatrix(M)

Arguments

M

A matrix

Value

A deep copy of the matrix.

Examples

lambda <- matrix(0.5,nrow=2,ncol=2)
p <- matrix(0.7, nrow=2,ncol=2)
L <- matrix(rexp(4),nrow=2);
L
Lold <- L
Lcopy <- cloneMatrix(L)
ERE_step_cycle(r=c(0,1),c=c(0,1),L=L,lambda=lambda,p=p)

L     ## new value
Lold  ## equal to L !!!
Lcopy ## still has the original value

systemicrisk documentation built on May 29, 2024, 9:20 a.m.