Re: elemental function versus loop over function




Mark Morss napsal:
I have to perform a scalar function on each of the elements of a large
array. In general, for speed, does it matter much whether I loop over
the array or define an elemental function? One aspect of my problem is
that my array result depends not only on the input array, but on one or
two scalar inputs. So if I define an elemental function, before I can
call it with these arguments, my understanding is that I have to "blow
up" these scalars into constant-valued arrays of the same dimension as
my input array.
A scalar is conformable with any array; therefore, as long as the
additional
arguments are scalar, you can easily use an elemental function.

My preliminary assumption is that isn't worth doing this, and just
looping over the array is likely to be faster.
A compiler would indeed be quite dumb to spread scalars into
conformable
arrays first. Most likely you will see no performance difference
between these
two approaches.

.



Relevant Pages

  • Allow ELEMENTAL procedures with INTENT(IN) array arguments?
    ... The scalar arguments would still need to be ... and the shape of the RESULT of an ELEMENTAL function ... or a MODULE to get array data into an ELEMENTAL procedure if that data ... real, intent:: xpow! ...
    (comp.lang.fortran)
  • Re: elemental function versus loop over function
    ... the array or define an elemental function? ... So if I define an elemental function, ... my input array. ... All elements should be either conforming arrays or scalars. ...
    (comp.lang.fortran)
  • elemental function versus loop over function
    ... I have to perform a scalar function on each of the elements of a large ... In general, for speed, does it matter much whether I loop over ... the array or define an elemental function? ... my input array. ...
    (comp.lang.fortran)
  • Re: using fortran intrinsic functions in mex-file
    ... LOGICAL FUNCTION LSAME ... These programs must be called using F90 style array ... Scalar Arguments .. ... Purpose ...
    (comp.soft-sys.matlab)
  • [ANNOUNCE] New module Class::IntrospectionMethods
    ... access plain scalars, array, hash. ... These scalar, hash or array can ... object can be queried for the container object. ... parent object (the one constructed by Class::IntrospectionMethods ...
    (comp.lang.perl.modules)