Learn R Programming

bio3d (version 2.3-3)

dist.xyz: Calculate the Distances Between the Rows of Two Matrices

Description

Compute the pairwise euclidean distances between the rows of two matrices.

Usage

dist.xyz(a, b = NULL, all.pairs=TRUE, ncore=1, nseg.scale=1)

Arguments

a

a ‘xyz’ object, numeric data matrix, or vector.

b

an optional second ‘xyz’ object, data matrix, or vector.

all.pairs

logical, if TRUE all pairwise distances between the rows of ‘a’ and all rows of ‘b’ are computed, if FALSE only the distances between coresponding rows of ‘a’ and ‘b’ are computed.

ncore

number of CPU cores used to do the calculation. ncore>1 requires package ‘parallel’ installed.

nseg.scale

split input data into specified number of segments prior to running multiple core calculation. See fit.xyz.

Value

Returns a matrix of pairwise euclidean distances between each row of ‘a’ and all rows of ‘b’.

Details

This function returns a matrix of euclidean distances between each row of ‘a’ and all rows of ‘b’. Input vectors are coerced to three dimensional matrices (representing the Cartesian coordinates x, y and z) prior to distance computation. If ‘b’ is not provided then the pairwise distances between all rows of ‘a’ are computed.

References

Grant, B.J. et al. (2006) Bioinformatics 22, 2695--2696.

See Also

dm, dist

Examples

Run this code
# NOT RUN {
 dist.xyz( c(1,1,1, 3,3,3), c(3,3,3, 2,2,2, 1,1,1))
 dist.xyz( c(1,1,1, 3,3,3), c(3,3,3, 2,2,2, 1,1,1), all.pairs=FALSE)

# }

Run the code above in your browser using DataLab