REPLICATE_INPLACE

Syntax | Arguments | Keywords | Examples | Version History | See Also

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.

Syntax

REPLICATE_INPLACE, X, Value [, D1, Loc1 [, D2, Range]]

Arguments

X

The array to be updated. X can be of any numeric type. REPLICATE_INPLACE does not change the size and type of X.

Value

The value which will fill all or part of X. Value may be any scalar or one-element array that IDL can convert to the type of X. REPLICATE_INPLACE does not change Value.

D1

An optional parameter indicating which dimension of X is to be updated.

Loc1

An array with the same number of elements as the number of dimensions of X. The Loc1 and D1 arguments together determine which one-dimensional subvector (or subvectors, if D1 and Range are provided) of X is to be updated.

D2

An optional parameter, indicating in which dimension of X a group of one-dimensional subvectors are to be updated. D2 should be different from D1.

Range

An array of indices of dimension D2 of X, indicating where to put one-dimensional updates of X.

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.

Examples

; Create a multidimensional zero array:
A = FLTARR( 40, 90, 10)

; Populate it with the value 4.5. (i.e., A[*]= 4.5 ):
REPLICATE_INPLACE, A, 4.5
;Update a single subvector.(i.e., A[*,4,0]= 20. ):
REPLICATE_INPLACE, A, 20, 1, [0,4,0]

; Update a group of subvectors.(i.e., A[ 0, [0, 5,89], * ] = -8 ):
REPLICATE_INPLACE, A, -8, 3, [0,0,0], 2, [0,5,89]

; Update a 2-dimensional slice of A (i.e., A[9,*, *] = 0.):
REPLICATE_INPLACE, A, 0., 3, [9,0,0] , 2, LINDGEN(90)

Version History

5.1

Introduced

See Also

REPLICATE, BLAS_AXPY