Bug #171
Negate LIST, MAT,...
Description
Negation ("-") is undefined for X, a list or matrix (and what else???)
However (-1)*X is allowed.
Should we define negation whenever "(-1)* " is allowed?
... I think so...
Related issues
History
#1
Updated by John Abbott about 12 years ago
If N*X
is valid (for N
integer, and X
of some type) then it makes perfect sense that -X
should be equivalent to (-1)*X
. We should also check that X*N
is allowed and is equivalent to N*X
.
I wonder if the equivalence can be implemented "automatically"?
[I have my doubts]
In any case, we should make sure that the equivalence is fully tested.
#2
Updated by Anna Maria Bigatti about 12 years ago
- Category changed from CoCoA-4 function: obsolete to CoCoA-4 function to be added
-M is not available in CoCoALib whereasmatrix operator-(ConstMatrixView Mleft, ConstMatrixView Mright)
is.
Should we add it or not?
#3
Updated by Anna Maria Bigatti about 12 years ago
John Abbott wrote:
If
N*X
is valid (forN
integer, andX
of some type) then it makes perfect sense that-X
should be equivalent to(-1)*X
. We should also check thatX*N
is allowed and is equivalent toN*X
.I wonder if the equivalence can be implemented "automatically"?
[I have my doubts]
better not. That should be implemented at cocoalib level.
In any case, we should make sure that the equivalence is fully tested.
True: ... again should be done in cocoalib
#4
Updated by John Abbott about 12 years ago
I've just added operator-
(scalar multiple by -1) to MatrixArith
.
Contrary to my suggestion that multiplication by an integer be commutative, I notice that M*n
is not yet offered in CoCoALib. Should it be added?
#5
Updated by Anna Maria Bigatti about 12 years ago
John Abbott wrote:
I've just added
operator-
(scalar multiple by -1) toMatrixArith
.Contrary to my suggestion that multiplication by an integer be commutative, I notice that
M*n
is not yet offered in CoCoALib. Should it be added?
yes, in fact
/**/ IdentityMat(R,2)*3; ERROR: I don't know how to evaluate operator * between MAT and INT IdentityMat(R,2)*3; ^
#6
Updated by John Abbott about 12 years ago
Added scalar multiplication on the right (for matrices) to CoCoALib.
#7
Updated by John Abbott about 12 years ago
Added scalar mult on the right & unary minus for matrices in C5.
#8
Updated by John Abbott about 12 years ago
Scalar multiplication could be useful for:
[LIST, MAT, MATRIXROW, RECORD, VECTOR]
JAA thinks it is better to exclude RECORD
, at least initially.
At the moment the only operation on MATRIXROW
is indexing (and printing). JAA would prefer not to have scalar multiples for MATRIXROW
because he thinks that a MATRIXROW
is a (read-only?) reference to a row in a matrix, and it would be unclear whether a scalar multiple of a MATRIXROW
should modify the original matrix.
Can we create values of type VECTOR
? Are they the same as ModuleElem
in CoCoALib?
#9
Updated by Anna Maria Bigatti about 12 years ago
I agree to exclude MATRIXROW
and RECORD
Can we create values of type
VECTOR
? Are they the same asModuleElem
in CoCoALib?
not yet. I think they sould be called ModuleElem
in CoCoA-5 as well
#10
Updated by John Abbott about 10 years ago
If L
is a list C5 cannot compute -L
but it can compute (-1)*L
and also L1-L2
if L1
and L2
are lists. This seems incongruous.
I tried implementing but couldn't figure out how: there is a commented out attempt in Interpreter.C:2168--2181
.
Additonally, Anna questions how sensible it is to have "list arithmetic".
Is Giovanni willing to help, if we should decide to implement?
#11
Updated by Anna Maria Bigatti about 10 years ago
- Target version set to CoCoA-5.1.0 Easter14
#12
Updated by John Abbott about 10 years ago
- Target version changed from CoCoA-5.1.0 Easter14 to CoCoA-5.?.?