Crates a deep copy of a matrix

Share:

Description

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

Usage

1

Arguments

M

A matrix

Value

A deep copy of the matrix.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.