\manpage {matrix} {}  {Real-Valued Matrices} 
 
\definition
An instance of the data type $matrix$ is a matrix of double variables.  

 
\creation M 
 
\create {(int\ n=0,\ int\ m=0)}
   { creates an instance $M$ of type $matrix$, $M$ is initialized to
           the $n \times m$ - zero matrix.  }
 
 
\operations 2 4 
 
\op  int     dim1 {()}
           {  returns $n$, the number of rows of $M$.  }
 
 
\op  int     dim2 {()}
           {  returns $m$, the number of columns of $M$.  }
 
 
\op  vector\& row {(int\ i)}
           {  returns the $i$-th row of $M$ (an $m$-vector).
	 \precond  $0 \le i \le n-1$.  }
 
 
\op  vector col {(int\ i)}
           {  returns the $i$-th column of $M$ (an $n$-vector).
	 \precond  $0 \le i \le m-1$.  }
 
 
\op  matrix  trans {()}
           {  returns $M^T$ ($m\times n$ - matrix).  }
 
 
\op  matrix  inv {()}
           {  returns the inverse matrix of $M$.\\
	 \precond  $M$.det() $\neq$ 0.  }
 
 
\op  double  det {()}
           {  returns the determinant of $M$.\\
	 \precond  $M$ is quadratic.  }
 
 
\op  vector solve {( vector\ b)}
           {  returns vector $x$ with $M\cdot x = b$.\\
	 \precond $M$.dim1() = $M$.dim2() = $b$.dim()
	 and $M$.det() $\neq$ 0.  }
 
 
\funop double\&  {int\ i, \ int\ j}
         {  returns $M_{i,j}$. \\
	  \precond $0\le i\le n-1$ and $0\le j\le m-1$. }
 
 
\binop matrix + {M1}
         {  Addition. \\
 	   \precond $M$.dim1() = $M1$.dim1() and $M$.dim2() = $M1$.dim2(). }
 
 
\binop matrix - {M1}
         {  Subtraction. \\
	   \precond $M$.dim1() = $M1$.dim1() and
	   $M$.dim2() = $M1$.dim2(). }
 
 
\binop matrix * {M1}
         {  Multiplication. \\
	   \precond $M$.dim2() = $M1$.dim1(). }
 
 
\binop vector * { vector\ vec}
         {  Multiplication with vector.\\
	    \precond $M$.dim2() = $vec$.dim().  }
 
 
\binop matrix * {double\ x}
         {  Multiplication with double x. }
 
 
\binopfunc  ostream\&   {ostream\&\ O\ <<M}
           {  writes matrix $M$ row by row to the output stream $O$.  }
 
 
\binopfunc  istream\&   {istream\&\ I\ >>\&\ M}
           {  reads matrix $M$ row by row from the input stream $I$.  }
 
 
\implementation
Data type $matrix$ is implemented by two-dimensional arrays of double numbers. 
Operations det, solve, and inv take time $O(n^3)$, dim1, dim2, row, and col 
take constant time, all other operations take time $O(nm)$.  
The space requirement is $O(nm)$.
 
