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

Click For Summary
SUMMARY

To raise the elements of an array to a power in Fortran90, the operation can be performed using the syntax v = v**5, where v is the array. This operation applies the power function element-wise, eliminating the need for loops. The discussion confirms that Fortran90 has built-in capabilities for such operations, making it efficient for large computations without significant performance concerns.

PREREQUISITES
  • Understanding of Fortran90 syntax and operations
  • Familiarity with array manipulation in Fortran90
  • Basic knowledge of mathematical operations in programming
  • Awareness of performance considerations in numerical computing
NEXT STEPS
  • Explore advanced array operations in Fortran90
  • Learn about vectorization techniques in Fortran for performance optimization
  • Investigate built-in mathematical functions in Fortran90 libraries
  • Study best practices for numerical computations in Fortran90
USEFUL FOR

Programmers, numerical analysts, and anyone working with scientific computing in Fortran90 who seeks to optimize array operations and enhance computational efficiency.

stevenphy2
Messages
10
Reaction score
0
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.
 
Physics news on Phys.org
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.
 
Hello,

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

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

Pete
 

Similar threads

Replies
43
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 16 ·
Replies
16
Views
3K
  • · Replies 45 ·
2
Replies
45
Views
2K
  • · Replies 13 ·
Replies
13
Views
7K
  • · Replies 17 ·
Replies
17
Views
4K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
Replies
7
Views
3K