Clicky

Fortran Wiki
product (changes)

Skip the Navigation Links | Home Page | All Pages | Recently Revised | Authors | Feeds | Export |

Showing changes from revision #3 to #4: (追記) Added (追記ここまで) | (削除) Removed (削除ここまで) | (削除) Chan (削除ここまで)(追記) ged (追記ここまで)

Description

Multiplies the elements of array along dimension dim if the corresponding element in mask is true.

Standard

Fortran 95 and later

Class

Transformational function

Syntax

result = product(array[, mask])(削除) (削除ここまで)(追記)
(追記ここまで)
result = product(array, dim[, mask])

Arguments

  • array - Shall be an array of type integer, real or complex.
  • dim - (Optional) shall be a scalar of type integer with a value in the range from 1 to n, where n equals the rank of array.
  • mask - (Optional) shall be of type logical and either be a scalar or an array of the same shape as array.

Return value

The result is of the same type as array.

If dim is absent, a scalar with the product of all elements in array is returned. Otherwise, an array of rank n-1, where n equals the rank of array, and a shape similar to that of array with dimension dim dropped is returned.

Example

program test_product
 integer :: x(5) = (/ 1, 2, 3, 4 ,5 /)
 print *, product(x) ! all elements, product = 120
 print *, product(x, mask=mod(x, 2)==1) ! odd elements, product = 15
end program

See also

sum, note that an element by element multiplication is done directly using the star character.

category: intrinsics

Revised on September 4, 2010 09:25:48 by Jason Blevins (174.101.53.244) (1320 characters / 0.0 pages)
Edit | Back in time (3 revisions) | Hide changes | History | Views: Print | TeX | Source | Linked from: Intrinsic procedures, sum, norm2

AltStyle によって変換されたページ (->オリジナル) /