home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / diverses / leda / man / matrix.tex < prev    next >
Encoding:
Text File  |  1991-11-15  |  3.3 KB  |  97 lines

  1. \bigskip
  2. \bigskip
  3. {\magonebf  2.5 Real-Valued Matrices (matrix)}
  4.  
  5. An instance of the data type $matrix$ is a matrix of real variables.
  6.  
  7. \def\name{$matrix$}
  8. \def\type{$matrix$}
  9.  
  10. \bigskip
  11. {\bf 1. Creation of a matrix }
  12.  
  13. \create M (int\ n,\ int\ m)
  14.  
  15.  
  16. creates an instance $M$ of type $matrix$, $M$ is initialized to the $n\times m$
  17. - zero matrix.
  18.  
  19.  
  20. \bigskip
  21. {\bf 2. Operations on a matrix M}
  22.  
  23. \medskip
  24. \+\cleartabs & \hskip 2.5truecm & \hskip 5truecm &\cr
  25. \+\op int     dim1 {}  
  26.                            { returns $n$, the number of rows of $M$.}
  27. \smallskip
  28. \+\op int     dim2 {}  
  29.                            { returns $m$, the number of cols of $M$.}
  30. \smallskip
  31. \+\op vector  row {int\ i}  
  32.                            { returns the $i$-th row of $M$ (an $m$-vector).}
  33. \+\nop                     { \precond  $0 \le i \le n-1$.}
  34. \smallskip
  35. \+\op vector  col {int\ i}  
  36.                            { returns the $i$-th column of $M$ (an $n$-vector).}
  37. \+\nop                     { \precond  $0 \le i \le m-1$.}
  38. \smallskip
  39. \+\op matrix  trans {}     
  40.                            { returns  $M^T$ ($m\times n$ - matrix). }
  41. \smallskip
  42. \+\op real    det {}       
  43.                            { returns the determinant of $M$.}
  44. \+\nop                     { \precond  $M$ is quadratic.}
  45. \smallskip
  46. \+\op matrix  inv {}       
  47.                            { returns the inverse matrix of $M$. }
  48. \+\nop                     { \precond  $M$.det() $\neq$ 0.}
  49. \smallskip
  50. \+\op vector  solve {vector\ b}  
  51.                            { returns vector $x$ with $M\cdot x = b$. }
  52. \+\nop                     { \precond $M$.dim1() = $M$.dim2() = $b$.dim()}
  53. \+\nop                     { and $M$.det() $\neq$ 0.}
  54. \medskip
  55. \+\opf real\&  {int\ i,\ int\ j}        
  56.                                  {returns $M_{i,j}$.}
  57. \+\nop                           {\precond $0\le i\le n-1$ and $0\le j\le m-1$.}
  58. \smallskip
  59. \+\opb matrix\&  =  M_1  
  60.                                  {Assignment; returns $M$.}
  61. \smallskip
  62. \+\opb matrix    +  M_1  
  63.                                  {Addition}
  64. \+\nop                           {\precond $M$.dim1() = $M_1$.dim1() and}
  65. \+\nop                           { $M$.dim2() = $M_1$.dim2().}
  66. \smallskip
  67. \+\opb matrix    -  M_1  
  68.                                  {Subtraktion}
  69. \+\nop                           {\precond $M$.dim1() = $M_1$.dim1() and}
  70. \+\nop                           { $M$.dim2() = $M_1$.dim2().}
  71. \smallskip
  72. \+\opb matrix    *  M_1   
  73.                                  {Multiplication}
  74. \+\nop                           {\precond $M$.dim2() = $M_1$.dim1().}
  75. \smallskip
  76. \+\opb matrix     *  r     
  77.                                  {Multiplication with real}
  78. \smallskip
  79. \+\opb vector     *  v     
  80.                                  {Multiplication with vector}
  81. \+\nop                           {\precond $M$.dim2() = $v$.dim().}
  82. \medskip
  83. \+\ops ostream\&  << O       
  84.                                  {writes matrix $M$ to the output stream $O$}
  85. \smallskip
  86. \+\ops istream\&  >> I       
  87.                                  {reads matrix $M$ from the input stream $I$}
  88.  
  89. \bigskip
  90. {\bf 3. Implementation }
  91. \medskip
  92. Data type $matrix$ is implemented by two-dimensional arrays of real numbers. 
  93. Operations det and solve take time $O(n^2)$, inv takes time $O(n^3)$, dim1, 
  94. dim2, row, and col take constant time, all other operations take time $O(nm)$.
  95. The space requirement is $O(nm)$.
  96.  
  97.