Concisely describe the proposed feature
I would like to add some mathematical constants (e.g. ti.pi) to the language so that users can without handwriting PI = 3.1415926535897.
Describe the solution you'd like (if any)
Additional comments
Also ti.ln2 and ti.ln10 is important since we can simulate log2 and log10 by ti.log(x) / ti.ln2.
Also ti.log(x) * ti.inv_ln2 for faster computation? Btw, @xumingkuan, does our constant_fold convert var / const into var * (1 / const)? The latter is sightly faster, especially for vectors.
Actually #510 is not implemented yet, and our constant_fold's function is very limited...
I don't know if we convert var / const into var * (1 / const). To me, if we do convert, it should not be in the constant folding pass -- it's reducing computation burden like a * 2 -> a + a (which we do convert in my memory) does.
Actually #510 is not implemented yet, and our
constant_fold's function is very limited...I don't know if we convert
var / constintovar * (1 / const). To me, if we do convert, it should not be in the constant folding pass -- it's reducing computation burden likea * 2 -> a + a(which we do convert in my memory) does.
Oh, I see, so we should make another pass before constant_fold? a / 0.5 -> a * 2 -> a + a.
Also should constant_fold do a * 2 * 3 -> a * 6?
Oh, I see, so we should make another pass before
constant_fold?a / 0.5 -> a * 2 -> a + a.
Yes, if we didn't.
Also should
constant_folddoa * 2 * 3 -> a * 6?
It should... But it doesn't do this now 馃槃
Thanks, but we can probably use math.pi or math.log(2), which will be constant folded during AST generation.