Diploma Thesis Percolation Simulation
C++ Sourcecode Documentation

www.AndreasKrueger.de/thesis/code

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

myVector Class Reference

#include <my_vector.h>

Collaboration diagram for myVector:

Collaboration graph
[legend]
List of all members.

Public Methods

 myVector ()
 myVector (int setdim)
 myVector (const myVector &u)
void set_dim (int setdim)
void randomvect (COORDFLOAT L)
void nullvect ()
void unitvect ()
myVector & operator= (const myVector &u)
myVector & operator-= (const myVector &)
bool operator!= (const myVector &u)
COORDFLOAT coord (int dir)

Private Attributes

int dim
COORDFLOAT x [MAXDIM]

Friends

int getdim (const myVector &u)
REAL length (const myVector &u)
REAL squarelength (const myVector &u)
myVector operator- (const myVector &, const myVector &)
myVector operator- (const myVector &)
ostream & operator<< (ostream &, myVector &)
istream & operator>> (istream &, myVector &)
bool operator< (const myVector &, const myVector &)
bool lower (const myVector &, COORDFLOAT border, int dir)

Constructor & Destructor Documentation

myVector::myVector  
 

Definition at line 64 of file my_vector.h.

References dim.

00064                   {
00065         dim=0;
00066 }

myVector::myVector int    setdim
 

Definition at line 68 of file my_vector.h.

References errorout(), MAXDIM, and set_dim().

00068                             {
00069         if ((setdim<1)||(setdim>MAXDIM)) {
00070                 errorout("'myVector' dimension < 1 or > MAXDIM");
00071                 exit(1);
00072         }
00073         else{
00074                 set_dim(setdim);
00075         }
00076 }

myVector::myVector const myVector &    u
 

Definition at line 78 of file my_vector.h.

References dim, and x.

00078                                     {                           // copy constructor
00079         dim=u.dim;                                                                      // create the new vector with same dimensionality
00080         for (int i=0;i<dim;i++) {                                       // copy components
00081                 x[i] = u.x[i];
00082         }
00083 }


Member Function Documentation

COORDFLOAT myVector::coord int    dir
 

Definition at line 222 of file my_vector.h.

References COORDFLOAT, and x.

Referenced by greatercoord(), grid::put_vector_into_boxes(), and grid::test_vector2boxes().

00222                                   {
00223         return x[dir];
00224 }

void myVector::nullvect   [inline]
 

Definition at line 162 of file my_vector.h.

References dim, and x.

Referenced by operator-(), set_dim(), and sphere::unitpointsphere().

00162                                 {
00163         for (int i=0;i<dim;i++) {
00164                 x[i] = 0;
00165         }
00166 }

bool myVector::operator!= const myVector &    u
 

Definition at line 199 of file my_vector.h.

References dim, and x.

00199                                            {    // give only reference for faster code
00200         bool temp=0;
00201         if (u.dim!=dim) temp=1;
00202         else {
00203                 for (int i=0;i<u.dim;i++) {
00204                         if (x[i] != u.x[i]) temp=1;
00205                 }
00206         }
00207         return temp;
00208 }

myVector & myVector::operator-= const myVector &    [inline]
 

Definition at line 134 of file my_vector.h.

References dim, errorout(), and x.

00134                                                        {        // give only reference for faster code
00135         if (dim!=u.dim) errorout("'-=' different dimensionality");
00136         else {
00137                 for (int i=0;i<dim;i++) {
00138                         x[i] -= u.x[i];
00139                 }
00140         }
00141         return *this;
00142 }

myVector & myVector::operator= const myVector &    u [inline]
 

Definition at line 124 of file my_vector.h.

References dim, errorout(), and x.

00124                                                       {                 // give only reference for faster code
00125         if (dim!=u.dim) errorout("'=' different dimensionality");
00126         else{
00127                 for (int i=0;i<dim;i++) {
00128                         x[i] = u.x[i];
00129                 }
00130         }
00131         return *this;
00132 }

void myVector::randomvect COORDFLOAT    L
 

Definition at line 187 of file my_vector.h.

References COORDFLOAT, dim, long_random(), and x.

Referenced by throw_spheres().

