ILNumerics Ultimate VS

CellStorageIsTypeOfT Method

ILNumerics Ultimate VS Documentation
ILNumerics - Technical Application Development
Tests if a cell element is of the given array kind/element type.

[ILNumerics Core Module]

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

public bool IsTypeOf<T>(
	InArray<long> indices
)

Parameters

indices
Type: ILNumericsInArrayInt64
Dimensional indices defining the position of the cell element to be probed.

Type Parameters

T
The array element type to probe the cell element for.

Return Value

Type: Boolean
true if the element found at the given position is an array of the given element type T, false otherwise.
Remarks

The method is helpful in order to investigate the contents of a cell array. If you are not sure about the types of elements in the cell, this function can be used to make sure that elements actually are of the expected type before attempting to retrieve them.

In most situations, elements of a cell are stored arrays of a distinct element type. That element type is given to IsTypeOfT(InArrayInt64) as typeparameter T. That means, in order to find out, if the first cell element stores an array of int cell.IsTypeOf<int>(0) is used.

In order to test for cell element type T can be Cell or BaseArray: cell.IsTypeOf<Cell>(0).

In order to test for logical element type T must be Boolean: cell.IsTypeOf<bool>(0).

[ILNumerics Core Module]

Examples

In the following example a Cell of size 3x2 is created. It stores several array types, among which other cells are stored as elements of the outer cell.

Cell cell = ILMath.cell(new Size(3, 2) 
                                 , "first element"
                                 , 2.0
                                 , ILMath.cell(Math.PI, 100f)
                                 , ILMath.create<short>(1, 2, 3, 4, 5, 6)
                                 , new double[] {-1.4, -1.5, -1.6});
The cell is now:
Cell [3,2]
                     <String>      first element  <Int16> [2,3,4,5,6] 
                     <Double>          2          Cell [1,3]           
                     Cell [2,1]                                    (null)
We test the element type of each element in the cell:
Console.Out.WriteLine("cell[0,0] is of type 'string': {0}", cell.IsTypeOf<string>(0));
Console.Out.WriteLine("cell[0,0] is of type 'double': {0}", cell.IsTypeOf<double>(0));

Console.Out.WriteLine("cell[1,0] is of type 'double': {0}", cell.IsTypeOf<double>(1));
Console.Out.WriteLine("cell[2,0] is of type 'Cell': {0}", cell.IsTypeOf<Cell>(2));

Console.Out.WriteLine("cell[0,1] is of type 'short': {0}", cell.IsTypeOf<short>(0, 1));
Console.Out.WriteLine("cell[1,1] is of type 'Cell': {0}", cell.IsTypeOf<Cell>(1, 1));
Console.Out.WriteLine("cell[2,1] is of type 'double': {0}", cell.IsTypeOf<double>(2, 1));
This gives the following output:
cell[0,0] is element type 'string': True
cell[0,0] is element type 'double': False
cell[1,0] is element type 'double': True
cell[2,0] is element type 'Cell': True
cell[0,1] is element type 'short': True
cell[1,1] is element type 'Cell': True
cell[2,1] is element type 'double': False  (element is null)
See Also

Reference