Feature #487
ScalarProduct accepts MatrixRow?
Description
Yesterday I saw some old C4 code. In it the author had a call of the form ScalarProduct(M[I],L)
where M
is a matrix and L
a list. Presumably it worked in C4; but it does not in C5 because ScalarProduct
expects two lists.
An easy workaround is to write ScalarProduct(GetRow(M,I),L)
; not as compact or elegant as the C4 version, but its meaning is clear. I believe the function GetRow
actually copies the entries, so there is a little wasted effort...
Should we extend ScalarProduct
to accept MATRIXROW?
Related issues
History
#1 Updated by John Abbott about 10 years ago
I'm rather undecided about this.
I suppose KISS would say not to widen the arg types accepted by ScalarProduct
, at least no until we observe that it is a frequent paradigm.
One "irritating" aspect is that the obvious C5 implementation would probably work with MATRIXROW args. Actually, the only obstacle to it working is that len
throws when given a MATRIXROW.
Opinions?
#2 Updated by Anna Maria Bigatti about 10 years ago
- Target version set to CoCoA-5.1.0 Easter14
I like defining (mathematically) matrix multiplication by scalar products, so I'm in favour of adding it.
GetRow would makes copies, so can get quite costly in a loop.
I don't think it is trivial to implement, probably "not hard".
#3 Updated by John Abbott about 10 years ago
- Target version changed from CoCoA-5.1.0 Easter14 to CoCoA-5.1.1 Seoul14
#4 Updated by Anna Maria Bigatti almost 10 years ago
- Target version changed from CoCoA-5.1.1 Seoul14 to CoCoA-5.?.?
I think it is possible, but tedious work. Is it worth the effort?
#5 Updated by John Abbott about 7 years ago
- Related to Support #1031: ScalarProduct: exact defn and manual page added
#6 Updated by Anna Maria Bigatti almost 5 years ago
- Related to Feature #1296: Matrixrow-functions added
#7 Updated by Anna Maria Bigatti almost 5 years ago
Anna Maria Bigatti wrote:
I like defining (mathematically) matrix multiplication by scalar products, so I'm in favour of adding it.
GetRow would makes copies, so can get quite costly in a loop.I don't think it is trivial to implement, probably "not hard".
I changed my mind: MATRIXROW
is a very dodgy type.