Monday, January 5, 2009

How to Speed Up Octave

Speed seems like a continuing theme on the Octave mailing lists, a recent thread on the list of "comparing the executive speed with Matlab" demonstrates that there really is very little speed overhead when you use Octave smartly. If you read down far enough, it also demonstrates that the Intel Fortran compiler is awesome!

There are four basic methods of speeding up a chunk of Octave code (in order of increasing speed):
  1. Allocate memory smartly (using for loops)

  2. Vectorize your code (avoiding for loops)

  3. Use sparse matrix operators in place of for loops you can't vectorize

  4. Write a compiled function in C/C++/Fortran to call from Octave

The first three options keep you in pure Octave. The fourth option, while requiring you to use a compiled language is really not too bad because you can use all of the types (vectors, matrices, etc) defined in the Octave libraries to write your function. That's almost as easy as doing it in Octave.

Speeding Up For Loops

This one really amounts to not being foolish. The only way to speed up for loops is to make sure you allocate all of your memory (using zeros() for instance) before you enter the for loop. The Octave Manual covers this topic here. The better thing to do is vectorize your code and avoid for loops all together.


What you really want to do is cast your calculation as a series of vector and matrix operations, or use the built-in (usually compiled) functions that operate directly on vectors. The post Is Octave Slow? demonstrates the sorts of speed up you can get when you get rid of for loops.

Sparse Matrices for Data Dependancy

What about for loops you can't vectorize? The ones where the result at iteration n depends on what you calculated in iteration n-1, n-2, etc. You can define a sparse matrix that represents your for loop and then do a sparse matrix solve. This is much faster because you are now using compiled functions. The drawback is that you are trading some increase (sometimes substantial) in memory usage to buy this speed up.

Compile It

The manual has a good intro on using mkoctfile to compile your function and make it callable from Octave. Probably the most useful thing is that you can use the Octave types, so you don't have to code up your own matrix or vector type. At this point the speed really has little to do with Octave and everything to do with the quality of the compiler you use and how efficiently you code up your calculation.


