Find length of a vector
Hi, trying to find the length of a vector by taking the square root of the scalar product, I get this (in ginsh):
v = [[a,b]]; [[a,b]] r = sqrt(v * transpose(v)); sqrt([[a,b]]*[[a],[b]]) evalm(r); matrix::pow(): don't know how to handle exponent
The reason is that the scalar product evaluates to a matrix with a single element, not to a numeric. Is that intended? Thanks, Jan Rheinländer
Hi, On 11/2/24 12:11 PM, Jan Rheinländer via GiNaC-devel wrote:
trying to find the length of a vector by taking the square root of the scalar product, I get this (in ginsh):
v = [[a,b]]; [[a,b]] r = sqrt(v * transpose(v)); sqrt([[a,b]]*[[a],[b]]) evalm(r); matrix::pow(): don't know how to handle exponent
The reason is that the scalar product evaluates to a matrix with a single element, not to a numeric.
There are just matrix products evaluating to matrices. There is no special case for scalar products (apart from the quite special stuff in indexed.h).
Is that intended?
Well, it's the way it is designed. ;-) -richy.
participants (2)
-
Jan Rheinländer
-
Richard B. Kreckel