q.js icon indicating copy to clipboard operation
q.js copied to clipboard

Q.ComplexNumber.fromString( n )

Open stewdio opened this issue 6 years ago • 3 comments

It’s kind of gross to see matrix definitions that include new Q.ComplexNumber( blah, blah ) rather than something simple like '-i'. Something like this within the Matrix constructor might be nice:

if( typeof n === 'string' ){

     n = Q.ComplexNumber.fromString( n )
}

But that means having to write Q.ComplexNumber.fromString( n )... So this issue is a note-to-self to write that!

stewdio avatar Jun 03 '19 23:06 stewdio

An alternative -- pass in an ordered pair (a, b) for the value a+bi.

marwahaha avatar Sep 18 '20 10:09 marwahaha

@marwahaha I’m confused: Are you suggesting something that differs from the way Q.ComplexNumber has worked from the beginning? (To create a complex number, call new Q.ComplexNumber( real, imaginary ).) I’m suggesting in addition to this existing functionality it would be nice to be able to pass a more human-readable String as an argument that would then be parsed into its correct components. And then Q.Matrix could take advantage of that as well: https://github.com/stewdio/q.js/issues/38

stewdio avatar Feb 04 '22 16:02 stewdio

Oh, I see the point here. Disregard my comment; thanks for clarifying.

marwahaha avatar Feb 08 '22 18:02 marwahaha