Selects between two values, or corresponding elements in two arrays. A logical mask determines whether to take each result element from the first or second argument.
The result has the same shape and data type as TSOURCE and FSOURCE.
For each element in the result, the value of the corresponding element in MASK determines whether the value is taken from TSOURCE (if true) or FSOURCE (if false).
! TSOURCE is | A D G |, FSOURCE is | a d g |, ! | B E H | | b e h | ! | C F I | | c f i | ! ! and MASK is the array | T T T | ! | F F F | ! | F F F | ! Take the top row of TSOURCE, and the remaining elements ! from FSOURCE. RES = MERGE(TSOURCE, FSOURCE, MASK) ! The result is | A D G | ! | b e h | ! | c f i | ! Evaluate IF (X .GT. Y) THEN ! RES=6 ! ELSE ! RES=12 ! END IF ! in a more concise form. RES = MERGE(6, 12, X .GT. Y)