Transformational Intrinsic Function (Generic): Creates a replicated array with an added dimension by making copies of existing elements along a specified dimension.
Syntax
Results:
The result is an array of the same type as source and of rank that is one greater than source.
If source is an array, each array element in dimension dim of the result is equal to the corresponding array element in source.
If source is a scalar, the result is a rank-one array with ncopies elements, each with the value source.
If ncopies <= zero, the result is an array of size zero.
Compatibility
CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIB
Examples
SPREAD ("B", 1, 4) is the character array (/"B", "B", "B", "B"/).
B is the array (3, 4, 5) and NC has the value 4.
SPREAD (B, DIM=1, NCOPIES=NC) produces the array
[ 3 4 5 ]
[ 3 4 5 ]
[ 3 4 5 ]
[ 3 4 5 ].
SPREAD (B, DIM=2, NCOPIES=NC) produces the array
[3 3 3 3 ]
[4 4 4 4 ]
[5 5 5 5 ].
The following shows another example:
INTEGER AR1(2, 3), AR2(3, 2)
AR1 = SPREAD((/1,2,3/),DIM= 1,NCOPIES= 2) ! returns
! 1 2 3
! 1 2 3
AR2 = SPREAD((/1,2,3/), 2, 2) ! returns 1 1
! 2 2
! 3 3