Diffpack Documentation


Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

Ptv(Type) Class Reference

simple vector for points, and optimized for 1D, 2D and 3D. More...

#include <PtvGen_Type.h>

List of all members.

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)
Osoperator<< (Os &os, const Ptv(Type) &x)
Isoperator>> (Is &is, Ptv(Type) &x)


Detailed Description

simple vector for points, and optimized for 1D, 2D and 3D.

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.


Constructor & Destructor Documentation

Ptv(Type)::Ptv_Type ( )
 

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()".

Ptv(Type)::Ptv_Type ( Type x_,
Type y_,
Type z_ )
 

See documentation of one of the overloaded constructor.

Ptv(Type)::Ptv_Type ( Type a[],
int n )
 

See documentation of one of the overloaded constructor.

Ptv(Type)::Ptv_Type ( const Ptv(Type) & X )
 

See documentation of one of the overloaded constructor.

Ptv(Type)::Ptv_Type ( const Ptv(Type),
0 & X )
 

See documentation of one of the overloaded constructor.

Ptv(Type)::~Ptv(Type) ( ) [inline]
 


Member Function Documentation

void Ptv(Type)::add ( Type a,
Ptv(Type) & X )
 

See documentation of one of the overloaded functions.

void Ptv(Type)::add ( const Ptv(Type) & X )
 

See documentation of one of the overloaded functions.

void Ptv(Type)::add ( Type a,
Ptv(Type) & X,
Type b,
Ptv(Type) & Y )
 

See documentation of one of the overloaded functions.

void Ptv(Type)::add ( Ptv(Type) & X,
Ptv(Type) & Y )
 

finds the sum of two vectors, see comments in the function declarations.

real Ptv(Type)::distance ( const Ptv(Type) & y ) const
 

compute the distance between this and the supplied "Ptv", that is

      || this - y || 

real Ptv(Type)::distance2 ( const Ptv(Type) & y ) const
 

compute the square of the distance between this and the supplied "Ptv", that is

      || this - y ||^2 

bool Ptv(Type)::eq ( const Ptv(Type) & y,
real tolerance = comparison_tolerance ) const
 

true if the equality holds (within the supplied comparison tolerance) for all components in the "Ptv".

void Ptv(Type)::fill ( Type v1,
Type v2,
Type v3 )
 

void Ptv(Type)::fill ( Type value )
 

void Ptv(Type)::fillMax ( const Ptv(Type) & X )
 

same as "fillMin", except the largest values are found.

void Ptv(Type)::fillMin ( const Ptv(Type) & X )
 

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.

bool Ptv(Type)::ge ( const Ptv(Type) & y,
real tolerance = comparison_tolerance ) const
 

true if the inequality holds (within the supplied comparison tolerance) for all components in the "Ptv".

Type * Ptv(Type)::getPtr0 ( )
 

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.

Type * Ptv(Type)::getPtr1 ( )
 

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.

bool Ptv(Type)::gt ( const Ptv(Type) & y,
real tolerance = comparison_tolerance ) const
 

true if the inequality holds (within the supplied comparison tolerance) for all components in the "Ptv".

bool Ptv(Type)::indexOk ( int i ) const
 

Type Ptv(Type)::inner ( const Ptv(Type) & X ) const
 

bool Ptv(Type)::le ( const Ptv(Type) & y,
real tolerance = comparison_tolerance ) const
 

true if the inequality holds (within the supplied comparison tolerance) for all components in the "Ptv".

bool Ptv(Type)::lt ( const Ptv(Type) & y,
real tolerance = comparison_tolerance ) const
 

true if the inequality holds (within the supplied comparison tolerance) for all components in the "Ptv".

void Ptv(Type)::mult ( Type a )
 

multiply all components in the "Ptv" with the supplied value.

real Ptv(Type)::norm ( ) const
 

See documentation of one of the overloaded functions.

real Ptv(Type)::norm ( Norm_type lp ) const
 

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).

bool Ptv(Type)::ok ( ) const
 

Ptv(Type) Ptv(Type)::operator * ( const Type & value ) const
 

bool Ptv(Type)::operator!= ( const Ptv(Type) & X ) const
 

Type Ptv(Type)::operator() ( int i ) const
 

Type & Ptv(Type)::operator() ( int i )
 

Ptv(Type) Ptv(Type)::operator+ ( const Type & value ) const
 

Ptv(Type) Ptv(Type)::operator+ ( const Ptv(Type) & X ) const
 

Ptv(Type) Ptv(Type)::operator- ( const Type & value ) const
 

Ptv(Type) Ptv(Type)::operator- ( const Ptv(Type) & X ) const
 

Ptv(Type) Ptv(Type)::operator/ ( const Type & value ) const
 

bool Ptv(Type)::operator< ( const Ptv(Type) & y ) const
 

bool Ptv(Type)::operator<= ( const Ptv(Type) & y ) const
 

void Ptv(Type)::operator= ( const VecSimple(Type) & X )
 

Ptv(Type) & Ptv(Type)::operator= ( const Ptv(Type) & X )
 

Ptv(Type) & Ptv(Type)::operator= ( const Type & value )
 

bool Ptv(Type)::operator== ( const Ptv(Type) & X ) const
 

bool Ptv(Type)::operator> ( const Ptv(Type) & y ) const
 

bool Ptv(Type)::operator>= ( const Ptv(Type) & y ) const
 

void Ptv(Type)::print ( Os os ) const
 

writes the content of the vector in a format that can be read by "scan".

String Ptv(Type)::printAsIndex ( ) const
 

See documentation of one of the overloaded functions.

void Ptv(Type)::printAsIndex ( Os os ) const
 

print the "Ptv" on the form

      (x1,x2,x3)       

void Ptv(Type)::prod ( const Ptv(Type) & X,
const Ptv(Type) & Y )
 

finds the cross product of two vectors "X" and "Y". This function is not available for the specialized 1D and 2D versions.

void Ptv(Type)::scan ( Is is )
 

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&)
This means that we create a set of max 6 numbers as members. Each member is recognized by beginning with a '(' and ending with ')', whereas a comma separates members. Then you can declare a "Ptv(real) without knowing the length and read it as, e.g., (3.1,3.2,-1.0).

int Ptv(Type)::size ( ) const
 

real Ptv(Type)::sqr ( ) const
 

the inner product of "this" with itself.

Type Ptv(Type)::sum ( ) const
 

the sum of all the components in the "Ptv".


Friends And Related Function Documentation

Ptv(Type)::Ptv_Type [friend]
 

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()".

Os & operator<< ( Os & os,
const Ptv(Type) & x ) [friend]
 

is defined in terms of the "print" function.

Is & operator>> ( Is & is,
Ptv(Type) & x ) [friend]
 

is defined in terms of the "scan" function.

void setEqual ( VecSimple(Type) & V,
const Ptv(Type) & X ) [friend]
 

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.


The documentation for this class was generated from the following file:
Copyright © 2003 inuTech GmbH. All rights reserved.