Has anyone tested the efficiency of MERGE function?

Has anyone tested the efficiency of MERGE function?

REAL::X(100,5)
INTEGER::IS,K
IS=merge(MINLOC(X(:,K)),MAXLOC(X(:,-K)),K>0)

! its equivalent is

IF(K>0)THEN
   IS=MINLOC(X(:,K))
ELSEIF(K<0)THEN
   IS=MAXLOC(X(:,-K))
END IF

! but it seems the later has better efficiency.

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Did you mean to set a DIM argument for minloc and maxloc? Until the code does what you intend, talking about efficiency seems pointless.

The strength of MERGE is not for cases as complicated as array operations.  Performance would depend on the expansion of minloc and maxloc and whether the compiler is able to optimize without making temporary arrays.  The size you quote is marginal on whether vectorization would be useful, and that depends (with recent released ifort) on whether you have set the old_maxminloc.  What do your optreports say?

Leave a Comment

Please sign in to add a comment. Not a member? Join today