IGLib  1.5
The IGLib base library for development of numerical, technical and business applications.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
IG.Num.Vector Class Reference

Real vector class. More...

+ Inheritance diagram for IG.Num.Vector:
+ Collaboration diagram for IG.Num.Vector:

Public Member Functions

 Vector (IVector vec)
 Constructs a vector from aanother array. More...
 
 Vector (int n)
 Constructs an n-dimensional vector of zeros. More...
 
 Vector (int n, int which)
 Constructs an n-dimensional unit vector for i'th coordinate. More...
 
 Vector (int n, double value)
 Constructs an n-dimensional constant vector with all components initialized to the specified value. More...
 
 Vector (IList< double > components)
 Constructs a vector from a list of elements by copying its elements. More...
 
 Vector (double[] components, bool copyElements=true)
 Constructs a vector from a 1-D array, either by directly using the array or by copying its elements. More...
 
 Vector (params double[] components)
 Constructs a vector from a 1-D array or from listed variable number of components. More...
 
 Vector (VectorBase_MathNetNumerics vec)
 Constructs a vector from a 1-D array, directly using the provided array as internal data structure. More...
 
Vector GetCopyThis ()
 Creates and returns a copy of the current vector, which is of the same type as the current vector. More...
 
override VectorBase GetCopyBase ()
 Creates and returns a copy of the current vector, which is of the same type as the current vector. More...
 
Vector GetNewThis (int length)
 Creates and returns a new vector of the specified dimension in such a way that the type of the returned vector is the same as that of the current vector. More...
 
override VectorBase GetNewBase (int length)
 Creates and returns a new vector of the specified dimension in such a way that the type of the returned vector is the same as that of the current vector. More...
 
Vector GetNewThis ()
 Creates and returns a new vector with the same dimension and of the same type as the current vector. More...
 
override VectorBase GetNewBase ()
 Creates and returns a new vector with the same dimension and of the same type as the current vector. More...
 
virtual Matrix GetNewMatrixThis (int rowCount, int columnCount)
 Creates and returns a new matrix with the specified dimensona, and of a type that is consistent with the type of the current vector. More...
 
override MatrixBase GetNewMatrixBase (int rowCount, int columnCount)
 Creates and returns a new matrix with the specified dimensona, and of a type that is consistent with the type of the current vector. More...
 
Matrix GetNewMatrixThis ()
 Creates and returns a new matrix of a type that is consistent with the type of the current vector, and with both dimensions equal to the dimension of the current vector. More...
 
override MatrixBase GetNewMatrixBase ()
 Creates and returns a new matrix of a type that is consistent with the type of the current vector, and with both dimensions equal to the dimension of the current vector. More...
 
override int GetHashCode ()
 Returns the hash code (hash function) of the current vector. More...
 
override bool Equals (Object obj)
 Returns a value indicating whether the specified object is equal to the current vector. More...
 
- Public Member Functions inherited from IG.Num.VectorBase
virtual double[] ToArray ()
 Copies the current vector to an array. More...
 
virtual IVector GetCopy ()
 Returns a deep copy of the current object. More...
 
virtual IVector GetNew (int length)
 Creates and returns a new vector with the specified dimension, and of the same type as the current vector. More...
 
virtual IVector GetNew ()
 Creates and returns a new vector with the same dimension and of the same type as the current vector. More...
 
virtual IMatrix GetNewMatrix (int rowCount, int columnCount)
 Creates and returns a new matrix with the specified dimensona, and of a type that is consistent with the type of the current vector. More...
 
virtual IMatrix GetNewMatrix ()
 Creates and returns a new matrix of a type that is consistent with the type of the current vector, and with both dimensions equal to the dimension of the current vector. More...
 
virtual void SetZero ()
 Sets all components of the current vector to 0. More...
 
virtual void SetConstant (double elementValue)
 Sets all components of the current vector to the specified value. More...
 
virtual void SetUnit (int which)
 Sets the current vector to the specific unit vector (one component equals 1, others are 0). More...
 
virtual void SetRandom ()
 Sets the current vector such that it contains random elements on the interval (0,1]. More...
 
virtual void SetRandom (IRandomGenerator rnd)
 Sets the current vector such that it contains random elements on the interval (0,1]. More...
 
virtual double NormP (double p)
 p-norm, p-th root of sum of absolute values of components raised to the power of p. More...
 
IVector Normalized ()
 Returns a vector that equals a normalized current vector. More...
 
void Normalize ()
 Normalizes the current vector. More...
 
void Negate ()
 Changes the sign of the current vector. More...
 
override int GetHashCode ()
 Returns the hash code (hash function) of the current vector. More...
 
override bool Equals (Object obj)
 Returns a value indicating whether the specified object is equal to the current vector. More...
 
int GetHashFunctionInt ()
 Returns an integer valued hash function of the current vector object. More...
 
string GetHashFunctionString ()
 Returns a string valued hash function of the current vector object. More...
 
override string ToString ()
 Returns a string representation of this vector in a standard IGLib form. More...
 
