mulXPtr: Multiplies the elements of a XPtr object by a constant...

Description Usage Arguments Value Author(s) See Also Examples

Description

Multiplies the elements of a XPtr object by a constant vector-wise. The idea is that a symmetrix matrix M can be represented as a triangular object d. With this function you set M[x,x] = M[x,x] * k but instead of working on M this function works on its XPtr representation d.

Usage

1
mulXPtr(d, x, k)

Arguments

d

a XPtr object, lower diagonal, representing a symmetric matrix

x

a list of vectors of indices

k

a vector of multiplicative constants, arguments are eventually recycled silently

Value

returns the modified XPtr object

Author(s)

Stefano M. Iacus

See Also

dist

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
M <- matrix(2,5,5)
d <- newXPtr(5,2)
x <- list(1:3, 4:5)

mulXPtr(d,x,c(-1,2))

# which is the equivalent of (apart for the diagonal elements)
M[1:3,1:3] <- M[1:3,1:3] * (-1)
M[4:5,4:5] <- M[4:5,4:5] * 2

# Indeed, we have
(XPtrToDist(d))
as.dist(M)

rrp documentation built on May 2, 2019, 5:25 p.m.

Related to mulXPtr in rrp...