Skip to contents

Small utility functions

Usage

myouter(x, y, fun)
shiftleft(x, k = 1)
shiftright(x, k = 1)

Arguments

x

a vector.

y

a vector.

k

a non-negative integer.

fun

a function, see `Details'.

Details

myouter(x,y,fun) computes the outer product of x and y using the function fun. The result is a matrix with \((i,j)\)th element equal to fun(x[i],y[j]). It is not required for fun to be able to work with vector arguments. The function does the computations in R using a simple double loop. So, it is a convenience function, not a speed improving one.

shiftright(x,k) rotates the vector x k positions to the right.

shiftleft(x,k) rotates the vector x k positions to the left.

Value

for myouter, a matrix, as described in `Details'

for shiftleft and shiftright, a vector

Author

Georgi N. Boshnakov