Build data and AI skills | 50% off

Last chance! 50% off unlimited learning

Sale ends in


sommer (version 3.6)

hadamard.prod: 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 or vector object

y

a numeric matrix or vector object

Value

A matrix.

Details

The Hadamard product is an element-by-element product of the two matrices. Let x and x be two m×n numeric matrices. The Hadamard product is xy=[x1,1y1,1x1,2y1,2x1,ny1,nx2,1y121x2,2y2,2x2,ny2,nxm,1ym,1xm,2ym,2xm,nym,n]. It uses the * operation in R.

References

Hadamard, J (1983). Resolution d'une question relative aux determinants, Bulletin des Sciences Mathematiques, 17, 240-246.

Styan, G. P. H. (1973). Hadamard Products and Multivariate Statistical Analysis, Linear Algebra and Its Applications, Elsevier, 6, 217-240.

Examples

Run this code
# NOT RUN {
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 )
print( z )
# }

Run the code above in your browser using DataLab