Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Fortran90 How to take the power of elements of an array to, say, 5?

  1. Dec 7, 2009 #1
    Hi all,
    as title, how to take the power of elements of an array to, say, 5?
    I know how to do it using loops, but would it be very troublesome if I have to do it a thousand times?
    Any ready made function in fortran90?
    I hope there is...
    I have googled it quite a bit, but seems nothing useful.
     
  2. jcsd
  3. Dec 7, 2009 #2

    Mark44

    Staff: Mentor

    I'm not very knowledgeable about what's in or not in Fortran90 libraries, but it's no more troublesome to do it in a loop that runs a thousand times than in one that runs five times. A computer CPU will happily do all these computations in a small fraction of a second. The code to do this would be very simple.
     
  4. Dec 16, 2009 #3
    Hello,

    If v is an array, you can write v=v**5

    The power operation will be applied element-wise to the array.

    Pete
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Fortran90 How to take the power of elements of an array to, say, 5?
Loading...