Ruby 2.6.0 リファレンスマニュアル > ライブラリ一覧 > matrixライブラリ > Matrixクラス > entrywise_product

instance method Matrix#entrywise_product

hadamard_product(m) -> Matrix[permalink][rdoc]
entrywise_product(m) -> Matrix

アダマール積(要素ごとの積)を返します。

[EXCEPTION] ExceptionForMatrix::ErrDimensionMismatch:
行や列の要素数が一致しない時に発生します。


require 'matrix'

Matrix[[1,2], [3,4]].hadamard_product(Matrix[[1,2], [3,2]]) # => Matrix[[1, 4], [9, 8]]