virtual string ToStringMath ()
 Returns a string representation of this vector in a standard IGLib form (Mathematica-like format but with C representation of numbers). More...
 
virtual string ToString (string elementFormat)
 Returns a string representation of the current vector in a standard IGLib form, with the specified format for elements of the vector. More...
 
virtual string ToStringMath (string elementFormat)
 Returns a string representation of the current vector in a standard IGLib form (Mathematica-like format but with C representation of numbers), with the specified format for elements of the vector. More...
 

Static Public Member Functions

static Vector Create (double[] components)
 Constructs a vector from a 1-D array. More...
 
static Vector Create (VectorBase_MathNetNumerics vec)
 Constructs a vector as a copy of a MathNetVector object. More...
 
static Vector Create (IVector vec)
 Constructs a vector as a copy of another Vector object. More...
 
static Vector Random (int n, IRandomGenerator rand=null)
 Generates vector with random elements uniformly distributed on [0, 1). More...
 
static Vector Ones (int n)
 Generates an d2-dimensional vector filled with 1. More...
 
static Vector Zeros (int n)
 Generates an d2-dimensional vector filled with 0. More...
 
static Vector BasisVector (int n, int i)
 Generates an d2-dimensional unit vector for i-th coordinate. More...
 
- Static Public Member Functions inherited from IG.Num.VectorBase
static double NormPlain (IVector a)
 Returns Euclidean norm of the specified vector. More...
 
static double NormStatic (IVector a)
 Returns Euclidean norm of the specified vector. More...
 
static double Norm2Plain (IVector a)
 Returns Euclidean norm of the specified vector. More...
 
static double Norm2Static (IVector a)
 Returns Euclidean norm of the specified vector. More...
 
static double Norm1Plain (Vector a)
 Returns the 1-norm (Manhattan or Taxicab norm, sum of element absolute values) of the specified vector. More...
 
static double Norm1Static (IVector a)
 Returns the 1-norm (Manhattan or Taxicab norm, sum of element absolute values) of the specified vector. More...
 
static double NormPPlain (Vector a, double p)
 Returns the p-norm (p-th root of sum of absolute values of components raised to the power of p) of the specified vector. More...
 
static double NormPStatic (IVector a, double p)
 Returns the p-norm (p-th root of sum of absolute values of components raised to the power of p) of the specified vector. More...
 
static double NormInfPlain (Vector a)
 Returns the Infinity-norm (maximum absolute value of any element) of the specified vector. More...
 
static double NormInfStatic (IVector a)
 Returns the Infinity-norm (maximum absolute value of any element) of the specified vector. More...
 
static double DistancePlain (IVector a, IVector b)
 Returns Euqlidean distance between the specified two vectors. More...
 
static double Distance (IVector a, IVector b)
 Returns Euqlidean distance between the specified two vectors. More...
 
static double DistanceWeightedPlain (IVector a, IVector b, IVector characteristicLengths)
 Returns distance between the specified two vectors where vector elements are weighted by elements of another vector, which represent intervals of equal importance (thus the weighted sum is divided by their squares). More...
 
static double DistanceWeighted (IVector a, IVector b, IVector characteristicLengths)
 Returns distance between the specified two vectors where vector elements are weighted by elements of another vector, which represent intervals of equal importance (thus the weighted sum is divided by their squares). More...
 
static double NormWeightedPlain (IVector a, IVector characteristicLengths)
 Returns weighted Euclidean norm of the specified vector. More...
 
static double NormWeighted (IVector a, IVector characteristicLengths)
 Returns weighted Euclidean norm of the specified vector. More...
 
static void SetZero (IVector vec)
 Sets all components of the current vector to 0. More...
 
static void SetConstant (IVector vec, double elementValue)
 Sets all components of the current vector to the specified value. More...
 
static void SetUnit (IVector vec, int which)
 Sets the current vector to the specific unit vector (one component equals 1, others are 0). More...
 
static void SetRandom (IVector vec)
 Sets the current vector such that it contains random elements on the interval (0,1]. More...
 
static void SetRandom (IVector vec, IRandomGenerator rnd)
 Sets the current vector such that it contains random elements on the interval (0,1]. More...
 
static int Compare (IVector v1, IVector v2)
 Compares two vectors and returns -1 if the first vector is smaller than the second one, 0 if vectors are equal, and 1 if the first vector is greater. Vector that is null is considered smaller than a vector that is not null. Two null vectors are considered equal. Vector with smaller dimension is considered smaller than a vector with greater dimension. Vectors with equal dimensions ar compared by elements. The first element that is different decides which vector is considered greater. More...
 
static void Resize (ref IVector vec, IVector template, int dimension)
 Resizes, if necessary, the specified vector according to the required dimension. If the vector is initially null then a new vector is created. If in this case a template vector is specified then the newly created vector will be of the same type as that template vector, because it is created by the GetNew() method on that vector. If dimension of the initial vector does not match the required dim., then vector is resized. If the specified vector dimension is less or equal to 0 then vector is resized with the same dimension as that of the template vector. If in this case the template vector is null, an exception is thrown. WARNINGS: Components are NOT preserved and have in general undefined values after operation is performed. If vector and template are null then the type of nawly created vector is Vector. More...
 
