--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/2de28954-fccb-48f2-9374-950f3ba6d573n%40googlegroups.com.
but whereas you can read a component...real com.:=Real(cmplx)imaginary com.:=Imag(cmplx)i can't see any way to write to a component.
That's because Complex numbers are immutable - just like strings, and regular numbers for that matter.Hence to replace one component of a complex number, you have to create a new complex number.new_imag := 3.0
a = complex(real(a), new_imag)
yes, see the bench and code in the OP.
but since your way is slightly different (just possibly making a difference to the compiler? unpredictable eliding seems a poor thing to rely on.) i benched that, exactly the same, that is, about 5x slower than just operating on a single float. i'd look at the m/c, except at 500% slower i'm happy it can't be, maybe one day?i'm going to search for a lib. (if/when speed becomes a problem.)also unfortunate, complex not being a lib, that wouldn't just be a drop in.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/2b65ea5f-3fbd-440d-a6e0-400d61d6a3efn%40googlegroups.com.