Replicates an array in an additional dimension by making copies of existing elements along that dimension.
Transformational function
The result is an array of rank rank(SOURCE)+1 and with the same type and type parameters as source.
If SOURCE is a scalar, the result is a one-dimensional array with NCOPIES elements, each with value SOURCE.
If SOURCE is an array, the result is an array of rank rank(SOURCE) + 1. Along dimension DIM, each array element of the result is equal to the corresponding array element in SOURCE.
If NCOPIES is less than or equal to zero, the result is a zero-sized array.
! A is the array (/ -4.7, 6.1, 0.3 /)
RES = SPREAD( A, DIM = 1, NCOPIES = 3 )
! The result is | -4.7 6.1 0.3 |
! | -4.7 6.1 0.3 |
! | -4.7 6.1 0.3 |
! DIM=1 extends each column. Each element in RES(:,1)
! becomes a copy of A(1), each element in RES(:,2) becomes
! a copy of A(2), and so on.
RES = SPREAD( A, DIM = 2, NCOPIES = 3 )
! The result is | -4.7 -4.7 -4.7 |
! | 6.1 6.1 6.1 |
! | 0.3 0.3 0.3 |
! DIM=2 extends each row. Each element in RES(1,:)
! becomes a copy of A(1), each element in RES(2,:)
! becomes a copy of A(2), and so on.
RES = SPREAD( A, DIM = 2, NCOPIES = 0 )
! The result is (/ /) (a zero-sized array).