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

  1. \bigskip
  2. \bigskip
  3. {\magonebf  2.4 Real-Valued Vectors (vector)}
  4.  
  5. An instance of the data type $vector$ is a vector of real variables.
  6.  
  7. \def\name{$vector$}
  8. \def\type{$vector$}
  9.  
  10. \bigskip
  11. {\bf 1. Creation of a vector }
  12.  
  13. a) \create v (int\ d)
  14.  
  15. b) \create v (real\ a,\ real\ b)
  16.  
  17. c) \create v (real\ a,\ real\ b,\ real\ c)
  18.  
  19.  
  20. creates an instance $v$ of type $vector$; $v$ is initialized to the zero
  21. vector of dimension $d$ (variant a), the two-dimensional vector $(a,b)$
  22. (variant b) or the three-dimensional vector $(a,b,c)$ (variant c).
  23.  
  24.  
  25. \bigskip
  26. {\bf 2. Operations on a vector v}
  27.  
  28. \medskip
  29. \+\cleartabs & \hskip 2.5truecm & \hskip 5truecm &\cr
  30. \+\op int   dim {}         
  31.                            {returns the dimension of $v$.}
  32. \smallskip
  33. \+\op real  length {}      
  34.                            {returns the Euclidean length of $v$}
  35. \smallskip
  36. \+\op real  angle {vector\ w}  
  37.                            { returns the angle between $v$ and $w$.}
  38. \medskip
  39. \+\opa real\&  {int\ i}           
  40.                            {returns $i$-th component of $v$.}
  41. \+\nop                     {\precond $0\le i \le v$.dim() - 1.}
  42. \smallskip
  43. \+\opb vector       +  {v_1}
  44.                            {Addition}
  45. \+\nop                     {\precond $v$.dim() = $v_1$.dim().}
  46. \smallskip
  47. \+\opb vector    -  {v_1}
  48.                            {Subtraction}
  49. \+\nop                     {\precond $v$.dim() = $v_1$.dim().}
  50. \smallskip
  51. \+\opb real      *  {v_1}
  52.                            {Scalar multiplication}
  53. \+\nop                     {\precond $v$.dim() = $v_1$.dim().}
  54. \smallskip
  55. \+\opb vector    *  {r}
  56.                            {Componentwise multiplication with real $r$}
  57. \medskip
  58. \+\opb vector\&  =  {v_1}
  59.                            {Assignment, returns $v$}
  60. \smallskip
  61. \+\opb bool      == {v_1}
  62.                            {Test for equality}
  63. \smallskip
  64. \+\opb bool      != {v_1}
  65.                            {Test for inequality}
  66. \medskip
  67. \+\ops ostream\& << {O}  
  68.                            {writes $v$ componentwise to the output stream $O$}
  69. \smallskip
  70. \+\ops istream\& >> {I}  
  71.                            {reads $v$ componentwise from the input stream $I$}
  72.  
  73. \vfill\eject
  74.  
  75. \bigskip
  76. {\bf 3. Implementation }
  77. \medskip
  78. Vectors are implemented by arrays of real numbers. All operations on a
  79. vector $v$ take time $O(v.dim())$, except of dim and $[\ ]$ which take constant
  80. time. The space requirement is $O(v.dim())$.
  81.  
  82.