static void Resize (ref IVector vec, int dimension)
 Resizes, if necessary, the specified vector according to the required dimension. If the vector is initially null then a new vector is created. If dimension of the initial vector does not match the required dimension, then vector is resized. Components are NOT preserved and have in general undefined values after operation is performed. WARNING: If the vector is initially null then the type of the newly created vector is Vector. More...
 
static void Resize (ref IVector vec, IVector template)
 Resizes, if necessary, the specified vector according to the dimension of the specified template vector. If the vector is initially null then a new vector is created. In this case the newly created vector will be of the same type as that template vector, because it is created by the GetNew() method on that vector. If dimension of the initial vector does not match the dimension of the template vector, then vector is resized. If the template vector is null, then an exception is thrown. WARNINGS: Components are NOT preserved and have in general undefined values after operation is performed. If vector and template are null then the type of newly created vector is Vector. More...
 
static void CopyPlain (IVector a, IVector result)
 Copies components of a vector to another vector. This is a plain version that does not perform any dimension checks. WARNING: dimensions of the copied vector and result vector must match. More...
 
static void Copy (IVector a, IVector result)
 Copies components of a vector to another vector. WARNING: dimensions of the copied vector and result vector must match. More...
 
static void Copy (IVector a, ref IVector result)
 Copies components of a vectr to another vector. Resulting vector is allocated or reallocated if necessary. More...
 
static void CopyPlain (VectorBase_MathNetNumerics a, IVector result)
 Copies components of a vector to another vector. This is a plain version that does not perform any dimension checks. WARNING: dimensions of the copied vector and result vector must match. More...
 
static void Copy (VectorBase_MathNetNumerics a, IVector result)
 Copies components of a vector to another vector. WARNING: dimensions of the copied vector and result vector must match. More...
 
static void Copy (VectorBase_MathNetNumerics a, ref IVector result)
 Copies components of a vectr to another vector. Resulting vector is allocated or reallocated if necessary. More...
 
static void CopyPlain (IVector a, Vector_MathNetNumerics result)
 Copies components of a vector to another vector. This is a plain version that does not perform any dimension checks. WARNING: dimensions of the copied vector and result vector must match. More...
 
static void Copy (IVector a, Vector_MathNetNumerics result)
 Copies components of a vector to another vector. WARNING: dimensions of the copied vector and result vector must match. More...
 
static void Copy (IVector a, ref Vector_MathNetNumerics result)
 Copies components of a vectr to another vector. Resulting vector is allocated or reallocated if necessary. More...
 
static void NegatePlain (IVector a, IVector result)
 Stores a negative vector of the specified vector to another vector. This is a plain version of the method that does not perform any consistency checks. WARNING: dimensions of the copied vector and result vector must match. More...
 
static void Negate (IVector a, IVector result)
 Stores a negative vector of the specified vector to another vector. WARNING: dimensions of the copied vector and result vector must match. More...
 
static void Negate (IVector a, ref IVector result)
 Stores a negative vector of the specified vector to another vector. Resulting vector is allocated or reallocated if necessary. More...
 
static void AddPlain (IVector a, IVector b, IVector result)
 Sums two vectors and stores the result in the specified result vector. This is a plain version of the method that does not perform any consistency checks. WARNING: dimensions of vectors must match, otherwise an exception is thrown. More...
 
static void Add (IVector a, IVector b, IVector result)
 Sums two vectors and stores the result in the specified result vector. WARNING: dimensions of vectors must match, otherwise an exception is thrown. More...
 
static void Add (IVector a, IVector b, ref IVector result)
 Sums two vectors and stores the result in the specified result vector. WARNING: dimensions of operands must match, otherwise an exception is thrown. If dimensions of the result do not match then teh result is re-allocated. More...
 
static void SubtractPlain (IVector a, IVector b, IVector result)
 Subtracts two vectors (a - b ) and stores the result in the specified result vector. This is a plain version of the method that does not perform any consistency checks. WARNING: dimensions of vectors must match, otherwise an exception is thrown. More...
 
static void Subtract (IVector a, IVector b, IVector result)
 Subtracts two vectors (a - b ) and stores the result in the specified result vector. WARNING: dimensions of vectors must match, otherwise an exception is thrown. More...
 
static void Subtract (IVector a, IVector b, ref IVector result)
 Subtracts two vectors (a - b ) and stores the result in the specified result vector. WARNING: dimensions of operands must match, otherwise an exception is thrown. If dimensions of the result do not match then teh result is re-allocated. More...
 
static void OrthogonalProjectionPlain (IVector original, IVector onWhich, double onWhichProductSelf, IVector result, double tolerance=0.0)
 Calculates orthogonal projection of the original vector on the specified vector, and stores the projection in the specified result, where the inner project of the vector to which projection is performed is specified. More...
 
static void OrthogonalProjectionPlain (IVector original, IVector onWhich, IVector result, double tolerance=0.0)
 Calculates orthogonal projection of the original vector on the specified vector, and stores the projection in the specified result. More...
 
