Project

General

Profile

Actions

Feature #10069

closed

[PATCH] Implement monadic operator for Matrix

Added by gogotanaka (Kazuki Tanaka) over 9 years ago. Updated over 9 years ago.

Status:
Closed
Target version:
[ruby-core:63850]

Description

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_uplus_for_matrix.patch gogotanaka (Kazuki Tanaka), 07/19/2014 02:07 AM
implement_negate_for_matrix.patch (1.21 KB) implement_negate_for_matrix.patch gogotanaka (Kazuki Tanaka), 07/19/2014 02:07 AM

Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #10068: [PATCH] Implement monadic operator for VectorClosedmarcandre (Marc-Andre Lafortune)07/19/2014Actions

Updated by matz (Yukihiro Matsumoto) over 9 years ago

  • Related to Feature #10068: [PATCH] Implement monadic operator for Vector added

Updated by matz (Yukihiro Matsumoto) over 9 years ago

As #10068, I like the idea, but unary operator has nothing related to inject though.

Matz.

Updated by gogotanaka (Kazuki Tanaka) over 9 years ago

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.

Updated by hsbt (Hiroshi SHIBATA) over 9 years ago

  • Assignee set to marcandre (Marc-Andre Lafortune)
  • Category set to lib
  • Status changed from Open to Assigned
  • Target version set to 2.2.0

Updated by marcandre (Marc-Andre Lafortune) over 9 years ago

  • Status changed from Assigned to Closed

Done.

Thanks for catching this omission, and for the patch.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0