00187                                        {
00188         for (int i=0;i<dim;i++) {
00189                 x[i] = long_random(L);
00190         }
00191 }

void myVector::set_dim int    setdim [inline]
 

Definition at line 85 of file my_vector.h.

References dim, and nullvect().

Referenced by myVector(), sphere::operator=(), set_dim(), and sphere::sphere().

00085                                        {
00086         dim=setdim;
00087         nullvect();
00088 }

void myVector::unitvect  
 

Definition at line 167 of file my_vector.h.

References dim, and x.

00167                         {
00168         for (int i=0;i<dim;i++) {
00169                 x[i] = 1;
00170         }
00171 }


Friends And Related Function Documentation

int getdim const myVector &    u [friend]
 

Definition at line 90 of file my_vector.h.

00090                               {
00091         return u.dim;
00092 }

REAL length const myVector &    u [friend]
 

Definition at line 95 of file my_vector.h.

00095                                       {
00096    COORDFLOAT temp=0;
00097         for (int i=0;i<u.dim;i++) 
00098                 {temp+=u.x[i]*u.x[i];}
00099         return sqrt(temp);
00100 }

bool lower const myVector &   ,
COORDFLOAT    border,
int    dir
[friend]
 

Definition at line 211 of file my_vector.h.

00211                                                           {
00212         // is myVector u in lower (than 'border') part of this dimensional direction?
00213         if ((dir<1)||(dir>u.dim)) {
00214                 errorout("space direction < 1 or > dim");
00215                 exit(1);
00216                 return false;
00217         }
00218         else return (u.x[dir-1] < border);
00219 }

myVector operator- const myVector &    [friend]
 

Definition at line 156 of file my_vector.h.

00156                                       {
00157         myVector temp(u.dim);
00158         temp.nullvect();
00159         return (temp-=u);
00160 }

myVector operator- const myVector &   ,
const myVector &   
[friend]
 

Definition at line 145 of file my_vector.h.

00145                                                           {             
00146         if (u.dim!=v.dim) {
00147                 errorout("'-' different dimensionality");
00148                 return u;
00149         }
00150         else{
00151                 myVector temp = u;
00152                 return (temp -= v);                                                             // calls myVector::operator-=(myVector)
00153         }
00154 }

bool operator< const myVector &   ,
const myVector &   
[friend]
 

Definition at line 195 of file my_vector.h.

00195                                                      {                  // length order
00196   return (length(u) < length(v) );
00197 }

ostream& operator<< ostream &   ,
myVector &   
[friend]
 

Definition at line 109 of file my_vector.h.

00109                                               {
00110         cout <<'(';
00111         for (int i=0;i<z.dim-1;i++) {
00112                 cout<<z.x[i]<<',';
00113         }
00114         return os<<z.x[z.dim-1]<<')';
00115 }

istream& operator>> istream &   ,
myVector &   
[friend]
 

Definition at line 117 of file my_vector.h.

00117                                               {
00118         for (int i=0;i<z.dim;i++) {
00119                 cin>>z.x[i];
00120         }
00121         return is;
00122 }

REAL squarelength const myVector &    u [friend]
 

Definition at line 102 of file my_vector.h.

00102                                      {
00103    COORDFLOAT temp=0;
00104         for (int i=0;i<u.dim;i++) 
00105                 {temp+=u.x[i]*u.x[i];}
00106         return temp;
00107 }


Member Data Documentation

int myVector::dim [private]
 

Definition at line 33 of file my_vector.h.

Referenced by getdim(), length(), lower(), myVector(), nullvect(), operator!=(), operator-(), operator-=(), operator<<(), operator=(), operator>>(), randomvect(), set_dim(), squarelength(), and unitvect().

COORDFLOAT myVector::x[MAXDIM] [private]
 

Definition at line 34 of file my_vector.h.

Referenced by coord(), length(), lower(), myVector(), nullvect(), operator!=(), operator-=(), operator<<(), operator=(), operator>>(), randomvect(), squarelength(), and unitvect().


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




Diploma Thesis Sourcecode Documentation
check out the text and the executable binaries

www.AndreasKrueger.de/thesis/code