public class TVecInt : TAbstractMtxVecInt
Class for one dimensional integer arrays.
Class for accessing and manipulating 8bit unsigned and 16 or 32 bit signed one dimensional arrays of integers and bits. Purpose of usage:
- leverage the SSEX/AVX instruction sets for integers
- take advantage of reduce storage size and fast bit (and, or, xor, not) operations
- provide basic (saturation) math support. Saturation math means that adding two integers whose result would be greater than the integer range will result in clipping of the result to the maximum value representable by the integer type.
- support for super-conductive object cache allows efficient multi-core threading of algorithms using this type.
- Pack and unpack bit arrays for much faster boolean processing.
The same object type can be used to work with three different integer types and integer precision is never changed implicitely. Mixing of different integer types or mixing with real types is not supported to avoid hidden cost of repeated conversions.
Examples
csharp
using Dew.Math;
using Dew.Math.Units;
namespace Dew.Examples
{
void Example()
{
TVecInt a = new TVecInt();
a.SetIt(new int[] {1,2,4,3});
a.SortAscending(); // a = 1,2,3,4
}
}
Properties
| Name | Type | Description |
|---|---|---|
| BitCount | Int64 | Allows sizing the internal storage to accomodate desired number of bits. |
| BlockEnd | Boolean | Returns true, if the currrent subrange of the vector was also the last subrange in the vector. |
| CacheIndex | Int32 | For internal use only. Read to get the index of this object in object cache. |
| Capacity | Int64 | Sizing the object will not allocate less than Capacity. |
| CapacityInBytes | Int64 | Sizing the object will not allocate less than CapacityInBytes. |
| CapacityInElements | Int64 | Sizing the object will not allocate less than CapacityInElements. |
| CapacityStep | Double | Specifies increment step for the Capacity property. |
| Caption | String | Caption. |
| ConditionCheck | Boolean | Enables/disable inline condition checking. |
| First | Int32 | First element in object Values array. |
| IntegerValues | String | Returns content as a string suitable for display as a tooltip. |
| IntPrecision | TIntPrecision | Defines internal storage precision which can be either 32, 16 or 8 bit. |
| IntPrecisionLock | Boolean | Prevents change to IntPrecision if Lock = True. |
| IsDouble | Boolean | Defines the precision (single or double) of the floating point operations. |
| IsSubRange | Boolean | Set to true after the SetSubIndex or SetSubRange call. |
| Item | Int32 | Allows setting/getting the integer value at position Indx. |
| Last | Int32 | Last element in object Values array. |
| Length | Int32 | Defines the length in number of samples. |
| OnSetSize | TMtxNotifyEvent | Called when object size changes. |
| PoolIndex | Int32 | Internal. |
| ScaleFactor | Int32 | Specifies the power of two for the scale factor used by some methods. |
| Tag | Int32 | Stores an integer value as part of a TMtxVec object. |
| ValuesSerialization | String | Provides serializatin of object content. |
Methods
| Name | Description |
|---|---|
| Abs (4) | Absolute values. |
| Add (12) | Add Src elements to calling vector elements. |
| AddAndMul (26) | Compute (X + Y)*Z |
| AddScaled (10) | Compute X + Y + Z*zScale |
| AddScaledC (4) | Compute X + Y*yScale + zScalar |
| AddScaledSqr (4) | Compute sqr(X + Y*yScale) |
| BinaryAnd (8) | Apply binary "and" between coresponding elements in Src and Self. |
| BinaryNot (4) | Applies binary "not" operation to elements stored in the object. |
| BinaryOr (8) | Apply binary "or" between coresponding elements in Src and Self. |
| BinarySearch (2) | Finds a match for X in object values using binary search. |
| BinaryXor (8) | Apply binary "xor" between coresponding elements in Src and Self. |
| BitPack (2) | Packs integer storage vector to bit storage. |
| BitShift (4) | Apply binary shift by number of Bits to the left (positive) or right (negative) to elements in Src. |
| BitShiftLeft (4) | Apply binary shift by number of Bits to the left to elements in Src. |
| BitShiftRight (4) | Apply binary shift by number of Bits to the right to elements in Src. |
| BitUnpack (2) | Unpacks bit storage to specified integer storage. |
| BlockFinish | Deinitializes block processing before the final block is processed. |
| BlockInit (3) | Initializes block processing. |
| BlockNext | Obtains the next subrange of the data. |
| BlockSubRangeLevel | Returns the current subrange stack level used by block processing functions. |
| Clear | Sets size to 0 and releases associated memory. |
| Concat (2) | Concatenates an array of TVecInt objects. |
| CondDisable | Saves the current value of ConditionCheck property and sets it to false. |
| CondEnable | Sets the ConditionCheck property to whatever it was before the CondDisable was used. |
| Convert (2) | Copy each of Vec elements to the calling object. |
| Copy (2) | Copy object values. |
| CopyFromArray (14) | Copies values from a real Src array. |
| CopyToArray (16) | Copies values from the calling object to the Dst array and converts data to complex double precision numbers. |
| CountInRange (2) | Returns number of values within the interval. |
| ctor | |
| CumSum (4) | Cumulative sum. |
| Diag | Copies the k-th diagonal from the TMtxInt object. |
| Difference (3) | Calculate the difference for all Vec elements. |
| DisableSelect | Prevents calls to Dew.Math.TMtxVecBase.Select. |
| DisableSubrange | Prevents calls to Dew.Math.TMtxVecBase.SetSubRange. |
| Distinct | Stores distinct values from Src in to Dst. |
| DivAndAdd (12) | Compute X/Y + Z |
| DivAndSub (12) | Compute X/Y - Z |
| Divide (12) | Divide calling object elements with Src elements. |
| DivideBy (4) | Divide Value with calling vector elements. |
| DivideC (2) | Compute X / (Y*zScale) |
| EnableSelect | Enables calls to Dew.Math.TMtxVecBase.Select. |
| EnableSubrange | Enables calls to Dew.Math.TMtxVecBase.SetSubRange. |
| Find | Finds a match for X in object values. |
| FindAndGather (2) | The b parameter is of Dew.Math.TMtxVecInt type. |
| FindIndexes (2) | Finds matching indexes. The b parameter is of Dew.Math.TMtxVecInt type. |
| FindIndexesAndLength (2) | Finds matching indexes and returns their count. The b parameter is of Dew.Math.TMtxVecInt type. |
| FindMask (2) | The b parameter is of Dew.Math.TMtxVecInt type. |
| FreeToCache | Releases this object back to cache. |
| Gather | Gather vector elements. |
| GatherByIncr | Gathers elements from X starting at Offset and with Increment to the calling object. |
| GatherByIndex | Gathers elements from X specified by indices stored in Indexes the calling object. |
| GatherByMask | Gathers elements from X specified by non-zero values stored in the Mask to the calling object. |
| GetCol (3) | Copies a column from matrix. |
| GetObjectToByteArray | Copies object to an array of bytes. |
| GetRow (3) | Copies a row from matrix. |
| GetSchema | Returns null. |
| GroupCount | Counts groups of equal numbers within Bins. |
| GroupCountIteration | Counts groups of equal numbers within Bins. |
| IsEqual (4) | Compares all Vec elements with calling object elements and checks also Length and IntPrecision properties, if they match. |
| IsPinned | Returns true of the working memory is pinned. |
| LoadFromFile | Reads the header information and the values array content from the file. |
| LoadFromStream | Load the list from a stream. |
| LogicalNot (4) | Applies logical "not" operation to elements stored in the object. |
| Max (4) | Maximum value. |
| MaxEvery (4) | Vectorised maximum. |
| MaxMin (2) | Calculate minimum and maximum in one procedure call. |
| MaxMinIdx (2) | Calculate minimum, maximum and their indices in one procedure call. |
| Median (6) | Applies median filter with size Mask to data in Src and stores the result in the calling vector. |
| Min (4) | Minimum value. |
| MinEvery (4) | Vectorised minimum. |
| Mul (4) | Compute X*Y*Z |
| MulAndAdd (14) | Compute X*Y + Z |
| MulAndDiv (6) | Compute X * Y / Z |
| MulAndSub (14) | Compute X*Y - Z |
| Multiply (8) | Multiply Src elements with calling vector elements. |
| Parse | Parses string content as vector. |
| PBValues | Obtains a pointer to the 8bit unsigned integer value of the vector at Index. |
| Pin | Pin down internal data structures for GC. |
| PIValues | Obtains a pointer to the 32bit signed integer value of the vector at Index. |
| PSValues | Obtains a pointer to the 16bit signed integer value of the vector at Index. |
| PValues | Obtains a pointer to the integer value of the vector at Index. |
| Ramp (3) | Fills the calling vector with a series following linear rule. |
| RandomRamp | Fills the calling vector elements with linear rule and randomly shuffles the indexes. |
| RandomShuffle | Randomly shuffles the content of the vector. |
| ReadHeader | Reads the header information from a stream to object. |
| ReadValues | Read values content from stream to object. |
| ReadXml | Read the object from the .NET XML stream. |
| RemDiv (6) | Divide all Src elements with Value elements and store result of division in the calling object and reminder in RemDst. |
| Reset | For internal use only. Used to return object to cache. |
| Resize (2) | Resizes vector size while preserving values. |
| Reverse (4) | Reverse vector elements. |
| Rotate (4) | A cyclic shift on vector elements in range. |
| SaveToFile | Write object header and values to a file. |
| SaveToStream | Save the list to a stream. |
| Scatter | Scatter object elements. |
| ScatterByIncr | Scatters Src elements starting at Offset and with Increment to the calling object. |
| ScatterByIndexes | Scatters Src elements defined with indices stored in Indexes to the calling object. |
| ScatterByMask | Scatters Src elements defined with the Mask to the calling object. |
| Select (2) | Resets the selection. |
| SelectAll | Resets any defined selection. |
| SetFullRange | Resets subrange defined with SetSubRange. |
| SetFullRangeLevel | Pops the current subrange stack one level up. |
| SetIt (2) | Sets object values. |
| SetObjectFromByteArray | Reads the properties of the object from the array of bytes. |
| SetSubIndex (2) | Defines a subarray. |
| SetSubRange (4) | Defines the calling vector to have the view of the same memory as Src. |
| SetSubRangeLevel (2) | Defines a sub vector/matrix of Src and pushes any previous subranges on to a stack. |
| SetVal (2) | Set all calling object elements to Value. |
| SetZero (2) | Set all calling vector elements to zero. |
| Shift (4) | Do a shift on vector elements in range. |
| Size (3) | Sets the size and storage precision of the calling object. |
| SizeFromArray (6) | Sets the size of the vector to match an array. |
| SizeToArray (8) | Sizes the array. |
| SortAscend (4) | Sort all calling vector elements in ascending order in-place. |
| SortDescend (4) | Sort all calling vector elements in descending order in-place. |
| SqrAddScaled (4) | Compute sqr(X) + sqr(Y)*yScale |
| StringsToValues (2) | Convert strings in srcList to integers. |
| Sub (4) | Compute X - Y - Z |
| SubAndMul (26) | Compute (X - Y)*Z |
| SubRangeLevel | Returns the current subrange stack level. |
| SubScaled (6) | Compute X - Y - Z*zScale |
| SubScaledC (4) | Compute X - Y*yScale - zScalar |
| Subtract (8) | Subtract all Src elements from calling vector elements. |
| SubtractFrom (4) | Subtract all calling vector elements from integer Value. |
| Sum (2) | Sums vector values. |
| ThreshAbsGT (4) | Perform threshold operation on all Src object values. |
| ThreshAbsLT (4) | Perform threshold operation on all Src object values. |
| ThreshBottom (4) | Perform threshold operation on all Src object values. |
| ThresholdGT_LT (4) | Threshold greater than and less than operation. |
| ThreshTop (4) | Perform threshold operation on all Src object values. |
| ToString | Returns content as a string. |
| UnPin | Unpin internal data structures for GC. |
| ValuesToStrings (2) | Converts the content of the Values array of the calling vector to a list of strings. |
| ValuesToText (2) | Convert all vector elements to text. |
| WriteHeader | Writes the header information for the calling vector to a stream. |
| WriteXml | Write the object to the .NET XML stream. |
Operators
| Name | Description |
|---|---|
| op_Implicit (3) | Implicit conversion from TVecInt to Span<Byte>. |
Events
| Name | Description |
|---|---|
| OnSetSizeEvent | Called when object size changes. |