comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Is it possible to generate an error when it is tried to multiply matrix with different dimensions?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Is it possible to generate an error when it is tried to multiply matrix with different dimensions? [message #85386] Tue, 30 July 2013 03:15 Go to next message
Victor[2] is currently offline  Victor[2]
Messages: 5
Registered: July 2013
Junior Member
Hi everyone!

I want to know if it is possible to generate an error (or warnning) in IDL (using for instance de COMPILE_OPT or something like that) when it is tried to multiply matrix with different dimensions.

for instance..

a = [1,2,3]
b = [1,2]

The dimensions are different and if I do print,a*b the result is [1,4] but in fact I want to know that the matrix are different.

It is a common error when I use a lot of matrix and could be good to know when this it happens (at least some warning...)
thanks!!

kind regards,

Víctor
Re: Is it possible to generate an error when it is tried to multiply matrix with different dimensions? [message #85400 is a reply to message #85386] Tue, 30 July 2013 09:26 Go to previous messageGo to next message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 7/30/13 4:15 AM, victor wrote:
> Hi everyone!
>
> I want to know if it is possible to generate an error (or warnning)
> in IDL (using for instance de COMPILE_OPT or something like that)
> when it is tried to multiply matrix with different dimensions.
>
> for instance..
>
> a = [1,2,3] b = [1,2]
>
> The dimensions are different and if I do print,a*b the result is
> [1,4] but in fact I want to know that the matrix are different.
>
> It is a common error when I use a lot of matrix and could be good to
> know when this it happens (at least some warning...) thanks!!
>
> kind regards,
>
> Víctor
>

Not that I know of.

Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)
Research Mathematician
Tech-X Corporation
Re: Is it possible to generate an error when it is tried to multiply matrix with different dimensions? [message #85402 is a reply to message #85386] Tue, 30 July 2013 11:08 Go to previous messageGo to next message
Phillip Bitzer is currently offline  Phillip Bitzer
Messages: 223
Registered: June 2006
Senior Member
You could always check before multiplying:

IF N_ELEMENTS(a) EQ N_ELEMENTS(b) THEN c= a*b ELSE MESSAGE, "different number of elements"

and let your error handler "catch" the error.

An FYI - this isn't *really* matrix multiplication. What you're doing is multiplying each element of the arrays together. If you're interested in matrix multiplication, check out:

http://www.exelisvis.com/docs/Matrix_Operators.html
Re: Is it possible to generate an error when it is tried to multiply matrix with different dimensions? [message #85413 is a reply to message #85402] Thu, 01 August 2013 00:04 Go to previous message
Victor[2] is currently offline  Victor[2]
Messages: 5
Registered: July 2013
Junior Member
Sorry, I wrote the question bad, as you said I would want to control a multiplication of each element of the matrix (not a "classical" mathematical matrix multiplication)

And Yes, I knew that I can control the situation but I wanted to know if it is possible to work in the same way like Matlab ...

Thanks



On Tuesday, July 30, 2013 8:08:55 PM UTC+2, Phillip Bitzer wrote:
> You could always check before multiplying:
>
>
>
> IF N_ELEMENTS(a) EQ N_ELEMENTS(b) THEN c= a*b ELSE MESSAGE, "different number of elements"
>
>
>
> and let your error handler "catch" the error.
>
>
>
> An FYI - this isn't *really* matrix multiplication. What you're doing is multiplying each element of the arrays together. If you're interested in matrix multiplication, check out:
>
>
>
> http://www.exelisvis.com/docs/Matrix_Operators.html
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: image(/buffer) & colorbar result in seg fault
Next Topic: Re: Asynchronous IDL_IDLBridge causing memory leak

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 18:41:45 PDT 2025

Total time taken to generate the page: 0.00593 seconds