From: qlli.illb@... Date: 2014-07-19T21:08:18+00:00 Subject: [ruby-core:63885] [ruby-trunk - Feature #10069] [PATCH] Implement monadic operator for Matrix Issue #10069 has been updated by gogo tanaka. Yukihiro Matsumoto wrote: > unary operator has nothing related to inject though. It's kind of my mistake, sorry to confuse you. I think it not seldom happens that we want do this(term monadic). And this is based on custom in math. Compared with some other numerical analysis software(MATLAB, mathematica, GNU Octave, R, NumPy), They have term monadic for matrix, vector. (But you can say "this is ruby issue! this is no business of how other softwares are" ) thank you. gogo. ---------------------------------------- Feature #10069: [PATCH] Implement monadic operator for Matrix https://bugs.ruby-lang.org/issues/10069#change-47911 * Author: gogo tanaka * Status: Open * Priority: Normal * Assignee: * Category: * Target version: ---------------------------------------- Before ``` m = Matrix[[1,2,3], [4,5,6]] + m NoMethodError: undefined method `+@' for Matrix[[1, 2, 3], [4, 5, 6]]:Matrix - m NoMethodError: undefined method `-@' for Matrix[[1, 2, 3], [4, 5, 6]]:Matrix ``` After ``` m = Matrix[[1,2,3], [4,5,6]] + m => Matrix[[1, 2, 3], [4, 5, 6]] - m => Matrix[[-1, -2, -3], [-4, -5, -6]] ``` I think monadic operator for Matrix is important, when I use operator as block. like that ``` matrix_ary.inject(:+) ``` ---Files-------------------------------- implement_uplus_for_matrix.patch (762 Bytes) implement_negate_for_matrix.patch (1.21 KB) -- https://bugs.ruby-lang.org/