static void OrthogonalProjection (IVector original, IVector onWhich, double onWhichProductSelf, ref IVector result, double tolerance=0.0)
 Calculates orthogonal projection of the original vector on the specified vector, and stores the projection in the specified result, where the inner project of the vector to which projection is performed is specified. More...
 
static void OrthogonalProjection (IVector original, IVector onWhich, ref IVector result, double tolerance=0.0)
 Calculates orthogonal projection of the original vector on the specified vector, and stores the projection in the specified result. More...
 
static void ArrayAddPlain (IVector a, double scal, IVector result)
 Addition of a scalar to all components of a vector. This is a plain version of the method that does not perform any consistency checks. Vector operand must be defined (non-null). More...
 
static void ArrayAdd (IVector a, double scal, IVector result)
 Addition of a scalar to all components of a vector. Vector operand must be defined (non-null). More...
 
static void ArrayAdd (IVector a, double scal, ref IVector result)
 Addition of a scalar to all components of a vector. Vector operand must be defined (non-null). More...
 
static void ArraySubtractPlain (IVector a, double scal, IVector result)
 Subtraction of a scalar from all components of a vector. This is a plain version of the method that does not perform any consistency checks. Vector operand must be defined (non-null). More...
 
static void ArraySubtract (IVector a, double scal, IVector result)
 Subtraction of a scalar from all components of a vector. Vector operand must be defined (non-null). More...
 
static void ArraySubtract (IVector a, double scal, ref IVector result)
 Subtraction of a scalar to all components of a vector. Vector operand must be defined (non-null). More...
 
static void MultiplyPlain (IVector a, double scal, IVector result)
 Multiplication of a vector by a scalar. This is a plain version of the method that does not perform any consistency checks. Vector operand must be defined (non-null). More...
 
static void Multiply (IVector a, double scal, IVector result)
 Multiplication of a vector by a scalar. Vector operand must be defined (non-null). More...
 
static void Multiply (IVector a, double scal, ref IVector result)
 Multiplication of a vector by a scalar. Vector operand must be defined (non-null). More...
 
static void ScalePlain (IVector a, double scal, IVector result)
 Multiplication of a vector by a scalar. This is a plain version of the method that does not perform any consistency checks. Vector operand must be defined (non-null). More...
 
static void Scale (IVector a, double scal, IVector result)
 Multiplication of a vector by a scalar. Vector operand must be defined (non-null). More...
 
static void Scale (IVector a, double scal, ref IVector result)
 Multiplication of a vector by a scalar. Vector operand must be defined (non-null). More...
 
static void DividePlain (IVector a, double scal, IVector result)
 Division of a vector by a scalar. This is a plain version of the method that does not perform any consistency checks. Vector operand must be defined (non-null). More...
 
static void Divide (IVector a, double scal, IVector result)
 Division of a vector by a scalar. Vector operand must be defined (non-null). More...
 
static void Divide (IVector a, double scal, ref IVector result)
 Division of a vector by a scalar. Vector operand must be defined (non-null). More...
 
static double ScalarProductPlain (IVector a, IVector b)
 Scalar product of teo vectors. This is a plain version of the method that does not perform any consistency checks. More...
 
static double ScalarProduct (IVector a, IVector b)
 Scalar product of teo vectors. More...
 
static void DyadicProductPlain (IVector a, IVector b, IMatrix result)
 Calculates dyadic product of two vectors and stores the result in the specified result matrix. This is a plain version of the method that does not perform any consistency checks. WARNING: dimensions must match, otherwise an exception is thrown. More...
 
static void DyadicProduct (IVector a, IVector b, IMatrix result)
 Calculates dyadic product of two vectors and stores the result in the specified result matrix. WARNING: dimensions must match, otherwise an exception is thrown. More...
 
static void DyadicProduct (IVector a, IVector b, ref IMatrix result)
 Calculates dyadic product of two vectors and stores the result in the specified result matrix. WARNING: dimensions of operands must match, otherwise an exception is thrown. If dimensions of the result do not match then teh result is re-allocated. More...
 
static void CrossProductPlain (IVector a, IVector b, IVector result)
 Calculates a vector product (cross product) of two vectors and stores the result in the specified result vector. This is a plain version of the method that does not perform any consistency checks. WARNING: dimensions of all vectors must be 3, otherwise an exception is thrown. More...
 
static void CrossProduct (IVector a, IVector b, IVector result)
 Calculates a vector product (cross product) of two vectors and stores the result in the specified result vector. WARNING: dimensions of all vectors must be 3, otherwise an exception is thrown. More...
 
static void CrossProduct (IVector a, IVector b, ref IVector result)
 Calculates a vector product (cross product) of two vectors and stores the result in the specified result vector. WARNING: dimensions of operands must match, otherwise an exception is thrown. If dimensions of the result do not match then teh result is re-allocated. More...
 
static void VectorProductPlain (IVector a, IVector b, IVector result)
 Calculates a vector product (cross product) of two vectors and stores the result in the specified result vector. This is a plain version of the method that does not perform any consistency checks. WARNING: dimensions of all vectors must be 3, otherwise an exception is thrown. More...
 
