Designing a <i>custom datatype</i> (which turns out to be based on balanced <i>ternary trees</i>!) to implement <i>optimized FFT</i> evaluation -- absolutely brilliant, IMHO!<p>Related:<p><a href="https://news.ycombinator.com/item?id=38969053">https://news.ycombinator.com/item?id=38969053</a>
Balanced ternary is an odd choice for signed integers, when it seems like two's-complement integers would work just as well here. (That is, start with primitives 0 = ...00000 and -1 = ...11111, and construct 2x and 2x+1 from those.)