このマニュアルは既にメンテナンスが終了したバージョンの Ruby を対象としています。 最新版のマニュアルへ

Ruby 3.2 リファレンスマニュアル

instance method Matrix#entrywise_product

hadamard_product(m) -> MatrixRuby 2.5.0 から[permalink][rdoc][edit]
entrywise_product(m) -> Matrix

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

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

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