static void VectorProduct (IVector a, IVector b, IVector result)
 Calculates a vector product (cross product) of two vectors and stores the result in the specified result vector. WARNING: dimensions of all vectors must be 3, otherwise an exception is thrown. More...
 
static void VectorProduct (IVector a, IVector b, ref IVector result)
 Calculates a vector product (cross product) of two vectors and stores the result in the specified result vector. WARNING: dimensions of operands must match, otherwise an exception is thrown. If dimensions of the result do not match then teh result is re-allocated. More...
 
static void ArrayProductPlain (IVector a, IVector b, IVector result)
 Calculates array product (element-by-element product) of two vectors and stores the result in the specified result vector. This is a plain version of the method that does not perform any consistency checks. WARNING: dimensions of all vectors must be 3, otherwise an exception is thrown. More...
 
static void ArrayProduct (IVector a, IVector b, IVector result)
 Calculates array product (element-by-element product) of two vectors and stores the result in the specified result vector. WARNING: dimensions of all vectors must be 3, otherwise an exception is thrown. More...
 
static void ArrayProduct (IVector a, IVector b, ref IVector result)
 Calculates array product (element-by-element product) of two vectors and stores the result in the specified result vector. WARNING: dimensions of operands must match, otherwise an exception is thrown. If dimensions of the result do not match then teh result is re-allocated. More...
 
static void ArrayQuotientPlain (IVector a, IVector b, IVector result)
 Calculates array quotient (element-by-element division) of two vectors and stores the result in the specified result vector. This is a plain version of the method that does not perform any consistency checks. WARNING: dimensions of all vectors must be 3, otherwise an exception is thrown. More...
 
static void ArrayQuotient (IVector a, IVector b, IVector result)
 Calculates array quotient (element-by-element division) of two vectors and stores the result in the specified result vector. WARNING: dimensions of all vectors must be 3, otherwise an exception is thrown. More...
 
static void ArrayQuotient (IVector a, IVector b, ref IVector result)
 Calculates array quotient (element-by-element division) of two vectors and stores the result in the specified result vector. WARNING: dimensions of operands must match, otherwise an exception is thrown. If dimensions of the result do not match then teh result is re-allocated. More...
 
static int GetHashCode (IVector vec)
 Returns hash code of the specified vector. More...
 
static bool Equals (IVector v1, IVector v2)
 Returns true if the specified vectors are equal, false if not. More...
 
static int GetHashFunctionInt (IVector vec)
 Returns an integer valued hash function of the specified vector object. More...
 
static string GetHashFunctionString (IVector vec)
 Returns a string valued hash function of the specified vector object. More...
 
static void OrthoNormalizeGramSchmidt (IList< IVector > original, ref IList< IVector > resOrthogonal, ref IVector resNorms, ref IVector auxProjection, double tolDependent=1e-10, bool normalize=false, int numRequestedVectors=0, IRandomGenerator rand=null, int maxExcessGenerated=5)
 Performs the Gramm-Schmidt orthogonalization procedure in order to calculate a set of orthonormal vectors from the specified set of arbitrary independent vectors. More...
 
static int OrthogonalizeGramSchmidt (IList< IVector > original, ref IList< IVector > resOrthogonal, ref IVector resNorms, ref IVector auxProjection, double tolDependent=1e-10, bool normalize=false, int numRequestedVectors=0, IRandomGenerator rand=null, int maxExcessGenerated=5)
 Performs the Gramm-Schmidt orthogonalization procedure in order to calculate a set of orthogonall vectors from the specified set of arbitrary independent vectors. More...
 
static void OrthoNormalizeGramSchmidtNonRobust (IList< IVector > original, ref IList< IVector > resOrthogonal, ref IVector resNorms, ref IVector auxProjection, double tolSize=0, bool normalize=false, bool modifiedGrammSchmidt=true)
 Performs the Gramm-Schmidt orthogonalization procedure in order to calculate a set of orthonormal vectors from the specified set of arbitrary independent vectors. More...
 
static void OrthogonalizeGramSchmidtNonRobust (IList< IVector > original, ref IList< IVector > resOrthogonal, ref IVector resNorms, ref IVector auxProjection, double tolSize=0, bool normalize=false, bool modifiedGrammSchmidt=true)
 Performs the Gramm-Schmidt orthogonalization procedure in order to calculate a set of orthogonall vectors from the specified set of arbitrary independent vectors. More...
 
static bool TestGramSchmidtOrthogonalization (int dim, int numRepetitions=1, double tol=1e-8, int outputLevel=0, IRandomGenerator randomGenerator=null, bool normalize=false, bool modifiedGrammSchmidt=true, bool nonRobust=false)
 Performs a test of Gramm-Schmidt orthogonalization on a set of random vectors. More...
 
static VectorBase operator+ (VectorBase v)
 Unary plus, returns the operand. More...
 
static VectorBase operator- (VectorBase v)
 Unary negation, returns the negative operand. More...
 
static VectorBase operator+ (VectorBase a, VectorBase b)
 Vector addition. More...
 
