You are here: Symbol Reference > Dew Namespace > Dew.Math Namespace > Classes > Vector Structure
Dew Math for .NET
ContentsIndexHome
PreviousUpNext
Vector Structure

Vector class for operator overloading (Delphi 2006 and later).

Syntax
C#
Visual Basic
public struct Vector : IDeserializationCallback, IDisposable, IXmlSerializable { public TDouble1DAccess Values; public TSingle1DAccess SValues; public TDCplx1DAccess CValues; public TSCplx1DAccess SCValues; }

MtxExpr.cs

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.

var b, c: Vector; bv: TVec; begin b := Vector(TDoubleArray.Create(1,1,1,1)); b = [1,1,1,1]; 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 bv.Add(c); //pass Vector type and implicitely convert to TVec end;
Copyright (c) 1999-2024 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!