The real power of Octave isn't that you can get your calculations to be nearly as fast as if you wrote them all in a compiled language. It's that you can prototype a calculation quickly and make sure that it is correct, and then there is a fairly well defined path to follow to speed up your correct calculation.


  1. I got this request for help on speeding up a moving average calculation by email recently.

    > The original problem is
    > for j=2:length(data)
    > a(j) = a(j-1) + alpha*(data(j)-a(j-1));
    > endfor
    > Now after creating A as a sparse matrix, given the original above,
    > what is "b" in your equation "x = A\b"?
    The way I do it is to think of each iteration of the loop as an equation (see this post).

    Writing out your loop I get a (alpha - 1) on the sub-diagonal, and a 1 on the main diagonal. I get an alpha*d(j) on the right-hand side, so that's your b.

  2. tips remove scars photoshop Prior to deciding to get started painting, It is also a good idea to lookup in the choices Bar and Verify to be sure that the Method option (small for Blend Manner) for the comb Device is ready to Standard, Opacity is set to a hundred% and Circulation is also established to 100%.

    This tutorial will explain to you the workflow to convey back again misplaced aspects and make an expert looking impression.

  3. How to make a wedding slideshow iSkysoft 2017
    MotionYou can use the movement graphics tool to title video clips and to make together with edit motion graphics.

    An acceptable illustration of your requested resource could not be located on this server. This mistake was created by Mod_Security.


  4. Photoshop cs3 download
    Mr. Stacks : develop storyboards and displays in couple of easy measures. Just pick out your illustrations or photos, presentation dimensions and structure which plug-in will immediately organize your file in various web pages or as a suitable storyboard.

    Material Informed Fill increases Photoshop's capability to intelligently switch Portion of a picture with pixels derived from other, nearby shades, noise, and tone.

  5. Adobe CS3 free download full version

    Previously people have really skilled their photos becoming modified to precisely what they're not completed in the job of Adobe Photoshop. Pictures as well as photos established in it are generally used by Adobe Website Maker.

    Connection to the internet and registration are essential for necessary software package activation, validation of subscriptions, and access to on the web services


  6. Screenshot on Samsung Galaxy On7 Pro
    And for the Senate, lawmakers of both of those events bemoaned the further more erosion in their traditions of bipartisanship and consensus. Trump usually takes up well being treatment with Rand Paul, on golfing program

    Highlighting this sort of mobile technical specs combined with the greatest cost in India and product pics, this Samsung touchscreen cellular price record aims to get a buyer's handbook for Samsung touchscreen phones. Filters around the remaining in addition user assessments on Every single mobile will further more enable you select the right cell. Sellers could be online or close by offline sellers like Snapdeal, eBay or TheMobileStore


  7. Just how much home can I afford to pay for?Home finance loan calculatorRefinance calculatorCost of residing calculatorDown payment calculator

    you can view my profile:

    On line quote equipment assist you get a quick snapshot of prospective premiums from quite a few automobile-insurance firms without delay.


  8. The best toothpaste has fluoride to prevent cavities plus extras to target other dental difficulties. Here's what to look for.

    you can view my profile:

    Much more address now incorporated as standard. Life time guarantee on repairs from an permitted network for providing you personal the vehicle. T&Cs apply.

  9. The thought of multi car or truck insurance is quite easy; insure multiple auto Using the exact same insurer to acquire a reduction. Best 10 Cheap Car Insurance

    To seek out several of the best auto retain the services of, extra providers we checked out buyer testimonials of organizations mentioned by car or truck employ the service of extra comparison website Moneymaxim.

  10. how get best cheap car insurance in 2017, The business also provides selling price breaks for other plan combos Which may include things like bike insurance, boat insurance, or many different kinds of specialty insurance.

    Focus on your well being. Although some wellness disorders are out of the Command, you might be able to protected cheaper charges for those who’re capable to lose fat, lower your blood pressure level, or get chronic overall health disorders beneath Command.

    For more info please click here:


    Remember the fact that there are various different factors that go into your high quality charge, so no two motorists are precisely the same. We did account for this in our comparison, by only evaluating noted rates from consumers who were very similar.

    When evaluating provides, make sure you assessment the economic institution’s Stipulations. Pre-certified offers are not binding. If you discover discrepancies with the credit rating score or details from the credit rating report, remember to Make contact with TransUnion® straight.

  12. punch in a few basic details and you have probably the most economical vehicle insurance quotations inside seconds.
    Our Evaluation located that based upon where you live, the price of insuring a car or truck can range really greatly from company to organization. This is certainly why to get minimal premiums, consumers ought to store all over and compare rates.

  13. AARP® provides third party insurance to its associates. Should you be an AARP member or wish to be a person ($sixteen once-a-year rate) you may want to think about acquiring your vehicle insurance by them to make use of the good discounts and solid insurance goods. Auto insurance from AARP is underwritten with the Hartford, which ranks very in client fulfillment rankings.

    As we mention previously mentioned, Nationwide was the top enterprise in California for cheap car insurance. The large automobile insurance company even bested generally cheap insurers like GEICO and Progressive. In the majority of towns that we surveyed during the Golden State, Nationwide was the go-to business for inexpensive charges.

  14. 12
    Windows Software Download

    10:12 AM (1 hour ago)

    to me
    To start with, you’ll must work out the full price of changing your private home inside the party of a total decline. Here is the sum it could Value to rebuild your home in precisely the same location utilizing very similar supplies to Whatever you now have at prevailing labor expenses. This amount may very well be vastly distinctive than your house’s current market benefit, specialists warn. Knowledgeable estimate can help in the event you’re Uncertain.

    The cost of 23 of the commonest car areas are also regarded. The lessen the cost of the areas, the lower the car insurance group might be. To find the greatest car or truck insurance quotes the price of the areas will need to be reasonably small.

  15. how to find Best 10 Cheap Car Insurance in 2017The best way a business treats its consumers states a whole lot regarding their enterprise, and RV insurance isn't any distinctive. Be sure you select an organization having a confirmed track record of customer service excellence.

    The one major variable impacting the price of an auto insurance quote is driving background. Automobile insurance firms get started their evaluation of future prospects by on the lookout back at their driving record for things like accidents, site visitors violations, or earlier insurance statements. The insurance firm can make the belief that a bigger amount of detrimental experiences equates to the next volume of hazard and therefore charges a higher premium for insurance coverage.
    usa Best 10 Cheap Car Insurance in 2017
    how to find Best 10 Cheap Car Insurance in 2017

  16. Cheap Car Insurance in 2017 You may think a third party only plan is the cheapest choice but weigh up all of the positives and negatives – you could be surprised at which features superior worth. Certainly, the only real way to actually really know what’s very best, is to compare – which you'll be able to do proper here (Blessed you) so, for all your vehicle insurance needs – simples. 

    §Lower price varies by point out and is only available to new Progressive Immediate automobile shoppers who qualify for electronic signature and indicator on line. Price reduction relates to initial coverage time period only. E-signal discounted not accessible in CA, GA, and NC.

    View our blog:

  17. how to Best 10 Cheap Car Insurance in 2017 Want to Reduce fees although not corners? Learn the way to save lots of on your car insurance and access discount rates for 2017.

    free Best 10 Cheap Car Insurance in 2017, In the event you’re a driver under the age of twenty five, or possibly a P-plater, so you’re trying to find the a discount on car insurance, it’s an regrettable incontrovertible fact that you won't uncover it. More youthful and fewer expert drivers usually pay extra for car or truck insurance than older drivers.
    View our blog:

  18. auto Insurance Although mainly called the biggest lifetime insurance enterprise in the U.S., MetLife also offers residence and car procedures. It gets good marks for benefit across the board, but vehicle-insurance customers are especially pleased with pricing.

    Cheap Insurance, Take into account bundling your insurance policies. Some insurance providers will give you a substantial discount if you buy more than one coverage, or “bundle” your procedures alongside one another. auto Insurance.

    View my profile:


  19. Read more: Subject to availability subsequent a sound assert. Standard three doorway one litre handbook auto offered for as many as fourteen days even though our accredited community repairs the vehicle or the car is declared a total reduction. Terms, conditions, exclusions and restrictions use. Receive a motor vehicle insurance estimate Plus you also get these Gains with Swiftcover car or truck insurance: Award winning customer service Automobile insurance quotes in double swift time online Your choice of canopy choices for extra peace of mind Motor vehicle insurance certificate ready to print devoid of expecting the submit Individual account to keep your paperwork Risk-free in one location on the net No admin fees once you update your details you on the internet Obtain a auto insurance quotation > *A part of Swiftcover comprehensive car insurance.
    Read more:

    Adhering to an auto accident, 2 hrs tuition by having an AA driving instructor that can help regain your self confidence

    If you want us, we’re here. You’ll obtain solutions to our most frequently questioned inquiries within our customer treatment area. And whether or not you prefer e-mail, social websites, webchat or perhaps the telephone, there are lots of tips on how to Speak to us.
    Read more:

  20. We use cookies to produce you With all the best practical working experience. By making use of our Net-site you conform to our utilization of cookies in accordance with our Cookie Coverage
    View my profile:
    We are committed to supplying incredibly minimal down payments choices, and our payment solutions Present you with General adaptability in picking a payment agenda. Plus we provide each of All those 12-30 day interval and six-thirty day period processes, In combination with every month payment ideas for all buyers.


  21. All people enjoys a freebie - so Why don't you snap up one particular of those pizza deals we have noticed, valid during June 2017, just before It is too late?!|What is actually actually cheaper - cut price supermarkets or shopping online: Two savvy mums go face to face to learn|Erie returned the cheapest ordinary quote, around $46 a month. This was reduce when compared to the cheapest estimate forever drivers half that age who set a day-to-day commute about the odometer.|When analyzing gives, please overview the financial establishment’s Terms and Conditions. Pre-skilled gives aren't binding. If you discover discrepancies using your credit history score or info from a credit rating report, please Speak to TransUnion® instantly.|Associates of your family can take pleasure in the reductions of approximately 25% after they get a policy When you. This insurance provider supplies hole insurance to include the primary difference on your vehicle personal loan after a generate off. Your premiums won't go up soon after your first incident. Nationwide has pretty good purchaser fulfillment scores, and If you're suitable with the discounts provided, you will get superior benefit for your cash.|Irrespective of dire warnings, just one major metropolis during the place has witnessed house charges slide from the calendar year Because the UK voted to go away the ecu Union|The new notes are actually in circulation - but some serial numbers are attracting sky-large price ranges. This is how to identify a special fiver|The cheapest Pennsylvania auto insurance price tag we uncovered for motorists with one at-fault crash was over $two hundred bigger than the lowest charge for motorists of a similar age without any incidents.|Which means they are going to up your top quality based upon age, sexual intercourse, occupation, submit code and in which you park park and also Whatever you push.|Insurers have long gone in terms of working out surgeons Usually have far more mishaps the place they ended up accountable than another job and building Modern society clerks the fewest. They know Virgos ended up worst for mishaps previous yr, but Pisceans had far more convictions.|Chester credited his wife of 12 a long time with creating him confront his demons - and wrote Give Me Your Name for his model wife|Should you’re seeking cheap car or truck insurance in Pennsylvania, searching all over is vital. Charges for the same coverage alternatives can swing substantially from a person insurance provider to the next, so it pays to match as lots of quotes as possible.|From Really like Island t-shirts to personalised mobile phone conditions, This is the Really like Island products that everyone desires to get their arms on|Advertiser Disclosure: So how can we generate profits? We receive payment from our associates when an individual applies or will get authorised for just a economical products by way of our web site. But, the results of our applications (like our charge card comparison Device) and editorial evaluations are depending on quantitative and qualitative assessments of product functions — nothing at all else.}

    If you’re an active member on the military services or perhaps a veteran — or have a direct loved one that's — you’ll most likely uncover rather reduced premiums with USAA, a possibility that isn’t available to the public.

    Element of the Volkswagen group, the Skoda Citigo is in car or truck insurance team one as a result of its reduced value and reliable engineering. The Skoda Citigo is often a compact but roomy three-doorway town car, made to be simple to generate and park on occupied metropolis streets.

    View my profile: