\manpage {vector} {} {Real-Valued Vectors}
 
\definition
An instance of the data type $vector$ is a vector of real variables.
 
\creation v 
 
\create { }
   { creates an instance $v$ of type $vector$; $v$ is initialized to
            the zero-dimensional vector. }
 
 
\create {(int\ d)}
   { creates an instance $v$ of type $vector$; $v$ is initialized to
            the zero vector of dimension $d$. } 
 
 
\create {(double\ a,\ double\ b)}
   { creates an instance $v$ of type $vector$; $v$ is initialized to
            the two-dimensional vector $(a,b)$. }
 
 
\create {(double\ a,\ double\ b,\ double\ c)}
   { creates an instance $v$ of type $vector$; $v$ is initialized to
            the three-dimensional vector $(a,b,c)$. }
 
 
\operations 2 4.5
 
\op  int    dim {()}
           {  returns the dimension of $v$. }
 
 
\op  double length {()}
           {  returns the Euclidean length of $v$. }
 
 
\op  double angle {( vector\ w)}
           {  returns the angle between $v$ and $w$. }
 
 
\arrop double\&  {int\ i}
         {  returns $i$-th component of $v$.\\
	       \precond $0\le i \le v$.dim()$-$1. }
 
 
\binop vector + {v1}
         {  Addition.\\
	       \precond $v$.dim() = $v1$.dim(). }
 
 
\binop vector - {v1}
         {  Subtraction.\\
	       \precond $v$.dim() = $v1$.dim(). }
 
 
\binop double * {v1}
         {  Scalar multiplication.\\
               \precond $v$.dim() = $v1$.dim(). }
 
 
\binop vector * {double\ r}
         {  Componentwise multiplication with double $r$. }
 
 
\binop bool == { }
         {  Test for equality. }
 
 
\binop bool != {w}
         {  Test for inequality. }
 
 
\binopfunc  ostream\&   {ostream\&\ O\ <<v}
           {  writes $v$ componentwise to the output stream $O$. }
 
 
\binopfunc  istream\&   {istream\&\ I\ >>\&\ v}
           {  reads $v$ componentwise from the input stream $I$. }
 
 
\implementation
Vectors are implemented by arrays of real numbers. All operations on a vector 
$v$ take time $O(v.dim())$, except for dim and $[\ ]$ which take constant
time. The space requirement is $O(v.dim())$.

 
