cgraph {matpow}R Documentation

Callback Examples

Description

Callback examples for matpow.

Usage

  cgraph(ev,cbinit=FALSE,mindist=FALSE)
  eig(ev,cbinit=FALSE,x=NULL,eps=1e-08)
  mc(ev,cbinit=FALSE,eps=1e-08)
  mexp(ev,cbinit=FALSE,eps=1e-08) 

Arguments

ev

R environment as in the return value of matpow.

cbinit

matpow will first call the callback with cbinit set to TRUE before iterations begin, then to FALSE during iterations.

mindist

if TRUE, the matrix of minimum intervertex distances will be calculated.

x

initial guess for the principal eigenvector.

eps

convergence criterion.

Details

Note that these functions are not called directly. The user specifies the callback function (whether one of the examples here or one written by the user) in his/her call to matpow, which calls the callback after each iteration.

In cgraph, it is recommended that squaring be set to TRUE in calling matpow, though this cannot be done if the mindist option is used. Use of squaring is unconditionally recommended for eig and mc. Do not use squaring with mexp.

Restrictions: These functions are currently set up only for ordinary R matrix multiplication or use with gputools.

Value

Callback functions don't normally return values, but they usually do maintain data in the R environment ev that is eventually returned by matpow, including the following components as well as the application-independent ones:

Examples

## Not run: 
m <- rbind(c(1,0,0,1),c(1,0,1,1),c(0,1,0,0),c(0,0,1,1))
ev <- matpow(m,callback=cgraph,mindist=T)
ev$connected  # prints TRUE
ev$dists  # prints, e.g. that min dist from 1 to 2 is 3
m <- rbind(1:2,3:4)
# allow for 1000 iterations max
ev <- matpow(m,1000,callback=eig,squaring=TRUE)
# how many iterations did we actually need?
ev$i  # only 8
ev$x  # prints eigenvec; check by calling R's eigen()

## End(Not run)

[Package matpow version 0.1.2 Index]