ILNumerics Ultimate VS

Logical  Conversion (Array to Logical)

ILNumerics Ultimate VS Documentation
ILNumerics - Technical Application Development
Convert n-dimensional Array to ILNumerics array.

[ILNumerics Core Module]

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

public static implicit operator Logical (
	Array A
)

Parameters

A
Type: SystemArray
System.Array of arbitrary size

Return Value

Type: Logical
If A is null: empty array. Otherwise a new ILNumerics array of the same size as A.
Exceptions

ExceptionCondition
InvalidCastExceptionIf the type of the elements in A cannot get converted to Boolean.
NotSupportedExceptionif As elements are reference types and A is a multidimensional array.
Remarks

Elements of A will be converted to elements of the output array, where non-null elements (reference types) and '!= 0' values (value types) in A create 'true' values in the result. The following element types are supported for A: all IConvertible types (double, float, int, uint, long, ulong, short, ushort, sbyte, byte etc.), and reference types.

The resulting Array will reflect all dimensions of A. Due to the fact that .NET System.Arrays are stored in row major order the storage layout of the resulting Array will be RowMajor also. Elements of an one-dimensional A will be ordered along the first dimension of the result. Hence, one-dimensional input arrays will produce column vectors.

Convert is used for the conversion of elements in A to bool elements.

The current value of MinNumberOfArrayDimensions is considered. Its default value of 2 will cause a matrix to be produced, even though the input A may be a one-dimensional array.

[ILNumerics Core Module]

Examples

C# Code Example
// convert from bool[] array 
Logical A = new bool[] { true, true, false, true };
//A.T
//Logical[1, 4] True True ...
//[0]:  ▮ ▮ ▯ ▮

// convert from double[] array
Logical B = new double[] { 1, 2, 0, 4 };
//B.T
//Logical[1, 4] True True ...
//[0]:  ▮ ▮ ▯ ▮

// convert from 2dim float[,] array
Logical C = new float[,] {
 { 9, 9, float.MaxValue, float.NegativeInfinity },
 { 0, 0, float.NaN, 0 },
};
//C
//Logical[2, 4] True False ...
//[0]:  ▮ ▮ ▮ ▮
//[1]:  ▯ ▯ ▯ ▯

// convert from 2dim reference type array
Logical D = new[,] {
 { new object(), new Double() + 1, new List<object>() },
 { null, null, null }
};
//D
//Logical[2, 3] True False ...
//[0]:  ▮ ▮ ▮
//[1]:  ▯ ▯ ▯
See Also

Reference