Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

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 

  1. #{                                                                                                                                                                                                             
  2.     zeta = iota = 0;
  3.     for ( SRCFIRST ; SRCAVAIL ; SRCNEXT ) ##This is going to be vectorised shortly.                                                                                                                               
  4.       ## This code can't run yet ... I'm going to work out what SRCFIRST, SRCAVAIL, SRCNEXT are and                                                                                                               
  5.       ## replace them with what they should be in this context. I've kept them as reminders.                                                                                                                       
  6.       ot = o * SRCT; ## Same with SRCT ... I think it means what was originally set as Y. Macros?                                                                                                                 
  7.       zeta += cos(ot) * SRCX;
  8.       zeta -= sin(ot) * SRCX * i; ## More sure now. I don't think I can vectorise this ... who am I kidding?                                                                                                       
  9.       ot *= 2;
  10.       iota += cos(ot);
  11.       iota -= sin(ot) * i;
  12.     endfor
  13.     }#                                                                                                                                                                                                             
  14.     ## Commented out the converted-from-C code because it's replaced by the four lines below.                                                                                                                     
  15.     ## This method is an application of Equation 8 on page 6 of the text,                                                                                                                                         
  16.     ot = o .* t;
  17.     zeta = sum( ( cos(ot) .* x ) - ( sin(ot) .* x .* i ) );
  18.     ot = ot .* 2;
  19.     iota = sum( cos(ot) - ( sin(ot) .* i ) );

Paste Details

Tags: octave lssa

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.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



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.

worth-right