Normalizes a vector (mass-weighted if requested).

normalize.vector(x, mass=NULL)

Arguments

x

a numeric vector or matrix to be normalized.

mass

a numeric vector containing the atomic masses for weighting.

Details

This function normalizes a vector, or alternatively, the column-wise vector elements of a matrix. If atomic masses are provided the vector is mass-weigthed.

See examples for more details.

Value

Returns the normalized vector(s).

References

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

Author

Lars Skjaerven

See also

nma , inner.prod

Examples

x <- 1:3 y <- matrix(1:9, ncol = 3, nrow = 3) normalize.vector(x)
#> [1] 0.2672612 0.5345225 0.8017837
normalize.vector(y)
#> [,1] [,2] [,3] #> [1,] 0.2672612 0.4558423 0.5025707 #> [2,] 0.5345225 0.5698029 0.5743665 #> [3,] 0.8017837 0.6837635 0.6461623
## Application to normal modes pdb <- read.pdb( system.file("examples/1hel.pdb", package="bio3d") ) ## Calculate (vibrational) normal modes modes <- nma(pdb)
#> Building Hessian... Done in 0.013 seconds. #> Diagonalizing Hessian... Done in 0.078 seconds.
## Returns a vector nv <- normalize.vector(modes$modes[,7]) ## Returns a matrix nv <- normalize.vector(modes$modes[,7:10]) ## Mass-weighted nv <- normalize.vector(modes$modes[,7], mass=modes$mass)