Talk:Formal power series: Difference between revisions

m
signed
No edit summary
m (signed)
Line 7:
::::Is ''indirection'' mean the ''interface'' which called like a class? I think it is one of the D ways to do ''closure''. Actually I am still wondering how it work. -- [[User:Badmadevil|badmadevil]] 04:32, 6 April 2008 (MDT)
::::: It's the extra member ''term'' of type ''UT''. I don't understand D enough to say why you need an ''interface'', or if you need one at all. I only understand that the usual way to implement lazyness is to use such an extra variable. And yes, it's related to closures -- the call to a generator mentioned above can also be a closure. As I said, I don't understand D well enough, but it still doesn't look like I would expect it. In particular, you still seem to have the efficiency problem (try multiplying three series, and insert some debugging code that shows you when a coefficient gets calculated. You should see that the same coefficient gets calculated multiple times, which means a '''lot''' of times at higher numbered coefficients. --[[User:Dirkt|Dirkt]] 05:36, 6 April 2008 (MDT)
::::::The ''term'' is an interface, which as previously state, may think as a class object. In solving the efficiency problem, I think the interface can be expanded to a proper class object, which has at least 2 member function. One is the coefficient generator, other is cache function to access an cache array storage. The cache function will query the generator if the coefficient is not inside the cache array, and of course, after return from the generator, the cache array will be updated. It is a trade off of time and space. I will try to implement this structure later if not too complicated. -- [[User:Badmadevil|badmadevil]] 06:35, 6 April 2008 (MDT)
 
BTW, I only mentioned the rationals as a "nice to have" feature (because then you can immediately see if the coefficients for sine and cosine are correct). If you need an extra module that implements the rationals from scratch, and if you don't have arbitrary precision anyway, I personally would prefer ''double''s. The task leaves this detail unspecified on purpose. --[[User:Dirkt|Dirkt]] 05:36, 6 April 2008 (MDT)
:Yes, it is overkill to implement from scratch, it is strict forward though.-- [[User:Badmadevil|badmadevil]] 06:35, 6 April 2008 (MDT)