#include <PtvGen_Type.h>
Public Methods | |
| Ptv(Type) () | |
| Ptv(Type) (Type x_, Type y_, Type z_) | |
| Ptv(Type) (Type a[], int n) | |
| Ptv(Type) (const Ptv(Type) &X) | |
| Ptv(Type) (const Ptv(Type), 0 &X) | |
| ~Ptv(Type) () | |
| bool | ok () const |
| int | size () const |
| void | fill (Type value) |
| void | fill (Type v1, Type v2, Type v3) |
| Type& | operator() (int i) |
| Type | operator() (int i) const |
| bool | indexOk (int i) const |
| Ptv(Type)& | operator= (const Type &value) |
| Ptv(Type)& | operator= (const Ptv(Type) &X) |
| void | operator= (const VecSimple(Type) &X) |
| bool | operator== (const Ptv(Type) &X) const |
| bool | operator!= (const Ptv(Type) &X) const |
| bool | operator> (const Ptv(Type) &y) const |
| bool | operator>= (const Ptv(Type) &y) const |
| bool | operator< (const Ptv(Type) &y) const |
| bool | operator<= (const Ptv(Type) &y) const |
| bool | eq (const Ptv(Type) &y, real tolerance=comparison_tolerance) const |
| bool | lt (const Ptv(Type) &y, real tolerance=comparison_tolerance) const |
| bool | le (const Ptv(Type) &y, real tolerance=comparison_tolerance) const |
| bool | gt (const Ptv(Type) &y, real tolerance=comparison_tolerance) const |
| bool | ge (const Ptv(Type) &y, real tolerance=comparison_tolerance) const |
| Ptv(Type) | operator+ (const Ptv(Type) &X) const |
| Ptv(Type) | operator- (const Ptv(Type) &X) const |
| Ptv(Type) | operator+ (const Type &value) const |
| Ptv(Type) | operator- (const Type &value) const |
| Ptv(Type) | operator * (const Type &value) const |
| Ptv(Type) | operator/ (const Type &value) const |
| void | add (Ptv(Type) &X, Ptv(Type) &Y) |
| void | add (Type a, Ptv(Type) &X, Type b, Ptv(Type) &Y) |
| void | add (const Ptv(Type) &X) |
| void | add (Type a, Ptv(Type) &X) |
| void | fillMin (const Ptv(Type) &X) |
| void | fillMax (const Ptv(Type) &X) |
| Type | inner (const Ptv(Type) &X) const |
| void | prod (const Ptv(Type) &X, const Ptv(Type) &Y) |
| real | distance (const Ptv(Type) &y) const |
| real | distance2 (const Ptv(Type) &y) const |
| real | norm (Norm_type lp) const |
| real | norm () const |
| void | mult (Type a) |
| real | sqr () const |
| Type | sum () const |
| void | printAsIndex (Os os) const |
| String | printAsIndex () const |
| void | print (Os os) const |
| void | scan (Is is) |
| Type* | getPtr0 () |
| Type* | getPtr1 () |
Friends | |
| class | Ptv(Type) |
| void | setEqual (VecSimple(Type) &V, const Ptv(Type) &X) |
| Os& | operator<< (Os &os, const Ptv(Type) &x) |
| Is& | operator>> (Is &is, Ptv(Type) &x) |
NAME: Ptv(Type) - simple vector for points, and optimized for 1D, 2D and 3D
DESCRIPTION:
The class implements a vector type opimized for lengths 1, 2 or 3. The class has a static array hardcoded (of length "PtvDIM"), and if the "Ptv" vector is to be larger than the static array, the object uses a dynamic array instead. Usually the static array has length 3, so most applications will make use of this efficient array and avoid dynamic allocation. The interface of "Ptv" is similar to "VecSimple". Most of the "Ptv" functions are, however, much more efficient than the corresponding functions in class "VecSimple". This is true as long as the internal static array in "Ptv" can be used.
Although the official name of this class is "Ptv", it is actually internally named as "PtvGen(Type,0)". Optimized versions for representation in 1D, 2D and 3D are available as "PtvGen(Type,1)" etc. The official names for these three versions are "Ptv1d", "Ptv2d" and "Ptv3d".
The public interface consists of various operations such as subscripting (w/array-range-check if desired), assignment operators, fill functions, print and scan functions, etc. The subscript operator assumes that the base equals 1.
|
|
Several constructors are available. The constructor without parameters allocates no memory. To allocate the proper amount of memory at a later stage, the "redim" function can be used. Another constructor takes the number of entries in the vector as parameter and allocates memory for the corresponding vector representation. There are also constructors for 2D and 3D points. A copy-constructor is also available. The specialized 1D, 2D and 3D versions can be automatically converted to the generic "Ptv" type. Assuming consistent dimensions of a "Ptv" object, also the reverse conversions are possible. To initialize the vector entries one can use the member functions "fill" or "operator()". |
|
|
See documentation of one of the overloaded constructor. |
|
|
See documentation of one of the overloaded constructor. |
|
|
See documentation of one of the overloaded constructor. |
|
|
See documentation of one of the overloaded constructor. |
|
|
|
|
|
See documentation of one of the overloaded functions. |
|
|
See documentation of one of the overloaded functions. |
|
|
See documentation of one of the overloaded functions. |
|
|
finds the sum of two vectors, see comments in the function declarations. |
|
|
compute the distance between this and the supplied "Ptv", that is
|| this - y ||
|
|
|
compute the square of the distance between this and the supplied "Ptv", that is
|| this - y ||^2
|
|
|
true if the equality holds (within the supplied comparison tolerance) for all components in the "Ptv". |
|
|
|
|
|
|
|
|
same as "fillMin", except the largest values are found. |
|
|
compares each component of "this" and the supplied object and updates each component of "this" to hold the smallest value of each component in the two compared objects. For example, if this object is "1 5" and the supplied is "4 2", this will be "1 2" after the function has been called. |
|
|
true if the inequality holds (within the supplied comparison tolerance) for all components in the "Ptv". |
|
|
returns access to the internal C array and assumes that the base is 0 (note that internally in this class, the base is 1). The "getPtr0" simply sends the address of the first element in the array. This is the common function for sending a Diffpack vector to a C function requiring a pointer (for a standard C array). Also when a Diffpack vector "v" is to be sent to a Fortran subroutine or function, "v.getPtr0()" is the correct data structure to send. |
|
|
returns access to the internal C array and assumes that the base is 1. The "getPtr1" simply sends the address of the first array element 'minus one'. A common use is when the object is to be transferred to C functions where arrays are assumed to have "[1]" as their first index (e.g., Numerical Recipes routines). Although Fortran arrays usually start with unit base, sending the return value of "getPtr1" to a Fortran subroutine will actually send the address to the array minus one and the calculations will be wrong. |
|
|
true if the inequality holds (within the supplied comparison tolerance) for all components in the "Ptv". |
|
|
|
|
|
|
|
|
true if the inequality holds (within the supplied comparison tolerance) for all components in the "Ptv". |
|
|
true if the inequality holds (within the supplied comparison tolerance) for all components in the "Ptv". |
|
|
multiply all components in the "Ptv" with the supplied value. |
|
|
See documentation of one of the overloaded functions. |
|
|
The version with no arguments computes the l2 norm of the "Ptv". The version that takes an "enum" variable "Norm_type" computes the specified norm for the "Ptv" (L1, L2, Linf). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
writes the content of the vector in a format that can be read by "scan". |
|
|
See documentation of one of the overloaded functions. |
|
|
print the "Ptv" on the form
(x1,x2,x3)
|
|
|
finds the cross product of two vectors "X" and "Y". This function is not available for the specialized 1D and 2D versions. |
|
|
reads the vector from an "Is". The format can be like ""1.1 4.0"" or ""(1.1,4)"". Note that the length of the vector must be known before "scan" can read the strings on the given form. However, if the length is unknown (that is, the length is zero from the default initialization in the constructor without arguments and "redim" has not been called), the input string to scan must start with an integer reflecting the length. For example, ""2 1.1 4.0"" or ""2 (1.1,4.0)"". Here is another way of reading a "Ptv" without knowing its size:
SetOfNo(Type) set(6); set.scan ('(',',',')'); set.convert2vector(Ptv&)
|
|
|
|
|
|
the inner product of "this" with itself. |
|
|
the sum of all the components in the "Ptv". |
|
|
Several constructors are available. The constructor without parameters allocates no memory. To allocate the proper amount of memory at a later stage, the "redim" function can be used. Another constructor takes the number of entries in the vector as parameter and allocates memory for the corresponding vector representation. There are also constructors for 2D and 3D points. A copy-constructor is also available. The specialized 1D, 2D and 3D versions can be automatically converted to the generic "Ptv" type. Assuming consistent dimensions of a "Ptv" object, also the reverse conversions are possible. To initialize the vector entries one can use the member functions "fill" or "operator()". |
|
|
is defined in terms of the "print" function. |
|
|
is defined in terms of the "scan" function. |
|
|
set the supplied vector to be equal to the supplied "Ptv". \iten["inner"] - computes the inner product of this "Ptv" and the supplied "Ptv" object. |