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

Home » Public Forums » archive » matrix division
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: matrix division [message #60566 is a reply to message #60444] Thu, 22 May 2008 09:19 Go to previous messageGo to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
David Fanning wrote:
> jameskuyper@verizon.net writes:
>
>> For the integer case:
>>
>> ratio = numerator/denominator
>> bad = WHERE(denominator eq 0, count)
>> IF count gt 0 THEN ratio[bad] = replacement_value
>>
>> replacement_value needs to be carefully chose for the context of your
>> problem. You might want to give different replacement values depending
>> upon whether the numerator is positive, negative, or 0. There's
>> probably a more elegant approach, but three different WHERE's would
>> certainly be sufficient to cover those cases.
>>
>> For the floating point case, IDL fills in the relevant elements of
>> ratio with -Inf, Nan, or Inf, depending upon the sign of the
>> numerator, and I can't think of any better way of handling it than to
>> use precisely those value. If you need to use your result for further
>> computations where those values would be unacceptable, replace them,
>> with logic similar to the above, but using the FINITE() function.
>
> Shoot. I was hoping for an elegant solution. :-(

For something like this, the Fortran WHERE construct is teeny bit more elegant, e.g.

real, dimension(100,100) :: ratio, numerator, denominator
....
where (abs(denominator) > 0.0)
ratio = numerator/denominator
elsewhere
ratio = -999.9
end where

I like the fact that I don't have to explicitly use any indices indicated where good or
bad values are.

Anyway....

cheers,

paulv
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Solarsoft and idlwave?
Next Topic: On the Coyote Path

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

Current Time: Wed Dec 03 01:52:29 PST 2025

Total time taken to generate the page: 2.72625 seconds