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

• stevenphy2
In summary, in order to take the power of elements of an array to a certain value (such as 5), you can use the syntax v = v**5, which will apply the power operation to each element of the array. This can be easily done in Fortran90, and it should not be troublesome to do it multiple times as the computer can quickly handle these computations."
stevenphy2
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?
I hope there is...
I have googled it quite a bit, but seems nothing useful.

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

1. How do I raise the elements of an array to the 5th power in Fortran90?

To raise the elements of an array to the 5th power in Fortran90, you can use the power function, which is denoted by "**" in Fortran. For example, if you have an array A, you can use the expression A**5 to raise all elements of A to the 5th power.

2. Can I raise each element of an array to a different power in Fortran90?

Yes, you can raise each element of an array to a different power in Fortran90. You can use a do loop to iterate through the array and raise each element to the desired power using the power function.

3. How can I take the power of elements in an array without modifying the original array?

In Fortran90, you can use the intrinsic function "POW" to take the power of elements in an array without modifying the original array. This function returns the result of raising the first argument to the power of the second argument.

4. Is there a way to take the power of elements in an array without using a loop in Fortran90?

Yes, you can use the "POW" function to take the power of elements in an array without using a loop in Fortran90. This function can operate on entire arrays, so you can pass in the array and the desired power as arguments, and it will return the result as a new array.

5. How can I take the power of complex numbers in an array in Fortran90?

In Fortran90, you can use the "CPOW" function to take the power of complex numbers in an array. This function takes in the array of complex numbers and the desired power as arguments and returns the result as a new array of complex numbers.

• Engineering and Comp Sci Homework Help
Replies
43
Views
4K
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
• Programming and Computer Science
Replies
2
Views
1K
• Programming and Computer Science
Replies
16
Views
2K
• Engineering and Comp Sci Homework Help
Replies
7
Views
2K
• Programming and Computer Science
Replies
17
Views
2K
• Computing and Technology
Replies
2
Views
792
• Programming and Computer Science
Replies
11
Views
2K
• Programming and Computer Science
Replies
13
Views
3K
• DIY Projects
Replies
19
Views
2K