static VectorBase operator- (VectorBase a, VectorBase b)
 Vector subtraction. More...
 
static double operator* (VectorBase a, VectorBase b)
 Scalar product of two vectors. More...
 
static VectorBase operator* (VectorBase a, double b)
 Product of a vector by a scalar. More...
 
static VectorBase operator* (double a, VectorBase b)
 Product of a vector by a scalar. More...
 
static VectorBase operator/ (VectorBase a, double b)
 Vector subtraction. More...
 
static string ToString (IVector vec)
 Returns a string representation of the specified vector in a standard IGLib form. More...
 
static string ToStringMath (IVector vec)
 Returns a string representation of the specified vector in a standard IGLib form (Mathematica-like format but with C representation of numbers). More...
 
static string ToString (IVector vec, string elementFormat)
 Returns a string representation of the specified vector in a standard IGLib form, with the specified format for elements of the vector. More...
 
static string ToStringMath (IVector vec, string elementFormat)
 Returns a string representation of the specified vector in a standard IGLib form (Mathematica-like format but with C representation of numbers), with the specified format for elements of the vector. More...
 
static void SaveJson (IVector vec, string filePath)
 Saves (serializes) the specified vector to the specified JSON file. File is owerwritten if it exists. More...
 
static void SaveJson (IVector vec, string filePath, bool append)
 Saves (serializes) the specified vector to the specified JSON file. If the file already exists, contents either overwrites the file or is appended at the end, dependent on the value of the append flag. More...
 
static void LoadJson (string filePath, ref IVector vecRestored)
 Restores (deserializes) a vector from the specified file in JSON format. More...
 
static void SaveCsv (IVector vec, string filePath)
 Saves the specified vector to a CSV file. It the specified file already exists then it is overwritten. Constant UtilStr.DefaultCsvSeparator is used as separator. More...
 
static void SaveCsv (IVector vec, string filePath, string separator)
 Saves the specified vector to a CSV file. It the specified file already exists then it is overwritten. More...
 
static void SaveCsv (IVector vec, string filePath, bool append)
 Saves the specified vector to a CSV file. Constant UtilStr.DefaultCsvSeparator is used as separator in CSV. More...
 
static void SaveCsv (IVector vec, string filePath, string separator, bool append)
 Saves the specified vector to a CSV file. More...
 
static void LoadCsv (string filePath, ref IVector vecRestored)
 Reads a vector from a CSV file. Constant Str.DefaultCsvSeparator is used as separator in CSV file. If there are no components then a null vector is returned by this method (no exceptions thrown). If there are more than one rows in the CSV file then vector is read from the first row. More...
 
static void LoadCsv (string filePath, string separator, ref IVector vecRestored)
 Reads a vector written in CSV format from a file. If there are no components then a null vector is returned by this method (no exceptions thrown). If there are more than one rows in the CSV file then vector is read from the first row. More...
 
static void LoadCsv (string filePath, int rowNum, ref IVector vecRestored)
 Reads a vector from the specified row of a CSV file. Constant UtilStr.DefaultCsvSeparator is used as CSV separator. If the specified row does not exisist in the file then exception is thrown. More...
 
static void LoadCsv (string filePath, int rowNum, string separator, ref IVector vecRestored)
 Reads a vector from the specified row of a CSV file. If the specified row does not exisist in the file then exception is thrown. More...
 

Protected Member Functions

void CopyFromMatNetNumericsVector (Vector_MathNetNumerics v)
 Copies values from the specified MathNet Numerics vector. More...
 
Vector_MathNetNumerics GetCopyMathNetNumerics ()
 Creates and returns a newly allocated MathNet Numerics representation of the current vector. More...
 

Protected Attributes

double[] _elements
 
int _length
 
bool _mathNetNumericsConsistent = false
 

Properties

override int Length [get]
 Gets dimension of the vector. More...
 
virtual int LengthSetter [set]
 Sets the dimension of the current vector. This setter must be used very restrictively - only in setters that can change vector dimension. Setter is defined separately from getter because the base class' property does not define a getter. More...
 
override double this[int i] [get, set]
 Gets or sets the element indexed by i in the Vector. More...
 
virtual bool IsCopyMathNetNumericsConsistent [get, protected set]
 Tells whether the internal MathNet Numerics representation of the current vector is consistent with the current vector. The MathNet Numerics representation is used for operations that are used from that library such as different kinds of decompositions. More...
 
virtual Vector_MathNetNumerics CopyMathNetNumerics [get]
 Gets the internal MathNet Numerics representation of the current vector. Representation is created on demand. However, the same copy is returned as long as it is consistent with the current matrix. Use GetCopyMathNet() to create a new copy each time. More...
 
- Properties inherited from IG.Num.VectorBase
abstract int Length [get]
 Gets dimension of the vector. More...
 
abstract double this[int i] [get, set]
 Gets or sets the element indexed by i in the Vector. More...
 
virtual double Norm [get]
 Gets Euclidean norm of the vector. More...
 
virtual double Norm2 [get]
 Gets Euclidean norm of the vector. More...
 
