From jrheinlaender at gmx.de Sat Nov 2 12:11:06 2024 From: jrheinlaender at gmx.de (=?UTF-8?Q?Jan_Rheinl=C3=A4nder?=) Date: Sat, 2 Nov 2024 12:11:06 +0100 Subject: [GiNaC-devel] Find length of a vector Message-ID: <3529e995-0b49-4dcd-9737-ee4aed545cd2@gmx.de> 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: OpenPGP_signature.asc Type: application/pgp-signature Size: 321 bytes Desc: OpenPGP digital signature URL: From kreckel at in.terlu.de Sat Nov 2 12:31:21 2024 From: kreckel at in.terlu.de (Richard B. Kreckel) Date: Sat, 2 Nov 2024 12:31:21 +0100 Subject: [GiNaC-devel] Find length of a vector In-Reply-To: <3529e995-0b49-4dcd-9737-ee4aed545cd2@gmx.de> References: <3529e995-0b49-4dcd-9737-ee4aed545cd2@gmx.de> Message-ID: <08bd21ec-56a1-47e8-b0e4-b816b32903be@in.terlu.de> 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. -------------- next part -------------- A non-text attachment was scrubbed... Name: OpenPGP_signature.asc Type: application/pgp-signature Size: 840 bytes Desc: OpenPGP digital signature URL: