Path: csiph.com!weretis.net!feeder4.news.weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: Impact of implicit arrays... Supersedes: <2242853.oTKMxGqOJf@PointedEars.de> Followup-To: poster Date: Wed, 15 Jun 2016 06:55:26 +0200 Organization: PointedEars Software (PES) Lines: 68 Message-ID: <2043638.uQNA3CLBAW@PointedEars.de> References: <4a1c28ea-447b-4e9b-9c75-68ef85c379e7@googlegroups.com> Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: solani.org 1465966526 6163 eJwNycEBwCAIA8CVREiC41Qo+4/Q3vfgNJaCYGAwsbArfROaooWN9+mU+jm0W+r5fyHj1W2dDwieELw= (15 Jun 2016 04:55:26 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Wed, 15 Jun 2016 04:55:26 +0000 (UTC) User-Agent: KNode/4.14.2 Cancel-Key: sha1:rS1+1goWXsvQpcPwil40Gepa0eo= X-User-ID: eJwFwYEBwCAIA7CXBG0Z51CF/09Ygk3jjUPwYDDtJ0dlz5Ba80qNXo5RxOzxuEJatl19Er3o2Wt0yR1F/HpQFlM= Cancel-Lock: sha1:bZlIDb7oFV+MysqRHoyYhNnnPco= X-NNTP-Posting-Host: eJwNyrkBwCAMBLCVAvc4rION9x8BGlUSPJxBy1SrvZ04X+eqE4iRPycXiZdqqOq5A62CUp4XHKYQ3w== Xref: csiph.com comp.lang.javascript:30658 Chris M. Thomasson wrote: > Also, we can do this another way that involves an explicit > output parameter to the function. Something like: > _______________________________________ > function ct_complex_mul(c0, c1, out) ^^^ > { > out[0] = c0[0] * c1[0] - c0[1] * c1[1]; > out[1] = c0[0] * c1[1] + c0[1] * c1[0]; > > return out; > } > _______________________________________ > > > To call it in a loop could look like: > _______________________________________ > function foo_with_out() > { > var out = [0, 0]; > var z = [1, 1]; > var c = [2, 2]; > > for (var i = 0; i < 10; ++i) > { > out = ct_complex_mul(z, c); ^^ > z[0] = out[0]; > z[1] = out[1]; > } > } > _______________________________________ No, that would be pointless. In fact, the function SHOULD NOT *return* the changed value then. But this non-idempotent, non-reentrant code is not thread-safe – it is not suited for animations. >> Another thought is to switch to polar coordinates >> instead of Cartesian coordinates as it would simplify >> multiplication and division at least. With fractal based >> work this might be more intuitive anyway, yes? > > Right. However, I think that converting Polar into Cartesian > in order to add/subtract is the simplest route correct? Yes. UTSL. The “From” and “Reply-To” header fields of your postings are borked, see You should also avoid the troll server, aioe.org. Pseudo-address added to killfile. F'up2 poster -- PointedEars FAQ: | SVN: Twitter: @PointedEars2 | ES Matrix: Please do not cc me. / Bitte keine Kopien per E-Mail.