virtual double NormEuclidean [get]
 Gets Euclidean norm of the vector. More...
 
virtual double SquaredNorm [get]
 Squared Euclidean norm, sum of squared components. More...
 
virtual double Norm1 [get]
 1-norm (Manhattan norm or Taxicab norm), sum of absolute values of components. More...
 
virtual double NormInf [get]
 Infinity-norm, maximum absolute value of any component. More...
 
static VectorStore VectorStore [get]
 Gets the matrix store for recycling auxiliary matrices. More...
 

Private Member Functions

object ICloneable. Clone ()
 Returns a deep copy of a vector. More...
 

Private Attributes

Vector_MathNetNumerics _copyMathNetNumerics
 

Detailed Description

Real vector class.

$A Igor Jan08 Jul10 Nov10;

Constructor & Destructor Documentation

IG.Num.Vector.Vector ( IVector  vec)
inline

Constructs a vector from aanother array.

Parameters
vecVector whose components are copied to the current vector.
See also
Create
IG.Num.Vector.Vector ( int  n)
inline

Constructs an n-dimensional vector of zeros.

Parameters
nDimensionality of vector.
IG.Num.Vector.Vector ( int  n,
int  which 
)
inline

Constructs an n-dimensional unit vector for i'th coordinate.

Parameters
nDimensionality of vector.
whichSpecifies which unit vector is constructed (which components equals one).
IG.Num.Vector.Vector ( int  n,
double  value 
)
inline

Constructs an n-dimensional constant vector with all components initialized to the specified value.

Parameters
nDimensionality of vector.
valueValue to which all components are set.
IG.Num.Vector.Vector ( IList< double >  components)
inline

Constructs a vector from a list of elements by copying its elements.

Parameters
componentsObject implementing IList interface that contains vector elements.
IG.Num.Vector.Vector ( double[]  components,
bool  copyElements = true 
)
inline

Constructs a vector from a 1-D array, either by directly using the array or by copying its elements.

Parameters
componentsOne-dimensional array of vector elements.
copyElementsIf true then elements of the provided array are copied (default), otherwise the array is directly used as internal structure containing elementts.
IG.Num.Vector.Vector ( params double[]  components)
inline

Constructs a vector from a 1-D array or from listed variable number of components.

Elements of array are copied.

Parameters
componentsOne-dimensional array of vector elements.
See also
Create(double[])
IG.Num.Vector.Vector ( VectorBase_MathNetNumerics  vec)
inline

Constructs a vector from a 1-D array, directly using the provided array as internal data structure.

Parameters
vecOne-dimensional array of doubles.
See also
Create

Member Function Documentation

static Vector IG.Num.Vector.Create ( double[]  components)
inlinestatic

Constructs a vector from a 1-D array.

static Vector IG.Num.Vector.Create ( VectorBase_MathNetNumerics  vec)
inlinestatic

Constructs a vector as a copy of a MathNetVector object.

static Vector IG.Num.Vector.Create ( IVector  vec)
inlinestatic

Constructs a vector as a copy of another Vector object.

Parameters
vecVector whose elements are used for the newly created vector.
static Vector IG.Num.Vector.Random ( int  n,
IRandomGenerator  rand = null 
)
inlinestatic

Generates vector with random elements uniformly distributed on [0, 1).

Parameters
nDimensionality of vector.
randRandom number generator used to generate vector elements. If null then a global generator is taken.
Returns
An n-dimensional vector with uniformly distributedrandom elements in [0, 1) interval.

References IG.Num.RandomGenerator.Global, and IG.Num.VectorBase.SetRandom().

Referenced by IG.Num.SpeedTestCpu.TestComputationalTimesCholesky_Base(), IG.Num.SpeedTestCpu.TestComputationalTimesCholesky_IGLib(), IG.Num.SpeedTestCpu.TestComputationalTimesLdlt_Base(), IG.Num.SpeedTestCpu.TestComputationalTimesLU_Base(), IG.Num.SpeedTestCpu.TestComputationalTimesLU_IGLib(), IG.Num.SpeedTestCpu.TestComputationalTimesQR_IGLib(), and IG.Num.VectorBase.TestGramSchmidtOrthogonalization().

static Vector IG.Num.Vector.Ones ( int  n)
inlinestatic

Generates an d2-dimensional vector filled with 1.

Parameters
nDimensionality of vector.
static Vector IG.Num.Vector.Zeros ( int  n)
inlinestatic

Generates an d2-dimensional vector filled with 0.

Parameters
nDimensionality of vector.
static Vector IG.Num.Vector.BasisVector ( int  n,
int  i 
)
inlinestatic

Generates an d2-dimensional unit vector for i-th coordinate.

Parameters
nDimensionality of vector.
iCoordinate index.
void IG.Num.Vector.CopyFromMatNetNumericsVector ( Vector_MathNetNumerics  v)
inlineprotected

Copies values from the specified MathNet Numerics vector.

Parameters
vVector from which elements are copied.
Vector_MathNetNumerics IG.Num.Vector.GetCopyMathNetNumerics ( )
inlineprotected

