hadamard.prod {matrixcalc}R Documentation

Hadamard product of two matrices

Description

This function returns the Hadamard or Shur product of two matrices, x and y, that have the same row and column dimensions.

Usage

hadamard.prod(x, y)

Arguments

x

a numeric matrix object

y

a numeric matrix object

Details

The Hadamard product is an element-by-element product of the two matrices. It uses the * operation in R.

Value

A matrix.

Note

The function stops running if x or y is not a numeric matrix and an error message is displayed. The function also stops running if x and y do not have the same row and column dimensions and an error mesage is displayed.

Author(s)

Frederick Novomestky fnovomes@poly.edu

References

Magnus, J. R. and H. Neudecker (1999) Matrix Differential Calculus with Applications in Statistics and Econometrics, Second Edition, John Wiley.

See Also

is.numeric.matrix

Examples

x <- matrix( c( 1, 2, 3, 4 ), nrow=2, byrow=TRUE )
y <- matrix( c( 2, 4, 6, 8 ), nrow=2, byrow=TRUE )
z <- hadamard.prod( x, y )

[Package matrixcalc version 1.0-1 Index]