Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. C++ computational efficiency

C++ computational efficiency

Scheduled Pinned Locked Moved C / C++ / MFC
c++algorithmsquestion
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    Indrawati
    wrote on last edited by
    #1

    Hi I am currently building a time-critical app that requires a lot of computation functions, like sin(), log(), and sqrt(). I have two questions regarding this: 1. Is there an alternative way that is faster than using those functions? I am working on unsigned ints (32-bit) data, and building a lookup table would not be feasible, since there is no known boundary on the data. 2. Will C++ STL algorithm like for_each(), accumulate(), etc. make my app run faster than using traditional for loop? I am using VC++ 6.0 BTW, without STLPort. Thanks!

    P 1 Reply Last reply
    0
    • I Indrawati

      Hi I am currently building a time-critical app that requires a lot of computation functions, like sin(), log(), and sqrt(). I have two questions regarding this: 1. Is there an alternative way that is faster than using those functions? I am working on unsigned ints (32-bit) data, and building a lookup table would not be feasible, since there is no known boundary on the data. 2. Will C++ STL algorithm like for_each(), accumulate(), etc. make my app run faster than using traditional for loop? I am using VC++ 6.0 BTW, without STLPort. Thanks!

      P Offline
      P Offline
      Paul Ranson
      wrote on last edited by
      #2

      (1)The FPU can perform the basic sin/cos/ln functions in 'hardware' and therefore presumably quite quickly, more quickly than an integer based hand coded approach. So I suggest you convert your incoming fixed point data to floating, process it, then convert it back, examine the generated machine code and measure the performance. Only then explore the options. If you use the C library functions 'double sin( double )' etc then the compiler should generate inline FPU code. (2)I don't think you'll see a significant performance difference for or against with the STL algorithms, but their use should make the code cleaner. Paul

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups