Diffpack Documentation


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

Vec(Type) Class Reference

one-dimensional vector with arithmetic operations (base=1). More...

#include <Vec_Type.h>

Inheritance diagram for Vec(Type)::

VecSort_Type Vector_Type VecSimple_Type HandleId VecSimplest_Type ArrayGen_Type ArrayGenSel_Type List of all members.

Public Methods

 Vec(Type) ()
 Vec(Type) (int length)
 Vec(Type) (Type *a, int n, int base=0)
 Vec(Type) (const Vec(Type) &X)
 Vec(Type) (const Vector(prm_Type) &pm)
virtual ~Vec(Type) ()
virtual int getNoEntries () const
virtual real getStorage () const
virtual bool makeItSimilar (Handle(Vector(Type)) &v) const
virtual bool redim (const Vector(prm_Type) &pm)
bool redim (int n)
bool redim (Type *a, int n, int base=0)
virtual void fill (const Vector(Type) &X)
virtual void fill (const Type &a)
Vec(Type)& operator= (const Vec(Type) &X)
Vec(Type)& operator= (const Type &a)
void fill (Type start, Type stop)
virtual void assemble (const Vec(Type) &ev, const VecSimple(int) &idx_trans, int elm_no)
virtual void add (const Vector(Type) &yb, const Vector(Type) &zb)
virtual void add (const Vector(Type) &yb, char s, const Vector(Type) &zb)
virtual void add (const Vector(Type) &yb, Type b, const Vector(Type) &zb)
virtual void add (Type a, const Vector(Type) &yb, Type b, const Vector(Type) &zb)
virtual void add (const Vector(Type) &y, int power, Type front_factor)
virtual void add (Type value)
virtual void mult (Type value)
virtual void apply (Func(Type) f)
virtual real norm (Norm_type lp=l2) const
virtual real normDiff (const Vector(Type) &y, Norm_type lp=l2) const
virtual Type inner (const Vector(Type) &yb) const
virtual void randomize (real low=-1, real high=1, real seed=1)
virtual void print (Os os, const char *header=NULL, int nentries_per_line=3) const
virtual void printAscii (Os os, const char *header=NULL) const
virtual void scan (Is is)
virtual void save (const char *filename, const char *name="X") const
virtual void load (const char *filename, const char *name="X")

Friends

Osoperator<< (Os &os, const Vec(Type) &x)
Isoperator>> (Is &is, Vec(Type) &x)

Detailed Description

one-dimensional vector with arithmetic operations (base=1).

NAME: Vec(Type) - one-dimensional vector with arithmetic operations (base=1)

DESCRIPTION:

The class is derived from "VecSort(Type)" and "Vector(Type)". Additional functions perform various arithmetic operations such as calculating vector norms, inner products, sum of vectors etc. For the class to have meaning, "Type" must define basic arithmetic operations such as "*", "/", "+" and "-". In addition the operators ">", "<", "==" and "!=" must be defined. If a general base is desired for the subscripting operator, the class "ArrayGen(Type)" can be used (that class can also take more than one subscript).

Since the class is also derived from "Vector(Type)", it is part of a class hierarchy of vectors. The virtual functions of this class can hence be accessed by a "Vector(Type)" pointer, or better, by a "Handle(Vector)" or "LinEqVector" object/pointer. "Vector" and "LinEqVector" are shell classes for the matrix hiearchy. Other classes in the hierarchy implement vectors represented as arbitrary-dimensional arrays, see "ArrayGen(Type)".


Constructor & Destructor Documentation

Vec(Type)::Vec_Type ( )
 

In addition to the standad constructor taking an integer "length" argument (see documentation of class "VecSimple(Type)"), there is a copy constructor. Moreover, the constructor accepting a "Vector_prm(Type)" object is in common for all classes derived from "Vector(Type)".

Vec(Type)::Vec_Type ( int length )
 

See documentation of one of the overloaded constructor.

Vec(Type)::Vec_Type ( Type * a,
int n,
int base = 0 )
 

See documentation of one of the overloaded constructor.

Vec(Type)::Vec_Type ( const Vec(Type) & X )
 

See documentation of one of the overloaded constructor.

Vec(Type)::Vec_Type ( const Vector(prm_Type) & pm )
 

See documentation of one of the overloaded constructor.

Vec(Type)::~Vec(Type) ( ) [virtual]
 


Member Function Documentation

void Vec(Type)::add ( Type value ) [virtual]
 

See documentation of one of the overloaded functions.

Reimplemented in ArrayGenSel(Type).

void Vec(Type)::add ( const Vector(Type) & y,
int power,
Type front_factor ) [virtual]
 

See documentation of one of the overloaded functions.

Reimplemented in ArrayGenSel(Type).

void Vec(Type)::add ( Type a,
const Vector(Type) & yb,
Type b,
const Vector(Type) & zb ) [virtual]
 

See documentation of one of the overloaded functions.

Reimplemented from Vector(Type).

Reimplemented in ArrayGenSel(Type).

void Vec(Type)::add ( const Vector(Type) & yb,
Type b,
const Vector(Type) & zb ) [virtual]
 

See documentation of one of the overloaded functions.

Reimplemented from Vector(Type).

Reimplemented in ArrayGenSel(Type).

void Vec(Type)::add ( const Vector(Type) & yb,
char s,
const Vector(Type) & zb ) [virtual]
 

See documentation of one of the overloaded functions.

Reimplemented from Vector(Type).

Reimplemented in ArrayGenSel(Type).

void Vec(Type)::add ( const Vector(Type) & yb,
const Vector(Type) & zb ) [virtual]
 

computes a sum of vectors. Some of the vectors can be multiplied by a scalar. There are several overloaded instances (see example below). Some of the "add" functions take "Vec(Type)" objects as arguments while others, that are virtual, take "Vector(Type)" objects as arguments. The latter "add" instances are convenient in the "Vector(Type)" hierarchy of vectors. There are also global "add" functions that are not members of any class, for example one can call "add(x,y,''-'',z)", where "x", "y", "z" are "Vec(Type)", which sets "x" equal to the difference of "y" and "z". This function is defined as "x.add(y,''-'',z)". Another "add" function takes a vector `$`y`$` and an integer power "p" as argument. The numerical operation is to add "y(i)^p" to each entry in the class vector.

Reimplemented from Vector(Type).

Reimplemented in ArrayGenSel(Type).

void Vec(Type)::apply ( Func(Type) f ) [virtual]
 

given a function pointer "f", this transformation is applied to every entry of the vector object.

Reimplemented in ArrayGenSel(Type).

void Vec(Type)::assemble ( const Vec(Type) & ev,
const VecSimple(int) & idx_trans,
int elm_no ) [virtual]
 

adds a small vector to a large, global vector. The contributions from element "elm_no" are assembled according to the index transformation vector. The routine is useful when programming finite element methods.

Reimplemented from Vector(Type).

void Vec(Type)::fill ( Type start,
Type stop )
 

See documentation of one of the overloaded functions.

Reimplemented in ArrayGen(Type), and ArrayGenSel(Type).

void Vec(Type)::fill ( const Type & a ) [virtual]
 

See documentation of one of the overloaded functions.

Reimplemented from Vector(Type).

Reimplemented in ArrayGen(Type), and ArrayGenSel(Type).

void Vec(Type)::fill ( const Vector(Type) & X ) [virtual]
 

the version with one argument (inherited from class "VecSimple") fills all array entries with the argument value. The version with two arguments, "start" and "stop", fills the vector with values that are uniformly distributed in the closed interval from "start" to "stop" (in ascending order).

Reimplemented from Vector(Type).

Reimplemented in ArrayGen(Type), and ArrayGenSel(Type).

int Vec(Type)::getNoEntries ( ) const [inline, virtual]
 

Reimplemented in ArrayGenSel(Type).

real Vec(Type)::getStorage ( ) const [virtual]
 

as a companion to the inherited function "getWork", this functions returns the storage cost of the current vector measured in Mb.

Reimplemented from Vector(Type).

Type Vec(Type)::inner ( const Vector(Type) & yb ) const [virtual]
 

computes the inner product of two vectors. If both vectors contain complex values, the complex conjugate of the first vector is used.

Reimplemented from Vector(Type).

Reimplemented in ArrayGenSel(Type).

void Vec(Type)::load ( const char * filename,
const char * name = "X" ) [virtual]
 

quite similar to "save", this function permits Matlab data files to be entered into the current vector object. If available, the binary format is used, otherwise it reads plain ASCII files.

Reimplemented from Vector(Type).

bool Vec(Type)::makeItSimilar ( Handle(Vector(Type)) & v ) const [virtual]
 

the "Vector(Type)" object given as input is initialized to be an imprint of the current object. This implies that the input handle "v" should be empty or refer to a vector of type "Vec(Type)". In cases where the input handle is empty, a new "Vec(Type): object is allocated and rebound to "v". Please note that this function does not copy the actual vector entries.

Reimplemented from Vector(Type).

Reimplemented in ArrayGen(Type), and ArrayGenSel(Type).

void Vec(Type)::mult ( Type value ) [virtual]
 

all vector entries are multiplied with a given constant "value".

Reimplemented from Vector(Type).

Reimplemented in ArrayGenSel(Type).

real Vec(Type)::norm ( Norm_type lp = l2 ) const [virtual]
 

computes the norm of the vector. There are several norms available (see "enum" "Norm_type"): "l1" is the discrete

       `$`L`_`1`$ norm (`$\`sum`_{`i=1`}^`n ``v`_`i`|$`), "L1" is the
       (`$`(1/n)`\`sum`_{`i=1`}^`n``v`_`i`|$`), "l2" is the discrete
v`_`i`^`2`}$`), while "L2" is the corresponding continuous norm (`$\`sqrt`{`(1/n)`\`sum`_{`i=1`}^`n v`_`i`^`2`}$`). Finally, "Linf" is the `$`L`_{\`infty`}$` norm (`$\`max`_`i
       ``v`_`i`|$`).

Reimplemented from Vector(Type).

Reimplemented in ArrayGenSel(Type).

real Vec(Type)::normDiff ( const Vector(Type) & y,
Norm_type lp = l2 ) const [virtual]
 

similar to "norm", but computes the norm of the vector difference between the current object and the argument vector.

Reimplemented from Vector(Type).

Reimplemented in ArrayGenSel(Type).

Vec(Type) & Vec(Type)::operator= ( const Type & a ) [inline]
 

the version that takes another "VecSimple(Type)" as argument makes the object a copy of the vector argument, that is, the object is redimensioned according to the dimensions of "X" and thereafter each entry is set equal to the corresponding entry in "X". The version that takes a "Type" value as argument sets all the entries in the vector to have this value.

Reimplemented from VecSort(Type).

Reimplemented in ArrayGen(Type), and ArrayGenSel(Type).

Vec(Type) & Vec(Type)::operator= ( const Vec(Type) & X ) [inline]
 

void Vec(Type)::print ( Os os,
const char * header = NULL,
int nentries_per_line = 3 ) const [virtual]
 

prints the contents of the vector to an "Os", see the documentation for the functions "VecSimple scan" and "VecSimple print". The specialized version "printAscii" forces ASCII output format.

Reimplemented from Vector(Type).

Reimplemented in ArrayGen(Type), and ArrayGenSel(Type).

void Vec(Type)::printAscii ( Os os,
const char * header = NULL ) const [virtual]
 

Reimplemented from Vector(Type).

Reimplemented in ArrayGen(Type).

void Vec(Type)::randomize ( real low = -1,
real high = 1,
real seed = 1 ) [virtual]
 

fills the vector with random values in the closed interval from "low" to "high". Two sequences of same length will be identical if they are based on the same "seed" value.

Reimplemented from Vector(Type).

bool Vec(Type)::redim ( Type * a,
int n,
int base = 0 ) [inline]
 

See documentation of one of the overloaded functions.

Reimplemented from VecSimplest(Type).

Reimplemented in ArrayGen(Type), and ArrayGenSel(Type).

bool Vec(Type)::redim ( int no_algdofs ) [inline]
 

See documentation of one of the overloaded functions.

Reimplemented from VecSimplest(Type).

Reimplemented in ArrayGen(Type), and ArrayGenSel(Type).

bool Vec(Type)::redim ( const Vector(prm_Type) & pm ) [virtual]
 

one "redim" function is inherited from class "VecSimplest" and redimensions the internal array. The other "redim" function takes a "Vector_prm(Type)" argument and is used in conjuction with a baseclass pointer to "Vector". The function enables redimensioning of any object in the "Vector" hierarchy and is typically used by equation solvers and equation system objects to redimension a vector of unknown class type. A similar function in the "Matrix" hierarchy is easier to understand.

Reimplemented from Vector(Type).

Reimplemented in ArrayGen(Type), and ArrayGenSel(Type).

void Vec(Type)::save ( const char * filename,
const char * name = "X" ) const [virtual]
 

saves the current vector object in a file that is readable for Matlab. If available, the utilities for Matlab's internal binary data file format is used. Otherwise, the output is given as a plain ASCII file that can be loaded in Matlab.

Reimplemented from Vector(Type).

void Vec(Type)::scan ( Is is ) [virtual]
 

reads the contents of the vector from an "Is". The format is documented in "VecSimple scan".

Reimplemented from Vector(Type).

Reimplemented in ArrayGen(Type), and ArrayGenSel(Type).


Friends And Related Function Documentation

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

calls the function "print".

Reimplemented in ArrayGenSel(Type).

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

calls the function "scan".

Reimplemented in ArrayGenSel(Type).


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