The REPLICATE_INPLACE procedure updates an existing array by replacing all or selected parts of it with a specified value. REPLICATE_INPLACE can be faster and use less memory than the IDL function REPLICATE or the IDL array notation for large arrays that already exist.
Note: REPLICATE_INPLACE is much faster when operating on entire arrays and rows, than when used on columns or higher dimensions.
Examples
A = FLTARR( 40, 90, 10)
REPLICATE_INPLACE, A, 4.5
REPLICATE_INPLACE, A, 20, 1, [0,4,0]
REPLICATE_INPLACE, A, -8, 3, [0,0,0], 2, [0,5,89]
REPLICATE_INPLACE, A, 0., 3, [9,0,0] , 2, LINDGEN(90)
Syntax
REPLICATE_INPLACE, Array, Value [, D1, Loc1 [, D2, Range]]
Arguments
Array
The array to be updated. Array can be of any numeric type. REPLICATE_INPLACE does not change the size or type of Array.
Value
The value which will fill all or part of Array. Value may be any scalar or one-element array that IDL can convert to the type of Array. REPLICATE_INPLACE does not change Value.
D1
An integer indicating which dimension of Array is to be updated. All of the values changed will be in dimension D1.
Note: The D1 parameter is a one-based index; that is, the first dimension of the array is dimension 1, not dimension 0.
Loc1
An array with the same number of elements as the number of dimensions of Array. The Loc1 and D1 arguments together determine which one-dimensional subvector (or subvectors, if D2 and Range are provided) of Array is to be updated. The element of Loc1 that corresponds to the value of D1 is ignored.
For example, suppose you have a three-dimensional array of data. To update all elements in the subvector described by array[*,0,0]:
array = FLTARR(5,5,5)
REPLICATE_INPLACE, array, 98.6, 1, [0,0,0]
To change the same values using array syntax:
array[*,0,0] = 98.6
D2
An integer indicating in which dimension of Array a group of one-dimensional subvectors are to be updated. D2 should be different from D1. If D2 is present, the element of Loc1 that corresponds to the value of D2 is ignored.
Note: The D2 parameter is a one-based index; that is, the first dimension of the array is dimension 1, not dimension 0.
Range
An array of indices into dimension D2 of Array, indicating where to put one-dimensional updates of Array.
For example, suppose you have a three-dimensional array of data. To update all elements in the subvector described byarray[2,1:2,*]:
array = FLTARR(5,5,5)
REPLICATE_INPLACE, array, 3.14, 3, [2,0,0], 2, [1,2]
To change the same values using array syntax:
array[2,1:2,*] = 3.14
Keywords
Thread Pool Keywords
This routine is written to make use of IDL’s thread pool, which can increase execution speed on systems with multiple CPUs. The values stored in the !CPU system variable control whether IDL uses the thread pool for a given computation. In addition, you can use the thread pool keywords TPOOL_MAX_ELTS, TPOOL_MIN_ELTS, and TPOOL_NOTHREAD to override the defaults established by !CPU for a single invocation of this routine. See Thread Pool Keywords for details.
Version History
See Also
REPLICATE, BLAS_AXPY