public struct Vector
Vector class for operator overloading (Delphi 2006 and later).
Declare Vector instead of TVec to take advantage of operator overloading in D2006 and later. Be carefull to declare Vector only for local variables with short lifetime. Call the Create method for Vector, if the variable is a global variable or a variable with a longer life. It also makes sense to continue to use TVec for global vars. If the Create method (constuctor) is not called, the Vector record obtains TVec object from object cache (fastest create). If the Create mehod is called, the TVec object is created in the usual way (slower). Object cache has limited size.
Examples
csharp
Vector b;
Vector c;
TVec bv;
b = Vector(TDoubleArray.Create(1,1,1,1));
b = new double[] {1,1,1,1}; //or like this
bv = b; // b and bv point to same data object
bv.Scale(2);
TVec(b).Scale(2); //an alternative way to scale
c = b*2 + Cplx(2,3); c = b*2 + 2 + 3i
c = b*bv; // mix Vector and TVec per element multiply
bv.Add(c); //pass Vector type and implicitely convert to TVec
Properties
| Name | Type | Description |
|---|---|---|
| Alfa | TCplx | Additional parameter for certain Lapack methods. |
| Beta | TCplx | Additional parameter for certain Lapack methods. |
| BlockEnd | Boolean | Returns true, if the currrent subrange of the vector was also the last subrange in the vector. |
| Capacity | Int64 | Sizing the object will not allocate less than Capacity samples. |
| CapacityStep | Double | Specifies increment step for the Capacity property. |
| Caption | String | Vector Caption. |
| Complex | Boolean | Defines if object values are complex. |
| ConditionCheck | Boolean | Enables/disable inline condition checking. |
| FFTOddLength | Boolean | Defines if FFT transform length is odd. |
| FFTScrambled | Boolean | Leave FFT scrambeled. |
| FFTStorageFormat | TFFTStorageFormat | FFT storage format. |
| First | Double | First element in object Values array. |
| Firstc | TCplx | First element in object CValues array. |
| FloatPrecision | TMtxFloatPrecision | Defines the precision (single, float) and type (real, complex) of the floating point operations. |
| IsSubRange | Boolean | Set to true after the SetSubIndex or SetSubRange call. |
| Item | Double | Allows setting/getting the real value at position Indx. |
| Last | Double | Last element in object Values array. |
| Lastc | TCplx | Last complex element in object CValues array. |
| Length | Int32 | Defines the length in number of samples. |
| Precision | TPrecision | Defines the precision used by streaming routines. |
| Rounding | TRounding | Defines the rounding used by streaming routines. |
| SubRangeLevel | Int32 | Returns the current depth of SubRange stack. |
| Tag | Int32 | Stores an integer value as a part of the object. |
| ZeroTolerance | Double | The tolerance used by Dew.Math.Vector.IsEqual. |
Methods
| Name | Description |
|---|---|
| Abs (4) | Absolute values. |
| Add (18) | Adds complex Value to all calling object complex elements. |
| AddAndMul (50) | Compute (X + yScalar)*zScalar |
| AddProduct (2) | Add a product of two vectors. |
| AddScaled (25) | Add each of Vec elements to corresponding elements in the calling object. |
| AddScaledC (8) | Compute X*xScale + Y*yScale + zScalar |
| AddScaledSqr (8) | Compute sqr(X*xScale + Y*yScale) |
| Adopt | Adopts TVec object. |
| ArcCos (4) | The inverse cosine. |
| ArcCosh (4) | Inverse hyperbolic cosine. |
| ArcCot (4) | Inverse cotangens. |
| ArcCoth (4) | Inverse hyperbolic cotangens. |
| ArcCsc (4) | Inverse cosecant. |
| ArcCsch (4) | Inverse hyperbolic cosecant. |
| ArcSec (4) | Inverse secant. |
| ArcSech (4) | Inverse hyperbolic secant. |
| ArcSin (4) | The inverse sine. |
| ArcSinh (4) | Inverse hyperbolic sine. |
| ArcTan (4) | Inverse tangens. |
| ArcTan2 (2) | Inverse tangens of Y/X. |
| ArcTanh (4) | Inverse hyperbolic tangens. |
| AutoCorrBiased | Biased auto-correlation. |
| AutoCorrNormal | Normal auto-corellation. |
| AutoCorrUnBiased | Unbiased auto-correlation. |
| BinarySearch (2) | Finds a match for X in sorted object values using binary search. |
| BlockFinish | Deinitializes block processing before the final block is processed. |
| BlockInit (4) | Initializes block processing. |
| BlockNext | Obtains the next subrange of the data. |
| CartToPolar (2) | Converts elements from cartesian to polar coordinate form. |
| Cbrt (4) | The cube root. |
| Ceil (4) | Rounds towards positive infinity. |
| Clear | Sets vector size to zero. |
| Concat (2) | Concatenates an array of TVec 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. |
| Conj (4) | Conjugate. |
| ConjMul (4) | Conjugate and multiply. |
| Convolve | Single-rate finite, linear convolution of two sequences. |
| Copy (7) | Copy object values. |
| CopyFromArray (12) | Copies values from an array. |
| CopyTo (5) | Copy and if needed convert values to Dst. |
| CopyToArray (12) | Copy values to an array. |
| Cos (4) | Cosine. |
| Cosh (4) | Hyperbolic cosine. |
| Cot (4) | Cotangens. |
| Coth (4) | Hyperbolic cotangens. |
| CplxToReal (2) | Split complex calling object in real and imaginary part. |
| CrossCorr | The cross-correlation of two vectors. |
| Csc (4) | Cosecant. |
| Csch (4) | Hyperbolic cosecant. |
| ctor (4) | Uses TVec object as internal storage. |
| CumProduct (4) | Calculate the cumulative product for all Vec elements. |
| CumSum (4) | Cumulative sum. |
| DCT (3) | The forward discrete cosine transform (DCT). |
| DegToRad (4) | Convert degrees to radians (in-place). |
| Diag | Copies the k-th diagonal from the TMtx object. |
| Difference (3) | Calculate the difference for all Vec elements and store the results in the calling vector. |
| DisableSelect | Prevents calls to Dew.Math.Units.MtxExpr.Select. |
| DisableSubrange | Prevents calls to Dew.Math.Vector.SetSubRange. |
| Disown (2) | Disowns a calling vector values pointer by setting Values, CValues to nil and Dew.Math.TMtxVecBase.Length to 0. |
| DivAndAdd (22) | Compute X/Y + zScalar |
| DivAndSub (22) | Compute X/Y - zScalar |
| Divide (14) | Compute xScalar / (Y*Z) |
| DivideBy (8) | Divide complex Value with elements of the calling object and store the result in the calling object. |
| DivideC (4) | Compute X / (Y*zScale) |
| DotProd (2) | Scalar product of two real arrays. |
| DotProdc (4) | Scalar product of two complex arrays. |
| DownSample (2) | Downsamples vector values. |
| EnableSelect | Enables calls to Dew.Math.Units.MtxExpr.Select. |
| EnableSubrange | Enables calls to Dew.Math.Vector.SetSubRange. |
| Equal (2) | Compares vector elements and returns true if vectors are equal. |
| Erf (4) | Error function of self (in-place). |
| Erfc (4) | Complementary error function of self (in-place). |
| ErfInv (4) | Inverse error function of self (in-place). |
| Exp (4) | Exponent (e^). |
| Exp10 (4) | Exponent base 10 (10^). |
| Exp2 (4) | Exponent base 2 (2^). |
| Expj (3) | A complex exponential e^(j*W). |
| ExtendToComplex (3) | Extend Vec object to complex calling object. |
| FFT (3) | Calculate the FFT from all Vec elements. |
| FFTFromReal (3) | The forward Fast Fourier Transformation (FFT) from real to complex. |
| Find (2) | Compare complex value X with all calling object elements. |
| FindAndGather (3) | Finds and gathers vector elements. |
| FixAngle (4) | Sets angle in [-2Pi,2Pi]. |
| Flip (4) | Flips the real and imaginary part of complex numbers. |
| FlipConj (4) | Flips the real and imaginary part of complex numbers and conjugates the complex numbers. |
| Floor (4) | Rounds towards negative infinity. |
| Frac (4) | Fractional part of values. |
| Gather | Gather vector elements. |
| GatherByIncr | Gather vector elements. |
| GatherByIndex | Gather vector elements. |
| GatherByMask | Gather vector elements. |
| GatherSplit | Gather a vector, split to two vectors. |
| GetCol (3) | Copies a column from matrix. |
| GetRow (3) | Copies a row from matrix. |
| GetSchema | Returns null. |
| GroupSum | Sums items from Src with matching corresponding indexes from Bins and places result in self. |
| GroupSumIteration | Sums items from Src with matching corresponding indexes from Bins and places result in self. |
| Hilbert | The fast hilbert transform (FFT based). |
| IDCT (3) | Calculate the inverse DCT in-pllace. |
| IFFT (3) | Calculate the inverse FFT from all Vec elements and store the results in the calling vector. |
| IFFTToReal (3) | Calculate the inverse FFT from all Vec elements. |
| ImagPart (2) | Gets the imaginary part of a complex object. |
| Integrate (2) | Integrate calling vector values. |
| IntPower (2) | Calculate the power Base^(Exponent) for all Base object elements using the integer Exponent value. |
| Inv (8) | Invert elements. |
| InvCbrt (4) | The inverse of cube root 1/(v)^1/3. |
| InvSqrt (4) | The inverse of square root 1/(v)^1/2. |
| IsEqual (8) | Compares complex Value with all calling object elements. |
| Kron | The Kronecker product between two vectors. |
| Kurtosis (2) | The Kurtosis (fourth central momentum). |
| Ln (4) | Natural logarithm. |
| LoadFromFile | Reads the header information and the values array content from the file. |
| LoadFromStream | Reads the header information and the values array content from a stream. |
| Log10 (4) | Log base 10. |
| Log2 (4) | Log base 2. |
| LogN (4) | Log base N. |
| Mag (4) | Magnitude. |
| Mask (3) | Assigns Value at indexes of the calling object, at which aMask is different from 0. |
| MaskNot (3) | Assigns Value at indexes of the calling object, at which aMask is equal to 0. |
| Max (5) | Maximum value. |
| Maxc (3) | Maximum value. |
| MaxEvery (4) | Vectorised maximum. |
| MaxMin (4) | Maximum and minimum value in a single pass. |
| Mean (3) | Mean value. |
| MeanAndStdDev (2) | Returns the standard deviation of all calling object elements. |
| Meanc (4) | Mean value. |
| Median (2) | Median. |
| Min (5) | Minimum value. |
| Minc (3) | Minimum value. |
| MinEvery (4) | Vectorised minimum. |
| Mul (18) | Multiply all calling object elements with complex Value in-place. |
| MulAndAdd (26) | Compute (X*yScalar) + zScalar |
| MulAndDiv (10) | Compute X * Y / zScalar |
| MulAndSub (26) | Compute X*yScalar - Z*zScale |
| MulI (4) | Multiply elements by imaginary unit I. |
| Norm | The norm of a vector. |
| Normalize (12) | Normalize by subtracting a complex constant SubOffset from Vec elements and dividing the result by complex constant DivFactor. |
| NormC (4) | Calculate the C-norm of calling vector. |
| NormL1 (4) | Calculate the L1-norm of the calling vector. |
| NormL2 (4) | Calculate the L2-norm of the calling vector. |
| Offset (4) | Add/Subtract a complex value. |
| Parse | Parses string content as vector. |
| PCValues1D | Obtains a pointer to the complex value of the vector at Index. |
| PhaseSpectrum (2) | The phase angles (spectrum) of object elements. |
| PixelDownSample (2) | Downsample the vectors Y and (optionaly) X starting at position Index and for Len samples. |
| PolarToCart (2) | Converts the polar magnitude/phase pairs to cartesian pairs. |
| Power (7) | Raises all calling vector elements to complex power Exponent in-place. |
| PowerSpectrum (2) | The power spectrum from object complex values. |
| PowerVec | Raises Base object elements to Exponent object elements power. |
| PrimeNumbers | Fills vector with prime numbers, starting from 2 up to the value of n. |
| Product (6) | Elements product. |
| Productc (2) | Elements product. |
| PValues1D | Obtains a pointer to the real value of the vector at Index. |
| RadToDeg (4) | Convert radians to degrees (in-place). |
| Ramp (7) | Fills the calling vector with a series following linear rule. |
| RandGauss (3) | The pseudo random sample generator with Gaussian distribution. |
| RandomShuffle | Randomly shuffles the content of the vector. |
| RandUniform (3) | The pseudo random sample generator with continuous uniform distribution. |
| Range (3) | Calculate the range from all calling object elements. |
| 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. |
| RealPart (2) | Gets real part of complex object values. |
| RealToCplx (2) | Constructs a complex object from two real objects. |
| Rem (4) | The Reminder after division X/Y. |
| Replace (4) | Search and replace a complex value. |
| ReplaceNAN (2) | Replaces all NAN values with Value. |
| Reset | Resets object properties to default values. |
| Resize (2) | Resizes vector size while preserving values. |
| Reverse (4) | Reverse vector elements. |
| RMS (2) | Root mean square (RMS). |
| Rotate (4) | Applies cyclic shift on Src vector elements and stores the result in Self. |
| Round (5) | Elements rounded to the nearest whole number. |
| SaveToFile | Write object header and values to a file. |
| SaveToStream | Writes the header information and the Values content to a stream. |
| Scale (4) | Multiply all calling object elements with a complex Value in-place. |
| Scatter | Scatter object elements. |
| ScatterByIncr | Scatter object elements. |
| ScatterByIndexes | Scatter object elements. |
| ScatterByMask | Scatter object elements. |
| Sec (4) | Secant. |
| Sech (4) | Hyperbolic secant. |
| SelectAll | Resets any defined selection. |
| SetCplx | Sets vector values (complex). |
| SetDouble (2) | Sets vector values (double). |
| SetFullRange | Resets any defined subrange. |
| SetInteger (2) | Sets vector values (integer). |
| SetIt (4) | Sets vector values. |
| SetSingle (2) | Sets vector values (single). |
| SetSubIndex (2) | Defines a subarray. |
| SetSubRange (4) | Sets the subarray size to full size. |
| SetSubRangeLevel (2) | Define a subvector of the Src vector starting at Index and ending at Index+Len-1. |
| SetVal (4) | Set all calling object complex elements to complex Value. |
| SetZero (2) | Initializes object elements to zero. |
| Sgn (4) | Computes signum function of calling object elements. |
| SgnMul | Signum. |
| Shift (4) | Shift vector elements left or right in the array. |
| Sign (4) | Changes elements sign. |
| Sin (4) | Sine. |
| SinCos (2) | Sine and cosine. |
| Sinh (4) | Hyperbolic sine. |
| SinhCosh (2) | Hyperbolic sine and cosine. |
| Size (4) | Size the object. |
| SizeFromArray (6) | Sets the size of the vector to match an array. |
| SizeToArray (6) | Sizes the array. |
| Skewness (2) | Skewness (third central momentum). |
| SortAscend (4) | Sorts vector elements in ascending order. |
| SortDescend (4) | Sorts vector elements in descending order. |
| Split (3) | Copy the contents of the calling TVec object to Vec1 and Vec2 objects. |
| Sqr (4) | Square. |
| SqrAddScaled (8) | Compute sqr(X)*xScale + sqr(Y)*yScale |
| Sqrt (4) | Square root. |
| StdDev (6) | Standard deviation. |
| StringsToValues (2) | Convert strings in aList to double or TCplx. |
| StripNanAndInf (3) | Copy Src into self, dropping every NAN/INF element and compacting the result. |
| Sub (18) | Subtracts complex Value from all calling object complex elements. |
| SubAndMul (50) | Compute (X - yScalar)*zScalar |
| SubFrom (8) | Subtract each of calling object elements from complex Value. |
| SubScaled (12) | Compute X*xScale - Y*yScale - Z*zScale |
| SubScaledC (8) | Compute X*xScale - Y*yScale - zScalar |
| Sum (5) | Sums vector values. |
| Sumc (2) | Sum (complex value). |
| SumOfSquares (2) | Calculate the Sum of squares of the calling vector. |
| Tan (4) | Tangens. |
| Tanh (4) | Hyperbolic tangens. |
| TensorProd (2) | Tensor product between vector and matrix. |
| 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 and store the results in calling object. |
| ThresholdGT (8) | Perform "greater than" threshold operation for complex numbers on all Vec object values and store the results in calling object. |
| ThresholdGT_LT (4) | Perform "greater than and less than" threshold operation on all Vec object values and store the results in calling object. |
| ThresholdLT (8) | Perform "less than" threshold operation for complex numbers on all Vec object values and store the results in calling object. |
| ThreshTop (4) | Perform threshold operation on all Src object values and store the results in calling object. |
| ToString | Returns content as a string. |
| Trunc (5) | Rounds a real number towards zero. |
| TruncAndFrac (2) | Rounds a real number towards zero and returns the fractional part. |
| UpSample (2) | Inserts zeroes between consecutive vector values. |
| ValuesToStrings (3) | Converts the content of the Values array of the calling vector to a list of strings. |
| ValuesToText | Writes vector values to string. |
| WriteHeader | Writes the header information for the calling vector to a stream. |
| WriteValues | Writes object Values content to a stream. |
| WriteXml | Write the object to the .NET XML stream. |
| ZScore (2) | Transforms vector into vector of standardized data in-place. |
Operators
| Name | Description |
|---|---|
| op_Addition (7) | Add left to all elements in Right and return result. |
| op_Division (7) | Divide Left with all elements Right. |
| op_Equality (7) | Returns true, if all elements of Right are equal to Left. |
| op_Explicit (7) | Explicitely convert TVec to Vector. |
| op_GreaterThan (5) | Returns true, if ALeft is greater from all elements in ARight. |
| op_GreaterThanOrEqual (5) | Returns true, if ALeft is greater or equal from all elements in ARight. |
| op_Implicit (12) | Implicit type conversion from an array of TCplx to Vector. |
| op_Inequality (7) | Returns true, if any elements of Right are not equal to Left. |
| op_LessThan (5) | Returns true, if ALeft is smaller from all elements in ARight. |
| op_LessThanOrEqual (5) | Returns true, if ALeft is smaller or equal from all elements in ARight. |
| op_Multiply (7) | Multiply all elements in Right with Left. |
| op_Subtraction (7) | Subtract all elements in Right from Left. |
| op_UnaryNegation | Negates all values inside AValue. |