Module: Muze::Core::Matrix
- Defined in:
- lib/muze/core/matrix.rb
Overview
Small dense matrix helpers used by feature extractors.
Class Method Summary collapse
Class Method Details
.multiply(left, right) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/muze/core/matrix.rb', line 9 def multiply(left, right) left_matrix = Numo::SFloat.cast(left) right_matrix = Numo::SFloat.cast(right) left_matrix = left_matrix.(1) if left_matrix.ndim == 1 right_matrix = right_matrix.(1) if right_matrix.ndim == 1 _, left_cols = left_matrix.shape right_rows, = right_matrix.shape raise Muze::ParameterError, "Matrix dimensions do not align" unless left_cols == right_rows left_matrix.dot(right_matrix).cast_to(Numo::SFloat) end |