LabVIEW 2021 Public Beta

cancel
Showing results for 
Search instead for 
Did you mean: 

[Bug?] Why can't "in range and coerce" deal with complex numbers?

Obviously, this is not really a bug since it has been like that since the beginning of time. Still, it seems to be a glaring omission in functionality.

 

In range and coerce does not accept complex numbers and I wonder why that is and why this cannot be cured. Obviously I am missing something here.

 

Expected functionality: Let's take a simple complex number that we want to see if it is contained within a rectangular area of the complex plane. We apparently need to first extract RE and IM, test them individually, then merge them back together to complex. Tedious! Comparing both RE and IM seems to be the logical behavior and could simplify certain things (example). It would need to be implemented and documented in the help.

 

(OTOH, we could also compare them to DBL, in which case we check if r is within range. (probably not that useful and we would need to decide how to deal with e.g. negative limits since r is always positive).)

 

So, is there a fundamental reason why the function currently does not accept all complex inputs? If this cannot get extended internally, maybe a VIM would be a good solution.

 

 

altenbach_0-1621448461329.png

 

 

 

0 Kudos
Message 1 of 4
(1,310 Views)

I think comparing complex numbers is ambiguous?

 

Can a complex number ever be considered 'bigger' or 'smaller' than a real number, or vice versa? - M...

Can we compare two complex numbers? - Quora

 

Comparing Re and Im and combining the results is just one way to compare.

 

Of course, if the In Range And Coerce would compare like that, it would be more useful than simply breaking.

0 Kudos
Message 2 of 4
(1,260 Views)

Thanks. Yes, I agree that sorting complex numbers is not possible, but "in range" does not really rely on 1D sorting. The limits just define a rectangular area and even a three year old can tell if a given point is inside or outside.. Maybe I just make my own vim.

 

Of course we can also cast the complex input/limits to a suitable cluster or array and things would work just fine:

 

altenbach_1-1621522827543.png

 

 

 

altenbach_0-1621522478345.png

 

0 Kudos
Message 3 of 4
(1,249 Views)

The links mention that comparing 1 complex number is ambiguous. LabVIEW agrees:

Compare Complex.PNG

The In Range is 2 compares. Does that double (or square) the ambiguity, or eliminates it 🤔?

 

The way we use complex numbers a lot (as coordinates), it sure would be convenient if the In Range would treat complex numbers like that.

 

As a programmer I agree that it makes sense to limit it the way you propose, but mathematicians might not.

0 Kudos
Message 4 of 4
(1,230 Views)