iom.tex 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. %
  2. % part of numlib docs. In time this won't be a standalone pdf anymore, but part of a larger part.
  3. % for now I keep it directly compliable. Uses fpc.sty from fpc-docs pkg.
  4. %
  5. \documentclass{report}
  6. \usepackage{fpc}
  7. \lstset{%
  8. basicstyle=\small,
  9. language=delphi,
  10. commentstyle=\itshape,
  11. keywordstyle=\bfseries,
  12. showstringspaces=false,
  13. frame=
  14. }
  15. \makeindex
  16. \newcommand{\FunctionDescription}{\item[Description]\rmfamily}
  17. \newcommand{\Dataorganisation}{\item[Data Struct]\rmfamily}
  18. \newcommand{\DeclarationandParams}{\item[Declaration]\rmfamily}
  19. \newcommand{\References}{\item[References]\rmfamily}
  20. \newcommand{\Method}{\item[Method]\rmfamily}
  21. \newcommand{\Precision}{\item[Precision]\rmfamily}
  22. \newcommand{\Remarks}{\item[Remarks]\rmfamily}
  23. \newcommand{\Example}{\item[Example]\rmfamily}
  24. \newcommand{\ProgramData}{\item[Example Data]\rmfamily}
  25. \newcommand{\ProgramResults}{\item[Example Result]\rmfamily}
  26. \makeatletter
  27. \@ifpackageloaded{tex4ht}{%
  28. \newcommand{\NUMLIBexample}[1]{
  29. \par \file{\textbf{Listing:} \exampledir/#1.pas}%
  30. \HCode{<HR/>}%
  31. \listinginput[9999]{5000}{\exampledir/#1.pas}%
  32. \HCode{<HR/>}%
  33. }%
  34. }{% else ifpackageloaded
  35. \newcommand{\NUMLIBexample}[1]{%
  36. \par \file{\textbf{Listing:} \exampledir/#1.pas}%
  37. \lstinputlisting{\exampledir/#1.pas}%
  38. }% End of FPCExample
  39. }% End of ifpackageloaded.
  40. \makeatother
  41. %
  42. \begin{document}
  43. \FPCexampledir{../examples}
  44. \section{general comments}
  45. \textbf{Original comments:} \\
  46. The used floating point type \textbf{real} depends on the used
  47. version, see the general introduction for more information. You'll
  48. need to USE units typ and iom to use these routines.
  49. \textbf{MvdV notes:} \\
  50. Integers used for parameters are of type "ArbInt" to avoid problems
  51. with systems that define integer differently depending on mode.
  52. Floating point values are of type "ArbFloat" to allow writing code
  53. that is independent of the exact real type. (Contrary to directly
  54. specifying single, real, double or extended in library and
  55. examples). Typ.pas and the central includefile have some conditional
  56. code to switch between floating point types.
  57. These changes were already prepared somewhat when I got the lib, but
  58. weren't consequently applied. I did that while porting to FPC.
  59. \section{Unit iom}
  60. \begin{procedure}{iomrev}
  61. \FunctionDescription Procedure to read a vector from file.
  62. \Dataorganisation The procedure assumes that the program that is
  63. calling it has declared a one dimensional vector where the data will
  64. be stored in.
  65. \DeclarationandParams
  66. \lstinline|procedure iomrev(var inp: text; var v: ArbFloat; n:|
  67. \lstinline|ArbInt);|
  68. \begin{description}
  69. \item[var inp: text] \mbox{} \\
  70. The parameter {\bf inp} contains the file where the components of the vector are stored in.
  71. \item[var v: ArbFloat] \mbox{} \\
  72. Parameter {\bf v} must contain the top array element.
  73. \item[n: ArbInt] \mbox{} \\
  74. The parameter {\bf n} contains the length of the resulting vector.
  75. \end{description}
  76. \Remarks
  77. This procedure does not do array range checks. When called with invalid
  78. parameters, invalid/nonsense responses or even crashes may be the result.
  79. \Example Reading and printing the vector \[(1,\; 2,\; 3,\; 4,\;
  80. 5)^{T}\].
  81. \NUMLIBexample{iomrevex}
  82. \ProgramData Below is the data from the inputfile shown.
  83. \begin{verbatim}
  84. 1 2 3 4 5
  85. \end{verbatim}
  86. \ProgramResults Running the example program {\bf iomrevex} when
  87. using the real type single gives the following results.
  88. \begin{verbatim}
  89. v =
  90. 1.000E+0000 2.000E+0000 3.000E+0000 4.000E+0000 5.000E+0000
  91. \end{verbatim}
  92. %\Precision
  93. %\Method
  94. %\References
  95. \end{procedure}
  96. %===========================================================================
  97. \begin{procedure}{iomwrv}
  98. \FunctionDescription Procedure to write a vector to file.
  99. \Dataorganisation The procedure assumes that the program that is
  100. calling it has declared a one dimensional vector where the data is
  101. stored in.
  102. \DeclarationandParams \lstinline|procedure iomwrv(var out: text;|
  103. \lstinline|var v: ArbFloat; n, form: ArbInt);|
  104. \begin{description}
  105. \item[var out: text] \mbox{} \\
  106. The parameter {\bf out} contains the file where the components of the vector are stored in.
  107. \item[var v: ArbFloat] \mbox{} \\
  108. Parameter {\bf v} must contain the top array element.
  109. \item[n: ArbInt] \mbox{} \\
  110. The parameter {\bf n} contains the length of the vector.
  111. \item[form: ArbInt] \mbox{} \\
  112. The parameter {\bf form} controls the number of decimals of the floating point representation.
  113. \end{description}
  114. \Remarks If the number of elements of the vector is so big that the
  115. vector does not fit one line, then the vector is split up over
  116. several lines.
  117. One line is typically 78 character positions. (It is possible though
  118. to change the global unit variable {\bf npos} that controls the
  119. number of characters).
  120. {\bf NOTE} \\
  121. This procedure does not do array range checks. When called with invalid
  122. parameters, invalid/nonsense responses or even crashes may be the result.
  123. \Example A random generated 5-vector $v$, with components between
  124. $-1$ and $+1$, is written to file in two ways with {\bf form}=15 and {\bf form}=12.
  125. \ProgramData
  126. \NUMLIBexample{iomwrvex}
  127. \ProgramResults Running the example program {\bf iomwrvex} when
  128. using the real type single will give a similar result.
  129. \begin{verbatim}
  130. -9.193040E-0001 -2.695178E-0001 -1.123863E-0001 -8.804156E-0001
  131. -4.882166E-0001
  132. -9.193E-0001 -2.695E-0001 -1.124E-0001 -8.804E-0001 -4.882E-0001
  133. \end{verbatim}
  134. %\Precision
  135. %
  136. %\Method
  137. %
  138. %\References
  139. \end{procedure}
  140. %===========================================================================
  141. \begin{procedure}{iomrem}
  142. \FunctionDescription Procedure for reading a rectangular matrix.
  143. \Dataorganisation The procedure assumes that the program that is
  144. calling it has declared a two dimensional matrix where the data will
  145. be stored in.
  146. \DeclarationandParams
  147. \lstinline|procedure iomrem(var inp: text; var a: ArbFloat; m, n,|
  148. \lstinline|rwidth: ArbInt);|
  149. \begin{description}
  150. \item[var inp: text] \mbox{} \\
  151. The parameter {\bf inp} contains the file where the components of the matrix are stored in.
  152. \item[var a: ArbFloat] \mbox{} \\
  153. Parameter {\bf a} must contain the left top array element.
  154. \item[m: ArbInt] \mbox{} \\
  155. Parameter {\bf m} contains the column length of the matrix to be read.
  156. \item[n: ArbInt] \mbox{} \\
  157. Parameter {\bf n} contains the row length of the matrix to be read.
  158. \item[rwidth: ArbInt] \mbox{} \\
  159. Parameter {\bf rwidth} contains the declared rowlength of the two
  160. dimensional array where the matrix will be stored in.
  161. \end{description}
  162. \Remarks This procedure does not do array range checks. When called
  163. with invalid parameters, invalid/nonsense responses or even crashes
  164. may be the result.
  165. \Example reading and printing if the $3 \times 2$-matrix
  166. \[ \left( \begin{array}{cc}
  167. 1 & 2 \\
  168. 3 & 4 \\
  169. 5 & 6
  170. \end{array}
  171. \right).
  172. \]
  173. \ProgramData
  174. \NUMLIBexample{iomremex}
  175. \ProgramResults Running the example program {\bf iomremex} when
  176. using the real type single gives the following results.
  177. \begin{verbatim}
  178. A=
  179. 1.000E+0000 2.000E+0000
  180. 3.000E+0000 4.000E+0000
  181. 5.000E+0000 6.000E+0000
  182. \end{verbatim}
  183. %\Precision
  184. %
  185. %\Method
  186. %
  187. %\References
  188. \end{procedure}
  189. %===========================================================================
  190. \begin{procedure}{iomwrm}
  191. \FunctionDescription Procedure for writing a rectangular matrix to
  192. file.
  193. \Dataorganisation The procedure assumes that the program that is
  194. calling it has declared a two dimensional matrix where the data will
  195. be stored in.
  196. \DeclarationandParams \lstinline|procedure iomwrm(var out: text;|
  197. \lstinline|var a: real; m, n, rwidth, form: integer);|
  198. \begin{description}
  199. \item[var out: text] \mbox{} \\
  200. The parameter {\bf out} contains the file where the components of the matrix are stored.
  201. \item[var a: real] \mbox{} \\
  202. Parameter {\bf a} must contain the left top array element.
  203. \item[m: integer] \mbox{} \\
  204. Parameter {\bf m} contains the column length of the matrix.
  205. \item[n: integer] \mbox{} \\
  206. Parameter {\bf n} contains the row length of the matrix.
  207. \item[rwidth: integer] \mbox{} \\
  208. Parameter {\bf rwidth} contains the true column count of the declared matrix.
  209. \item[form: integer] \mbox{} \\
  210. The parameter {\bf form} controls the number of decimals of the floating point representation.
  211. \end{description}
  212. \Remarks If the number of columns of the matrix is so big that the
  213. row does not fit one line, then the matrix columns are split up over
  214. several lines separated by an empty line.
  215. One line is typically 78 character positions. (It is possible though
  216. to change the global unit variable {\bf npos} that controls the
  217. number of characters).
  218. {\bf NOTE} \\
  219. This procedure does not do array range checks. When called with invalid
  220. parameters, invalid/nonsense responses or even crashes may be the result.
  221. \Example Of a $5 \times 13$-matrix $A$ with elements
  222. $A_{ij}=-(i+j/10), 1 \leq i \leq 5,\ 1 \leq j \leq 13$, is the $3
  223. \times 6$ block matrix $(A_{ij}), \ 2 \leq i \leq 4, \ 3 \leq j \leq
  224. 8$ written to file with {\bf form}=14 and {\bf form}=10.
  225. \ProgramData
  226. \NUMLIBexample{iomwrmex}
  227. \ProgramResults Running the example program {\bf iomwrmex} when
  228. using the real type single gives the following results.
  229. \begin{verbatim}
  230. -2.30000E+0000 -2.40000E+0000 -2.50000E+0000 -2.60000E+0000
  231. -3.30000E+0000 -3.40000E+0000 -3.50000E+0000 -3.60000E+0000
  232. -4.30000E+0000 -4.40000E+0000 -4.50000E+0000 -4.60000E+0000
  233. -2.70000E+0000 -2.80000E+0000 -3.70000E+0000 -3.80000E+0000
  234. -4.70000E+0000 -4.80000E+0000
  235. -2.3E+0000 -2.4E+0000 -2.5E+0000 -2.6E+0000 -2.7E+0000
  236. -2.8E+0000 -3.3E+0000 -3.4E+0000 -3.5E+0000 -3.6E+0000
  237. -3.7E+0000 -3.8E+0000 -4.3E+0000 -4.4E+0000 -4.5E+0000
  238. -4.6E+0000 -4.7E+0000 -4.8E+0000
  239. \end{verbatim}
  240. %\Precision
  241. %
  242. %\Method
  243. %
  244. %\References
  245. \end{procedure}
  246. %===========================================================================
  247. \begin{procedure}{iomwrms}
  248. \FunctionDescription Procedure for writing a rectangular matrix to a
  249. string.
  250. \Dataorganisation The procedure assumes that the program that is
  251. calling it has declared a two dimensional matrix where the data will
  252. be stored in.
  253. \DeclarationandParams \lstinline|procedure iomwrms(var out:|
  254. \lstinline|ArbString; var a: ArbFloat; m, n, form, c: ArbInt);|
  255. \begin{description}
  256. \item[var out: ArbString] \mbox{} \\
  257. The parameter {\bf out} contains the string where the components of the matrix are stored.
  258. \item[var a: ArbFloat] \mbox{} \\
  259. Parameter {\bf a} must contain the left top array element.
  260. \item[m: ArbInt] \mbox{} \\
  261. Parameter {\bf m} contains the column length of the matrix.
  262. \item[n: ArbInt] \mbox{} \\
  263. Parameter {\bf n} contains the row length of the matrix.
  264. \item[form: ArbInt] \mbox{} \\
  265. The parameter {\bf form} controls the number of decimals of the floating point representation.
  266. \item[c: ArbInt] \mbox{} \\
  267. The parameter {\bf c} contains the true column count of the declared matrix.
  268. \end{description}
  269. \Remarks This procedure does not do array range checks. When called
  270. with invalid parameters, invalid/nonsense responses or even crashes
  271. may be the result.
  272. \Example
  273. \NUMLIBexample{iomrewrsex}
  274. \ProgramData
  275. \begin{verbatim}
  276. {1 2}{3 4}{5 6}
  277. \end{verbatim}
  278. \ProgramResults
  279. \begin{verbatim}
  280. A = { 1.0E+0000 2.0E+0000 }{ 3.0E+0000 4.0E+0000 }{ 5.0E+0000
  281. 6.0E+0000 }
  282. \end{verbatim}
  283. %\Precision
  284. %
  285. %\Method
  286. %
  287. %\References
  288. \end{procedure}
  289. %===========================================================================
  290. \begin{procedure}{iomrems}
  291. \FunctionDescription Procedure for reading a rectangular matrix from
  292. string.
  293. \Dataorganisation The procedure assumes that the program that is
  294. calling it has declared a two dimensional matrix where the data will
  295. be stored in.
  296. \DeclarationandParams \lstinline|procedure iomrems(inp: ArbString;|
  297. \lstinline|var a: ArbFloat; var m, n: ArbInt; c: ArbInt);|
  298. \begin{description}
  299. \item[inp: ArbString] \mbox{} \\
  300. De parameter {\bf inp} contains the string where all components of the new matrix are stored in.
  301. \item[var a: ArbFloat] \mbox{} \\
  302. Parameter {\bf a} must contain the left top array element.
  303. \item[var m: ArbInt] \mbox{} \\
  304. Parameter {\bf m} contains the column length of the matrix.
  305. \item[var n: ArbInt] \mbox{} \\
  306. Parameter {\bf n} contains the row length of the matrix.
  307. \item[c: ArbInt] \mbox{} \\
  308. Parameter {\bf c} contains the true column count of the declared matrix.
  309. \end{description}
  310. \Remarks This procedure does not do array range checks. When called
  311. with invalid parameters, invalid/nonsense responses or even crashes
  312. may be the result.
  313. \Example
  314. \NUMLIBexample{iomrewrsex}
  315. \ProgramData
  316. \begin{verbatim}
  317. {1 2}{3 4}{5 6}
  318. \end{verbatim}
  319. \ProgramResults
  320. \begin{verbatim}
  321. A = { 1.0E+0000 2.0E+0000 }{ 3.0E+0000 4.0E+0000 }{ 5.0E+0000
  322. 6.0E+0000 }
  323. \end{verbatim}
  324. %\Precision
  325. %
  326. %\Method
  327. %
  328. %\References
  329. \end{procedure}
  330. \end{document}