-
Notifications
You must be signed in to change notification settings - Fork 14
Limited Fortran Intrinsics Library
Matt Norman edited this page Apr 29, 2022
·
4 revisions
YAKL contains a limited library of Fortran intrinsic functions. Currently, they include the functions below. All computations-based (e.g., not tiny
or epsilon
) intrinsics called on SArray
and FSArray
objects are done in serial and can be performed inside parallel_for
kernels. All computations-based intrinsics called on memDevice
Array
objects will invoke a kernel and cannot per performed inside parallel_for
kernels.
-
abs: Absolute value (element-wise) of an array
- Same as the Fortran intrinsic. Works on all
Array
,SArray
, andFSArray
objects.
- Same as the Fortran intrinsic. Works on all
-
all: Determines if all of the elements of a
bool
array aretrue
- Same as the Fortran intrinsic except without the optional
dim
argument. Works on allArray
,SArray
, andFSArray
objects.
- Same as the Fortran intrinsic except without the optional
-
allocated: Determines if an array has been allocated
- Same as the Fortran intrinsic. Works on all
Array
,SArray
, andFSArray
objects.
- Same as the Fortran intrinsic. Works on all
-
any: Determines if any of the elements of a
bool
array aretrue
- Same as the Fortran intrinsic except without the optional
dim
argument. Works on allArray
,SArray
, andFSArray
objects.
- Same as the Fortran intrinsic except without the optional
-
associated: Determines if an array has been allocated (same spirit as Fortran given different C++ semantics)
- Same as the Fortran intrinsic. Works on all
Array
,SArray
, andFSArray
objects. - Recall that with YAKL
Array
objects, there is little meaningful difference between allocated and associated.
- Same as the Fortran intrinsic. Works on all
-
count: Gives the number of
true
elements in abool
array- Same as the Fortran intrinsic except without the optional
dim
andkind
arguments. Works on allArray
,SArray
, andFSArray
objects.
- Same as the Fortran intrinsic except without the optional
-
epsilon: Gives machine epsilon for the floating point type of the array or scalar passed in
- Same as the Fortran intrinsic. Works on all
Array
,SArray
, andFSArray
, and scalar objects.
- Same as the Fortran intrinsic. Works on all
-
huge: Gives the largest representable value for the arithmetic type of the array or scalar passed in
- Same as the Fortran intrinsic. Works on all
Array
,SArray
, andFSArray
, and scalar objects.
- Same as the Fortran intrinsic. Works on all
-
lbound: Gives the lower bound of the array passed in
- Same as the Fortran intrinsic. Works on all
Array
,SArray
, andFSArray
objects. - For
styleC
Array
objects andSArray
objects: Without thedim
argument, this returns anSArray
object of rank 1. With the dim argument, zero-based indexing is expected. - For
styleFortran
Array
objects andFSArray
objects: Without thedim
argument, this returns anFSArray
object of rank 1 and lower bound of 1. With the dim argument, one-based indexing is expected.
- Same as the Fortran intrinsic. Works on all
-
matinv: Matrix inverse for small arrays using Gaussian Elimination
- This is not a Fortran intrinsic function, but it provides the inverse of square rank-2
SArray
andFSArray
matrix objects.
- This is not a Fortran intrinsic function, but it provides the inverse of square rank-2
-
matmul_cr and matmul_rc: Matrix multiplication using (column,row) and (row,column) format matrices
- Same as the Fortran intrinsic. Works on
SArray
andFSArray
objects only.FSArray
objects must have the default lower bounds of 1 to be accepated by these routines.
- Same as the Fortran intrinsic. Works on
-
maxloc and minloc: Index of maximum and minimum value in an array
- Same as the Fortran intrinsic without the optional dim, mask, kind, and back arguments. Only works on
Array
,SArray
, andFSArray
objects of rank 1. - When
-DYAKL_B4B
is turned on, device maxloc calculations are done serially on the host to preserve determinism
- Same as the Fortran intrinsic without the optional dim, mask, kind, and back arguments. Only works on
-
maxval and minval: Maximum and minimum value in an array
- Same as the Fortran intrinsic without the optional dim and mask arguments. Works on all
Array
,SArray
, andFSArray
objects.
- Same as the Fortran intrinsic without the optional dim and mask arguments. Works on all
-
merge: Merge two arrays based on a
bool
mask array- Same as the Fortran intrinsic. Works on all
Array
,SArray
,FSArray
, and scalar objects.
- Same as the Fortran intrinsic. Works on all
-
mod: Computes integer mod: a % b = a - ((int)(a/b) * b
- Same as the Fortran intrinsic.
-
pack: Packs an array into a single dimension with an optional mask.
- Same as the Fortran intrinsic without the optional vector argument and only for rank-1 arrays. Works for all rank-1
Array
objects. - Does not work on
SArray
andFSArray
objects because those require compile-time-known sizes, and the dimension sizes of the result of apack
operation cannot be known at compile time. - Calling
pack
on amemDevice
Array
leads to copying the inputs to the host, runningpack
on the host, and copying the results back to the device. This is because it is largely a serial operation.
- Same as the Fortran intrinsic without the optional vector argument and only for rank-1 arrays. Works for all rank-1
-
product: Computes the product over all elements of an array
- Same as the Fortran intrinsic without the optional dim and mask parameters. Works on all
Array
,SArray
, andFSArray
objects.
- Same as the Fortran intrinsic without the optional dim and mask parameters. Works on all
-
shape: Returns the shape an array as a rank-1 array of dimension sizes
- Same as the Fortran intrinsic . Works on all
Array
,SArray
, andFSArray
objects. - For
styleC
Array
objects andSArray
objects, this returns anSArray
object of rank 1. - For
styleFortran
Array
objects andFSArray
objects, this returns anFSArray
object of rank 1 and lower bound of 1.
- Same as the Fortran intrinsic . Works on all
-
sign: Applies the sign of the second argument to the first argument
- Same as the Fortran intrinsic . Works on all
Array
,SArray
, andFSArray
objects.
- Same as the Fortran intrinsic . Works on all
-
size: Gives the total elements of an array or the number of elements in a given dimension
- Same as the Fortran intrinsic . Works on all
Array
,SArray
, andFSArray
objects. - For
styleC
Array
objects andSArray
objects: Without thedim
argument, this returns anSArray
object of rank 1. With the dim argument, zero-based indexing is expected. - For
styleFortran
Array
objects andFSArray
objects: Without thedim
argument, this returns anFSArray
object of rank 1 and lower bound of 1. With the dim argument, one-based indexing is expected.
- Same as the Fortran intrinsic . Works on all
-
sum: Gives the sum of all elements in an array
- Same as the Fortran intrinsic without the optional dim and mask parameters. Works on all
Array
,SArray
, andFSArray
objects.
- Same as the Fortran intrinsic without the optional dim and mask parameters. Works on all
-
tiny: For floating point types, gives the smallest positive representable number. For integer types, gives the smallest overall representable number.
- Same as the Fortran intrinsic for floating point types. Works on all
Array
,SArray
, andFSArray
objects.
- Same as the Fortran intrinsic for floating point types. Works on all
-
transpose: Transposes a rank-2 matrix
- Same as the Fortran intrinsic. Works on all
Array
,SArray
, andFSArray
objects.
- Same as the Fortran intrinsic. Works on all
-
ubound: Gives the upper bound of the array passed in
- Same as the Fortran intrinsic. Works on all
Array
,SArray
, andFSArray
objects. - For
styleC
Array
objects andSArray
objects: Without thedim
argument, this returns anSArray
object of rank 1. With the dim argument, zero-based indexing is expected. - For
styleFortran
Array
objects andFSArray
objects: Without thedim
argument, this returns anFSArray
object of rank 1 and lower bound of 1. With the dim argument, one-based indexing is expected.
- Same as the Fortran intrinsic. Works on all