Creates and returns a newly allocated MathNet Numerics representation of the current vector.

Vector IG.Num.Vector.GetCopyThis ( )
inline

Creates and returns a copy of the current vector, which is of the same type as the current vector.

override VectorBase IG.Num.Vector.GetCopyBase ( )
inlinevirtual

Creates and returns a copy of the current vector, which is of the same type as the current vector.

Implements IG.Num.VectorBase.

Vector IG.Num.Vector.GetNewThis ( int  length)
inline

Creates and returns a new vector of the specified dimension in such a way that the type of the returned vector is the same as that of the current vector.

Parameters
lengthDimension of the returned vector.
override VectorBase IG.Num.Vector.GetNewBase ( int  length)
inlinevirtual

Creates and returns a new vector of the specified dimension in such a way that the type of the returned vector is the same as that of the current vector.

Parameters
lengthDimension of the returned vector.

Implements IG.Num.VectorBase.

Vector IG.Num.Vector.GetNewThis ( )
inline

Creates and returns a new vector with the same dimension and of the same type as the current vector.

override VectorBase IG.Num.Vector.GetNewBase ( )
inlinevirtual

Creates and returns a new vector with the same dimension and of the same type as the current vector.

Implements IG.Num.VectorBase.

virtual Matrix IG.Num.Vector.GetNewMatrixThis ( int  rowCount,
int  columnCount 
)
inlinevirtual

Creates and returns a new matrix with the specified dimensona, and of a type that is consistent with the type of the current vector.

Parameters
rowCountNumber of rows of the returned matrix.
columnCountNumber of rows of the returned matrix.
Returns
A matrix with specified dimensions, whose type is consistent with the type of the current vector.
override MatrixBase IG.Num.Vector.GetNewMatrixBase ( int  rowCount,
int  columnCount 
)
inlinevirtual

Creates and returns a new matrix with the specified dimensona, and of a type that is consistent with the type of the current vector.

Parameters
rowCountNumber of rows of the returned matrix.
columnCountNumber of rows of the returned matrix.
Returns
A matrix with specified dimensions, whose type is consistent with the type of the current vector.

Implements IG.Num.VectorBase.

Matrix IG.Num.Vector.GetNewMatrixThis ( )
inline

Creates and returns a new matrix of a type that is consistent with the type of the current vector, and with both dimensions equal to the dimension of the current vector.

override MatrixBase IG.Num.Vector.GetNewMatrixBase ( )
inlinevirtual

Creates and returns a new matrix of a type that is consistent with the type of the current vector, and with both dimensions equal to the dimension of the current vector.

Implements IG.Num.VectorBase.

object ICloneable. IG.Num.Vector.Clone ( )
inlineprivate

Returns a deep copy of a vector.

override int IG.Num.Vector.GetHashCode ( )
inline

Returns the hash code (hash function) of the current vector.

This method calls the VectorBase.GetHashCode to calculate the hash code, which is standard for all implementations of the IVector interface.

Two vectors that have the same dimensions and equal elements will produce the same hash codes.

Probability that two different vectors will produce the same hash code is small but it exists.

Overrides the object.GetHashCode method.

References IG.Num.VectorBase.GetHashCode().

override bool IG.Num.Vector.Equals ( Object  obj)
inline

Returns a value indicating whether the specified object is equal to the current vector.

True is returned if the object is a non-null vector (i.e. it implements the IVector interface), and has the same dimension and equal elements as the current vector.

This method calls the VectorBase.Equals to obtain the returned value, which is standard for all implementations of the IVector interface.

Overrides the object.Equals method.

References IG.Num.VectorBase.Equals().

Member Data Documentation

double [] IG.Num.Vector._elements
protected
int IG.Num.Vector._length
protected
Vector_MathNetNumerics IG.Num.Vector._copyMathNetNumerics
private
bool IG.Num.Vector._mathNetNumericsConsistent = false
protected

Property Documentation

virtual int IG.Num.Vector.LengthSetter
setprotected

Sets the dimension of the current vector. This setter must be used very restrictively - only in setters that can change vector dimension. Setter is defined separately from getter because the base class' property does not define a getter.

override double IG.Num.Vector.this[int i]
getset

Gets or sets the element indexed by i in the Vector.

Parameters
iElement index, 0 - based.
virtual bool IG.Num.Vector.IsCopyMathNetNumericsConsistent
getprotected set

Tells whether the internal MathNet Numerics representation of the current vector is consistent with the current vector. The MathNet Numerics representation is used for operations that are used from that library such as different kinds of decompositions.

Currrently, an internal flag indicating consistency of the MathNet matrix is not used. Every time this property is required, the consistence is actually verified by comparing values. There may be derived matrix classes where the falg is actually used. These must keep track when anything in the matrix changes and invalidate the flag on each such event.

virtual Vector_MathNetNumerics IG.Num.Vector.CopyMathNetNumerics
get

Gets the internal MathNet Numerics representation of the current vector. Representation is created on demand. However, the same copy is returned as long as it is consistent with the current matrix. Use GetCopyMathNet() to create a new copy each time.


The documentation for this class was generated from the following file: