Advertising
Paste Description for Loop versus Vector
Two implementations of the same function, one as a loop and the other as a vector. Note how much lighter the vector is.
- Loop versus Vector
- Wednesday, May 23rd, 2012 at 8:43:14pm MDT
- #{
- zeta = iota = 0;
- for ( SRCFIRST ; SRCAVAIL ; SRCNEXT ) ##This is going to be vectorised shortly.
- ## This code can't run yet ... I'm going to work out what SRCFIRST, SRCAVAIL, SRCNEXT are and
- ## replace them with what they should be in this context. I've kept them as reminders.
- ot = o * SRCT; ## Same with SRCT ... I think it means what was originally set as Y. Macros?
- zeta += cos(ot) * SRCX;
- zeta -= sin(ot) * SRCX * i; ## More sure now. I don't think I can vectorise this ... who am I kidding?
- ot *= 2;
- iota += cos(ot);
- iota -= sin(ot) * i;
- endfor
- }#
- ## Commented out the converted-from-C code because it's replaced by the four lines below.
- ## This method is an application of Equation 8 on page 6 of the text,
- ot = o .* t;
- zeta = sum( ( cos(ot) .* x ) - ( sin(ot) .* x .* i ) );
- ot = ot .* 2;
- iota = sum( cos(ot) - ( sin(ot) .* i ) );
advertising
Update the Post
Either update this post and resubmit it with changes, or make a new post.
You may also comment on this post.
Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.