ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:75394] [Ruby trunk Bug#12356] Vector covector incorrect multiplication with another vector.
       [not found] <redmine.issue-12356.20160506235154@ruby-lang.org>
@ 2016-05-06 23:51 ` rafael.soares81
  2019-08-23 22:35 ` [ruby-core:94513] [Ruby master " merch-redmine
  2019-08-26 14:54 ` [ruby-core:94568] " ruby-core
  2 siblings, 0 replies; 3+ messages in thread
From: rafael.soares81 @ 2016-05-06 23:51 UTC (permalink / raw)
  To: ruby-core

Issue #12356 has been reported by Rafael Silva.

----------------------------------------
Bug #12356: Vector covector incorrect multiplication with another vector.
https://bugs.ruby-lang.org/issues/12356

* Author: Rafael Silva
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-linux]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
Version 2.2.4

v1	=	Vector[2,3,4]
v2	=	Vector[4,5,6]
v1.covector.row_size      #1
v1.covector.column_size   #3
v2.covector.row_size      #1
v2.covector.column_size   #3

Vector does not have distinction between row and column, there's no column vector notion in the language.

v1 * v2.covector #Matrix[[8,10,12],[12,15,18],[16,20,24]]
# Should be illegal. But works like if v2.covector is transposed / column vector which it's clearly not.

v1.covector * v2.covector #ExceptionForMatrix::ErrDimensionMismatch: Matrix dimension mismatch
# Expected

v1 * v2 #ExceptionForMatrix::ErrOperationNotDefined: Operation(*) can't be defined: Vector op Vector
# No comments, see my observation below.

v1.covector * v2 #Vector[47]
#Again covector treated like transposed / column vector.

Personal observation: Terrible choice to represent Vector like an Array, Vector should be a shortcut to Matrix.



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ruby-core:94513] [Ruby master Bug#12356] Vector covector incorrect multiplication with another vector.
       [not found] <redmine.issue-12356.20160506235154@ruby-lang.org>
  2016-05-06 23:51 ` [ruby-core:75394] [Ruby trunk Bug#12356] Vector covector incorrect multiplication with another vector rafael.soares81
@ 2019-08-23 22:35 ` merch-redmine
  2019-08-26 14:54 ` [ruby-core:94568] " ruby-core
  2 siblings, 0 replies; 3+ messages in thread
From: merch-redmine @ 2019-08-23 22:35 UTC (permalink / raw)
  To: ruby-core

Issue #12356 has been updated by jeremyevans0 (Jeremy Evans).

Assignee set to marcandre (Marc-Andre Lafortune)
Status changed from Open to Assigned

I don't think this is a bug, but I'll let marcandre make the determination.  `Vector` can't be multipled with `Vector`, you get an error.  You can multiple a `Vector` by a `Matrix` and vice-versa by design, and `Vector#covector` returns a `Matrix`.  You can multiple a `Matrix` by a `Matrix` only if the column_count of the receiver is the row count of the argument.

Whether `Vector` is good design or bad design I'm not going to speculate on.  However, you could consider using NMatrix (https://rubygems.org/gems/nmatrix), as that represents vectors as matrices.

----------------------------------------
Bug #12356: Vector covector incorrect multiplication with another vector.
https://bugs.ruby-lang.org/issues/12356#change-80949

* Author: edmorte (Rafael Silva)
* Status: Assigned
* Priority: Normal
* Assignee: marcandre (Marc-Andre Lafortune)
* Target version: 
* ruby -v: ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-linux]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
Version 2.2.4

v1	=	Vector[2,3,4]
v2	=	Vector[4,5,6]
v1.covector.row_size      #1
v1.covector.column_size   #3
v2.covector.row_size      #1
v2.covector.column_size   #3

Vector does not have distinction between row and column, there's no column vector notion in the language.

v1 * v2.covector #Matrix[[8,10,12],[12,15,18],[16,20,24]]
# Should be illegal. But works like if v2.covector is transposed / column vector which it's clearly not.

v1.covector * v2.covector #ExceptionForMatrix::ErrDimensionMismatch: Matrix dimension mismatch
# Expected

v1 * v2 #ExceptionForMatrix::ErrOperationNotDefined: Operation(*) can't be defined: Vector op Vector
# No comments, see my observation below.

v1.covector * v2 #Vector[47]
#Again covector treated like transposed / column vector.

Personal observation: Terrible choice to represent Vector like an Array, Vector should be a shortcut to Matrix.



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ruby-core:94568] [Ruby master Bug#12356] Vector covector incorrect multiplication with another vector.
       [not found] <redmine.issue-12356.20160506235154@ruby-lang.org>
  2016-05-06 23:51 ` [ruby-core:75394] [Ruby trunk Bug#12356] Vector covector incorrect multiplication with another vector rafael.soares81
  2019-08-23 22:35 ` [ruby-core:94513] [Ruby master " merch-redmine
@ 2019-08-26 14:54 ` ruby-core
  2 siblings, 0 replies; 3+ messages in thread
From: ruby-core @ 2019-08-26 14:54 UTC (permalink / raw)
  To: ruby-core

Issue #12356 has been updated by marcandre (Marc-Andre Lafortune).

Status changed from Assigned to Rejected

Thanks Jeremy for updating this issue. I double checked and never received the original email notification...

> `Vector` does not have distinction between row and column, there's no column vector notion in the language.

Actually, in the library `Vector` is a column vector. You can see this for example with:

```
Vector[1, 2].to_matrix # => Matrix[[1], [2]]
```

So I believe that it is correct that `v.covector * v` or `v * v.covector` returns some result while other combinations should raise.

I'll close this but will reopen if there's more discussion to be had.


----------------------------------------
Bug #12356: Vector covector incorrect multiplication with another vector.
https://bugs.ruby-lang.org/issues/12356#change-81025

* Author: edmorte (Rafael Silva)
* Status: Rejected
* Priority: Normal
* Assignee: marcandre (Marc-Andre Lafortune)
* Target version: 
* ruby -v: ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-linux]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
Version 2.2.4

v1	=	Vector[2,3,4]
v2	=	Vector[4,5,6]
v1.covector.row_size      #1
v1.covector.column_size   #3
v2.covector.row_size      #1
v2.covector.column_size   #3

Vector does not have distinction between row and column, there's no column vector notion in the language.

v1 * v2.covector #Matrix[[8,10,12],[12,15,18],[16,20,24]]
# Should be illegal. But works like if v2.covector is transposed / column vector which it's clearly not.

v1.covector * v2.covector #ExceptionForMatrix::ErrDimensionMismatch: Matrix dimension mismatch
# Expected

v1 * v2 #ExceptionForMatrix::ErrOperationNotDefined: Operation(*) can't be defined: Vector op Vector
# No comments, see my observation below.

v1.covector * v2 #Vector[47]
#Again covector treated like transposed / column vector.

Personal observation: Terrible choice to represent Vector like an Array, Vector should be a shortcut to Matrix.



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-08-26 14:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-12356.20160506235154@ruby-lang.org>
2016-05-06 23:51 ` [ruby-core:75394] [Ruby trunk Bug#12356] Vector covector incorrect multiplication with another vector rafael.soares81
2019-08-23 22:35 ` [ruby-core:94513] [Ruby master " merch-redmine
2019-08-26 14:54 ` [ruby-core:94568] " ruby-core

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).