ILNumerics Ultimate VS

ScopeEnter Method (BaseArray, NullableArrayStyles)

ILNumerics Ultimate VS Documentation
ILNumerics - Technical Application Development
Begins an artificial scope block within a local function block.

[ILNumerics Core Module]

Namespace:  ILNumerics
Assembly:  ILNumerics.Core (in ILNumerics.Core.dll) Version: (5.5.7503.3146)

public static IDisposable Enter(
	BaseArray A,
	Nullable<ArrayStyles> arrayStyle = null


Type: ILNumericsBaseArray
Any input array, given as parameter for the current function. Input arrays are: InArrayT, InCell, and InLogical.
arrayStyle (Optional)
Type: SystemNullableArrayStyles
[Optional] The ArrayStyle valid within the scope block. A non-null value will be used within the scope block as current array style. Default: (null) the current ArrayStyle.

Return Value

Type: IDisposable
The new scope object.

The Scope class plays an important role for the ILNumerics memory management. When writing functions in ILNumerics, Scope is used to define blocks of artificial scopes for local function blocks. ILNumerics ensures that no memory is left as garbage after the scope block is left. Furthermore, it garantees that input arrays are kept alive during the execution of the block. By following these ILNumerics function rules ILNumerics is able to optimize the execution of the algorithm regarding execution speed and memory footprint.

If a value other than null is given for arrayStyle the value of ArrayStyle is modified for the operations within this scope block. After the scope is left, the old setting is reliably restored. If null is provided (default) the current setting of ArrayStyle is not touched.

[ILNumerics Core Module]


The examples demonstrates a custom function in ILNumerics. It demonstrates the use of distinct array types in the function declaration and the use of artificial scopes.

RetArray<double> FreqPeaks(InArray<double> inData, OutArray<double> freq = null, double sampFreq = 44.1) { 

                using (Scope.Enter(inData)) {    

                    Array<double> Data = check(inData); 
                    Array<double> retLength = min(ceil(Data.Length / 2.0 + 1), 5.0);   
                    Array<double> Window = stdWindowFunc(Data.Length);  
                    Array<double> magnitudes = abs(fft(Data * Window));  
                    magnitudes = magnitudes[r(0,end / 2 + 1)];  

                    Array<double> indices = empty();  
                    Array<double> sorted = sort(magnitudes, indices, descending:true);  
                    if (!isnull(freq)) 
                        freq.a = (sampFreq / 2.0 / magnitudes.Length * indices)[r(0,retLength-1)];  
                    return magnitudes[r(0,retLength-1)];  
See Also