You are here: Symbol Reference > MtxExprInt Namespace > Classes > MatrixInt Record
MtxVec VCL
ContentsIndex
PreviousUpNext
MatrixInt Record

Integer vector class for operator overloading (Delphi 2006 and later).

Pascal
MatrixInt = record end;

Declare VectorInt instead of TVecInt to take advantage ofoperator overloading. Be carefull to declare VectorInt only for local variables with short lifetime. Call the Create method for VectorInt, if the variable is a global variable or a variable with a longer life. It also makes sense to continue to use TVecInt for global vars. If the Create method (constuctor) is not called, the VectorInt record obtains TVecInt object from object cache (fastest create). If the Create mehod is called, the TVecInt object is created in the usual way (slower). Object cache has limited size.

var b, c: VectorInt; bv: TVecInt; begin b := VectorInt(TIntegerArray.Create(1,1,1,1)); //b = [1,1,1,1]; bv := b; //b and bv point to same data object bv.Multiply(2); bv.Bits[76] := true; //set 76th bit in the array to 1 TVecInt(b).Multiply(2); //an alternative way to scale c := b*2 + 3; //c := b*2 + 2 + 3i c := b*bv; //mix VectorInt and TVecInt bv.Add(c); //pass VectorInt type and implicitely convert to TVecInt pointer b.PackBits(c); // store bit 1 in b for all elements in c which are different from zero. Bit 0 otherwise. end;
Examples on GitHub
Copyright (c) 1999-2024 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!