The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information....



Interface of SDL_Vector

const
{$IFDEF PAIDVERS}
  SDLVersionInfo = 'vector_r1050_full';
  IsLightEd = false;
{$ELSE}
  SDLVersionInfo = 'vector_r1050_lighted';
  IsLightEd = true;
{$ENDIF}
  release = 1050;

type
  ESDLVectorError = class(ESDLError);      { exception type to indicate errors }
  TIntegMethod = (imSimple, imTrapezoidal, imSimpson);
  TIntVector = class;
  TVector = class (TComponent)
              private
                FNElem         : longint;                 { number of elements }
                FIsEmpty       : boolean;
                FVec           : array of double; { pointer to vector elements }
                FOnChange      : TNotifyEvent;
                FOnSortExchange: TSortExchgEvent;
                function    GetVal (Elem: longint): double;
                procedure   SetVal (Elem: longint; Value: double);
                function    CalcVecLeng: double;
                procedure   SetVecLeng (Value: double);
                procedure   SetVecSize (sz: longint);
                procedure   SkewKurtIntern (LowElem, HighElem: integer;
                                var Skewness, Kurtosis: double;
                                var NumData: longint);
              protected
                procedure AssignTo (Dest: TPersistent); override;
                procedure   SortExchange (ExchgWhat: byte; index1, index2,
                                first, last: longint);
              public
                constructor Create (AOwner: TComponent); override;
                destructor  Destroy; override;
                procedure Assign(Source: TPersistent); override;
                procedure   Add (OtherVec: TVector);
                procedure   AbsVal;
                procedure   Clear;
                procedure   Changed;
                procedure   Clone (VecSource: TVector);
                procedure   CopyFrom (VecSource: TVector;
                               SourceElemLo, SourceElemHi,
                               DestElem: integer);
                function    Correlate (OtherVec: TVector;
                               ElemShift: integer): double;
{$IFNDEF DOTNET}
                function    CRCofData: string;
{$ENDIF}                
                function    DotProduct (OtherVec: TVector): double;
                function    EuclideanDistance (OtherVec: TVector): double;
                procedure   Fill (value: double);
                procedure   FillRandomUniform (RangeLow, RangeHigh: double);
                procedure   FillRandomGauss (Mean, StdDev: double);
                function    FindInSortedVector (Ascending: boolean;
                               Value: double): integer;
                function    Find (LowElem, HighElem: integer;
                               value: double): integer;
                function    GeometricMean (LowElem, HighElem: integer): double;
                function    HarmonicMean (LowElem, HighElem: integer): double;
                function    Histogram (FirstElem, LastElem: longint;
                               FirstBin, LastBin, BinWidth: double;
                               Histo: TIntVector; var Underflow,
                               Overflow, MaxCnt: longint): boolean;
                function    Integrate (BoundLow,BoundHigh: double;
                               Method: TIntegMethod): double;
                property    Leng: double read CalcVecLeng write SetVecLeng;
                function    LoadFromFile (FileName: string;
                               AdjustVectorSize: boolean): boolean; overload;
                function    LoadFromFile (FileName: string; AdjustVectorSize,
                               AutoDetect: boolean): boolean; overload;
                function    LoadFromStream (InStream: TMemoryStream;
                               AdjustVectorSize: boolean): boolean; overload;
                function    LoadFromStream (InStream: TFileStream;
                               AdjustVectorSize: boolean): boolean; overload;
                procedure   MakeValidElemRange
                               (var LowElem, HighElem: integer);
                function    MeanCenter: double;
                procedure   MeanVar (LowElem, HighElem: integer;
                               var Mean, Variance: double);
                procedure   MinMax (LowElem, HighElem: integer;
                               var Minimum, Maximum: double); overload;
                procedure   MinMax (LowElem, HighElem: integer;
                               var Minimum, Maximum: double;
                               var MinIx, MaxIx: integer); overload;
                procedure   Mirror;
                function    Mode (LowElem, HighElem: integer): double;
                function    PearsonCorrCoeff (OtherVec: TVector): double;
                function    Percentile (prob: double; LowElem,
                               HighElem: integer): double;
                procedure   QNormalize (RefQuant: double;
                              var Median, QuantDiff: double);
                function    Quartiles (LowElem, HighElem: integer;
                               var Q1, Q2, Q3: double): boolean;
                function    Resize (NE: longint): boolean;
                procedure   SaveToStream (var OutStream: TMemoryStream;
                              LowElem, HighElem: integer); overload;
                procedure   SaveToStream (var OutStream: TFileStream;
                              LowElem, HighElem: integer); overload;
                procedure   Standardize (var mean, stddev: double);
                function    StoreOnFile (FirstElem, LastElem, Precision: integer;
                                FileName:string): boolean;
                procedure   SkewKurt (LowElem, HighElem: integer;
                               var Skewness, Kurtosis: double);
                procedure   SkewKurtSample (LowElem, HighElem: integer;
                               var Skewness, Kurtosis: double);
                procedure   ShuffleElems;
                procedure   SMult (scalar: double);
                procedure   SortElems (Ascending: boolean; RangeFirst,
                               RangeLast: integer);
                procedure   Subtract (OtherVec: TVector);
                function    Sum (LowElem, HighElem: integer): double;
                property    IsEmpty: boolean read FIsEmpty write FIsEmpty;
                property    Elem[ix: longint]: double
                               read GetVal write SetVal; default;
              published
                property    NrOfElem: longint read FNElem write SetVecSize;
                property    OnChange: TNotifyEvent read FOnChange write FOnChange;
                property    OnSortExchange: TSortExchgEvent
                               read FOnSortExchange write FOnSortExchange;
              end;

  TIntVector = class (TComponent)
                 private
                   FNElem         : longint;               { number of elements }
                   FVec           : array of integer;{pointer to vector elements}
                   FIsEmpty       : boolean;
                   FOnChange      : TNotifyEvent;
                   FOnSortExchange: TSortExchgEvent;
                   function    GetVal (Elem: longint): integer;
                   procedure   SetVal (Elem: longint; Value: integer);
                   function    CalcVecLeng: double;
                   procedure   SetIntVecSize (sz: longint);
                   procedure   SkewKurtIntern (LowElem, HighElem: integer;
                                  var Skewness, Kurtosis: double;
                                  var NumData: longint);
                 protected
                   procedure AssignTo (Dest: TPersistent); override;
                   procedure   SortExchange (ExchgWhat: byte; index1, index2,
                                  first, last: longint);
                 public
                   constructor Create (AOwner: TComponent); override;
                   destructor  Destroy; override;
                   procedure   AbsVal;
                   procedure   Add (OtherVec: TIntVector);
                   procedure Assign(Source: TPersistent); override;
                   procedure   Changed;
                   procedure   Clear;
                   procedure   Clone (VecSource: TIntVector);
                   procedure   CopyFrom (VecSource: TIntVector;
                                  SourceElemLo, SourceElemHi,
                                  DestElem: integer);
                   function    Correlate (OtherVec: TIntVector;
                                  ElemShift: integer): integer;
{$IFNDEF DOTNET}
                   function    CRCofData: string;
{$ENDIF}
                   function    DotProduct (OtherVec: TIntVector): integer;
                   function    EuclideanDistance (OtherVec: TIntVector): double;
                   procedure   Fill (value: integer);
                   function    FindInSortedVector (Ascending: boolean;
                                  Value: integer): integer;
                   function    Find (LowElem, HighElem, value: integer): integer;
                   function    GeometricMean (LowElem, HighElem: integer): double;
                   function    HarmonicMean (LowElem, HighElem: integer): double;
                   function    Histogram (FirstElem, LastElem: longint;
                                  FirstBin, LastBin, BinWidth: integer;
                                  Histo: TIntVector; var Underflow, Overflow,
                                  MaxCnt: longint): boolean;
                   property    Leng: double read CalcVecLeng;
                                    { %% read only - in contrast to TVector !! }
                   function    LoadFromFile (FileName: string;
                                  AdjustVectorSize: boolean): boolean;
                   function    LoadFromStream (InStream: TMemoryStream;
                                  AdjustVectorSize: boolean): boolean; overload;
                   function    LoadFromStream (InStream: TFileStream;
                                  AdjustVectorSize: boolean): boolean; overload;
                   procedure   MakeValidElemRange (var LowElem, HighElem: integer);
                   procedure   MeanVar (LowElem, HighElem: integer;
                                  var Mean, Variance: double);
                   procedure   MinMax (LowElem, HighElem: integer;
                                  var Minimum, Maximum: integer); overload;
                   procedure   MinMax (LowElem, HighElem: integer;
                               var Minimum, Maximum: integer;
                               var MinIx, MaxIx: integer); overload;
                   procedure   Mirror;
                   function    Mode (LowElem, HighElem: integer): integer;
                   function    PearsonCorrCoeff (OtherVec: TIntVector): double;
                   function    Percentile (prob: double; LowElem,
                                  HighElem: integer): double;
                   function    Quartiles (LowElem, HighElem: integer;
                                  var Q1, Q2, Q3: double): boolean;
                   function    Resize (NE: longint): boolean;
                   procedure   SaveToStream (var OutStream: TMemoryStream;
                                 LowElem, HighElem: integer); overload;
                   procedure   SaveToStream (var OutStream: TFileStream;
                                 LowElem, HighElem: integer); overload;
                   procedure   SkewKurt (LowElem, HighElem: integer;
                                  var Skewness, Kurtosis: double);
                   procedure   SkewKurtSample (LowElem, HighElem: integer;
                                  var Skewness, Kurtosis: double);
                   procedure   SortElems (Ascending: boolean;
                                  RangeFirst, RangeLast: integer);
                   procedure   ShuffleElems;
                   procedure   SMult (scalar: integer);
                   function    StoreOnFile (FirstElem, LastElem: integer;
                                  FileName:string): boolean;
                   procedure   Subtract (OtherVec: TIntVector);
                   function    Sum (LowElem, HighElem: integer): longint;
                   property    IsEmpty: boolean read FIsEmpty write FIsEmpty;
                   property    Elem[ix: longint]: integer
                                  read GetVal write SetVal; default;
                 published
                   property    NrOfElem: longint read FNElem write SetIntVecSize;
                   property    OnChange: TNotifyEvent read FOnChange write FOnChange;
                   property    OnSortExchange: TSortExchgEvent
                                  read FOnSortExchange write FOnSortExchange;
               end;





Last Update: 2012-Oct-20