ILNumerics Ultimate VSInLogical  Conversion (Array to InLogical)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.3.7131.2749)

public static implicit operator InLogical (
	Array A


Type: SystemArray
System.Array of arbitrary size

Return Value

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

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.

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]


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

// convert from double[] array
Logical B = new double[] { 1, 2, 0, 4 };
//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 },
//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 }
//Logical[2, 3] True False ...
//[0]:  ▮ ▮ ▮
//[1]:  ▯ ▯ ▯
See Also