README 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. Meschach Library
  2. Version 1.2b
  3. David E. Stewart
  4. (david.stewart@anu.edu.au)
  5. and
  6. Zbigniew Leyk
  7. (zbigniew.leyk@anu.edu.au)
  8. School of Mathematical Sciences
  9. Australian National University
  10. Canberra ACT 0200
  11. Australia
  12. [last revised: 6th April, 1994]
  13. 1. INTRODUCTION
  14. The Meschach Library is a numerical library of C routines for performing
  15. calculations on matrices and vectors. It is intended for solving systems of
  16. linear equations (dense and sparse), solve least squares problems,
  17. computing eigenvalues and eigenvectors, etc. We do not claim that it
  18. contains every useful algorithm in numerical linear algebra, but it does
  19. provide a basis on which more advanced algorithms can be built. The library
  20. is for people who know something about the C programming language,
  21. something of how to solve the numerical problem they are faced with but do
  22. not want to have the hassle of building all the necessary routines from the
  23. scratch. The library is not a loose collection of numerical routines but it
  24. comprises a coherent system. The current version is enhanced with many
  25. features comparing with previous versions. Since the memory requirements
  26. are nontrivial for large problems we have paid more attention to
  27. allocation/deallocation of memory.
  28. The source code is available to be perused, used and passed on without
  29. cost, while ensuring that the quality of the software is not compromised.
  30. The software is copyrighted; however, the copyright agreement follows in
  31. the footsteps of the Free Software Foundation in preventing abuse that
  32. occurs with totally public domain software.
  33. Detailed instructions for installing Meschach are contained below.
  34. Pronunciation: if in doubt, say "me-shark". This is close enough.
  35. Don't ask us "Why call it that?" Have a look at the quote at the front of
  36. the manual.
  37. 2. AVAILABILITY
  38. The authors make this code openly available to others, in the hope that
  39. it will prove to be a useful tool. We ask only that:
  40. * If you publish results obtained using Meschach, please consider
  41. acknowledging the source of the code.
  42. * If you discover any errors in the code, please promptly communicate them
  43. to the authors.
  44. We also suggest that you send email to the authors identifying yourself
  45. as a user of Meschach; this will enable the authors to notify you of any
  46. corrections/improvements in Meschach.
  47. 3. HOW TO GET IT
  48. There are several different forms in which you might receive Meschach.
  49. To provide a shorthand for describing collections of files, the Unix
  50. convention of putting alternative letters in [...] will be used. (So,
  51. fred[123] means the collection fred1, fred2 and fred3.) Meschach is
  52. available over Internet/AARnet via netlib, or at the anonymous ftp site
  53. thrain.anu.edu.au in the directory pub/meschach. There are five .shar
  54. files: meschach[01234].shar (which contain the library itself),
  55. meschach0.shar (which contains basic documentation and machine dependent
  56. files for a number of machines). Of the meschach[1234].shar files, only
  57. meschach[12].shar are needed for the basic Meschach library; the third
  58. .shar file contains the sparse matrix routines, and the the fourth contains
  59. the routines for complex numbers, vectors and matrices. There is also a
  60. README file that you should get from meschach0.shar.
  61. If you need the old iterative routines, the file oldmeschach.shar
  62. contains the files conjgrad.c, arnoldi.c and lanczos.c.
  63. To get the library from netlib,
  64. mail netlib@research.att.com
  65. send all from c/meschach
  66. There are a number of other netlib sites which mirror the main netlib
  67. sites. These include netlib@ornl.gov (Oak Ridge, TN, USA), netlib@nac.no
  68. (Oslo, Norway), ftp.cs.uow.edu.au (Wollongong, Australia; ftp only),
  69. netlib@nchc.edu.tw (Taiwan), elib.zib-berlin.de (Berlin, Germany; ftp
  70. only). (For anonymous ftp sites the directory containing the Meschach
  71. .shar files is pub/netlib/c/meschach or similar, possibly depending on the
  72. site.)
  73. Meschach is available in other forms on thrain.anu.edu.au by ftp in the
  74. directory pub/meschach. It is available as a .tar file (mesch12a.tar for
  75. version 1.2a), or as a collection of .shar files, or as a .zip file. The
  76. .tar and .zip versions each contain the entire contents of the Meschach
  77. library.
  78. There is a manual called "Meschach: Matrix Computations in C" which has
  79. been published by
  80. Centre for Mathematics and its Applications
  81. School of Mathematical Sciences
  82. Australian National University
  83. Canberra, ACT 0200
  84. Australia
  85. and costs A$30 (about US$22) + postage/handling. You can order it by
  86. writing there or you can send email messages to one of us
  87. (david.stewart@anu.edu.au or zbigniew.leyk@anu.edu.au) and we can pass it
  88. on.
  89. If you don't have any money, as a stop gap you can get the **OLD**
  90. manual, although it is out of date, by anonymous ftp from
  91. thrain.anu.edu.au : /pub/meschach/version1.1b/bookdvi.tar [.Z or .gz]
  92. In addition, don't forget that the distribution includes a DOC directory
  93. which contains tutorial.txt and fnindex.txt which are respectively, the
  94. tutorial chapter (text version) and the function index (text version).
  95. 4. INSTALLATION
  96. a) On Unix machines
  97. To extract the files from the .shar files, put them all into a suitable
  98. directory and use
  99. sh <file>.shar
  100. to expand the files. (Use one sh command per file; sh *.shar will not work
  101. in general.)
  102. For the .tar file, use
  103. tar xvf mesch12a.tar
  104. and for the .zip file use
  105. unzip mesch12a.zip
  106. On a Unix system you can use the configure script to set up the
  107. machine-dependent files. The script takes a number of options which are
  108. used for installing different subsets of the full Meschach. For the basic
  109. system, which requires only meschach[012].shar, use
  110. configure
  111. make basic
  112. make clean
  113. For including sparse operations, which requires meschach[0123].shar, use
  114. configure --with-sparse
  115. make sparse
  116. make clean
  117. For including complex operations, which requires meschach[0124].shar, use
  118. configure --with-complex
  119. make complex
  120. make clean
  121. For including everything, which requires meschach[01234].shar, use
  122. configure --with-all
  123. make all
  124. make clean
  125. To compile the complete library in single precision (with Real equivalent
  126. to float), add the --with-float option to configure, use
  127. configure --with-all --with-float
  128. make all
  129. make clean
  130. Some Unix-like systems may have some problems with this due to bugs or
  131. incompatibilities in various parts of the system. To check this use make
  132. torture and run torture. In this case use the machine-dependent files from
  133. the machines directory. (This is the case for RS/6000 machines, the -O
  134. switch results in failure of a routine in schur.c. Compiling without the
  135. -O switch results in correct results.)
  136. If you have problems using configure, or you use a non-Unix system,
  137. check the MACHINES directory (generated by meschach0.shar) for your
  138. machine, operating system and/or compiler. Save the machine dependent
  139. files makefile, machine.c and machine.h. Copy those files from the
  140. directory for your machine to the directory where the source code is.
  141. To link into a program prog.c, compile it using
  142. cc -o prog_name prog.c ....(source files).... meschach.a -lm
  143. This code has been mostly developed on the University of Queensland,
  144. Australia's Pyramid 9810 running BSD4.3. Initial development was on a
  145. Zilog Zeus Z8000 machine running Zeus, a Unix workalike operating system.
  146. Versions have also been successfully used on various Unix machines
  147. including Sun 3's, IBM RT's, SPARC's and an IBM RS/6000 running AIX. It
  148. has also been compiled on an IBM AT clone using Quick C. It has been
  149. designed to compile under either Kernighan and Richie, (Edition 1) C and
  150. under ANSI C. (And, indeed, it has been compiled in both ANSI C and
  151. non-ANSI C environments.)
  152. b) On non-Unix machines
  153. First look in the machines directory for your system type. If it is
  154. there, then copy the machine dependent files machine.h, makefile (and
  155. possibly machine.c) to the Meschach directory.
  156. If your machine type is not there, then you will need to either compile
  157. ``by hand'', or construct your own makefile and possibly machine.h as well.
  158. The machine-dependent files for various systems should be used as a
  159. starting point, and the ``vanilla'' version of machine.h should be used.
  160. Information on the machine-dependent files follows in the next three
  161. subsections.
  162. On an IBM PC clone, the source code would be on a floppy disk. Use
  163. xcopy a:* meschach
  164. to copy it to the meschach directory. Then ``cd meschach'', and then
  165. compile the source code. Different compilers on MSDOS machines will
  166. require different installation procedures. Check the directory meschach
  167. for the appropriate ``makefile'' for your compiler. If your compiler is
  168. not listed, then you should try compiling it ``by hand'', modifying the
  169. machine-dependent files as necessary.
  170. Worst come to worst, for a given C compiler, execute
  171. <C compiler name> *.c
  172. on MS-DOS machines. For example,
  173. tcc *.c
  174. for Turbo C, and
  175. msc *.c
  176. for Microsoft C, or if you are using Quick C,
  177. qcl *.c
  178. and of course
  179. cc *.c
  180. for the standard Unix compiler.
  181. Once the object files have been generated, you will need to combine them
  182. into a library. Consult your local compiler's manual for details of how to
  183. do this.
  184. When compiling programs/routines that use Meschach, you will need to
  185. have access the the header files in the INCLUDE directory. The INCLUDE
  186. directory's contents can be copied to the directory where the
  187. programs/routines are compiled.
  188. The files in the DOC directory form a very brief form of documentation
  189. on the the library routines in Meschach. See the printed documentation for
  190. more comprehensive documentation of the Meschach routines. This can be
  191. obtained from the authors via email.
  192. The files and directories created by the machines.shar shell archive
  193. contain the files machine.c machine.h and makefile for a particular
  194. machine/operating system/compiler where they need to be different. Copy
  195. the files in the appropriate directory for your machine/operating
  196. system/compiler to the directory with the Meschach source before compiling.
  197. c) makefile
  198. This is setup by using the configure script on a Unix system, based on
  199. the makefile.in file. However, if you want to modify how the library is
  200. compiled, you are free to change the makefile.
  201. The most likely change that you would want to make to this file is to
  202. change the line
  203. CFLAGS = -O
  204. to suit your particular compiler.
  205. The code is intended to be compilable by both ANSI and non-ANSI
  206. compilers.
  207. To achieve this portability without sacrificing the ANSI function
  208. prototypes (which are very useful for avoiding problems with passing
  209. parameters) there is a token ANSI_C which must be #define'd in order to
  210. take full advantage of ANSI C. To do this you should do all compilations
  211. with
  212. #define ANSI_C 1
  213. This can also be done at the compilation stage with a -DANSI_C flag.
  214. Again, you will have to use the -DANSI_C flag or its equivalent whenever
  215. you compile, or insert the line
  216. #define ANSI_C 1
  217. in machine.h, to make full use of ANSI C with this matrix library.
  218. d) machine.h
  219. Like makefile this is normally set up by the configure script on Unix
  220. machines. However, for non-Unix systems, or if you need to set some things
  221. ``by hand'', change machine.h.
  222. There are a few quantities in here that should be modified to suit your
  223. particular compiler. Firstly, the macros MEM_COPY() and MEM_ZERO() need to
  224. be correctly defined here. The original library was compiled on BSD
  225. systems, and so it originally relied on bcopy() and bzero().
  226. In machine.h you will find the definitions for using the standard ANSI C
  227. library routines:
  228. /*--------------------ANSI C--------------------*/
  229. #include <stddef.h>
  230. #include <string.h>
  231. #define MEM_COPY(from,to,size) memmove((to),(from),(size))
  232. #define MEM_ZERO(where,size) memset((where),'\0',(size))
  233. Delete or comment out the alternative definitions and it should compile
  234. correctly. The source files containing memmove() and/or memset() are
  235. available by anonymous ftp from some ftp sites (try archie to discover
  236. them). The files are usually called memmove.c or memset.c.
  237. Some ftp sites which currently (Jan '94) have a version of these files are
  238. munnari.oz.au (in Australia), ftp.uu.net, gatekeeper.dec.com (USA), and
  239. unix.hensa.ac.uk (in the UK). The directory in which you will find
  240. memmove.c and memset.c typically looks like .../bsd-sources/lib/libc/...
  241. There are two further machine-dependent quantities that should be set.
  242. These are machine epsilon or the unit roundoff for double precision
  243. arithmetic, and the maximum value produced by the rand() routine, which is
  244. used in rand_vec() and rand_mat().
  245. The current definitions of these are
  246. #define MACHEPS 2.2e-16
  247. #define MAX_RAND 2.147483648e9
  248. The value of MACHEPS should be correct for all IEEE standard double
  249. precision arithmetic.
  250. However, ANSI C's <float.h> contains #define'd quantities DBL_EPSILON
  251. and RAND_MAX, so if you have an ANSI C compiler and headers, replace the
  252. above two lines of machine.h with
  253. #include <float.h>
  254. /* for Real == float */
  255. #define MACHEPS DBL_EPSILON
  256. #define MAX_RAND RAND_MAX
  257. The default value given for MAX_RAND is 2^31 , as the Pyramid 9810 and
  258. the SPARC 2's both have 32 bit words. There is a program macheps.c which
  259. is included in your source files which computes and prints out the value of
  260. MACHEPS for your machine.
  261. Some other macros control some aspects of Meschach. One of these is
  262. SEGMENTED which should be #define'd if you are working with a machine or
  263. compiler that does not allow large arrays to be allocated. For example,
  264. the most common memory models for MS-DOS compilers do not allow more than
  265. 64Kbyte to be allocated in one block. This limits square matrices to be no
  266. more than 9090 . Inserting #define SEGMENTED 1 into machine.h will mean
  267. that matrices are allocated a row at a time.
  268. 4. SAMPLE TESTS
  269. There are several programs for checking Meschach called torture
  270. (source: torture.c) for the dense routines, sptort (source: sptort.c) for
  271. the sparse routines, ztorture (source ztorture.c) for a complex version of
  272. torture, memtort (source memtort.c) for memory allocation/deallocation,
  273. itertort (source itertort.c) for iterative methods, mfuntort (source
  274. mfuntort.c) for computing powers of dense matrices, iotort (source
  275. iotort.c) for I/O routines. These can be compiled using make by "make
  276. torture", "make sptort", etc. The programs are part of meschach0.shar.
  277. 5. OTHER PROBLEMS
  278. Meschach is not a commercial package, so we do not guarantee that
  279. everything will be perfect or will install smoothly. Inevitably there will
  280. be unforeseen problems. If you come across any bugs or inconsistencies, please
  281. let us know. If you need to modify the results of the configure script, or
  282. need to construct your own machine.h and makefile's, please send them to
  283. us. A number of people sent us the machine dependent files for Meschach 1.1,
  284. but with the use of configure, and the new information needed for version
  285. 1.2, these machine dependent files don't have quite the right information.
  286. Hopefully, though, they are redundant. Non-Unix platforms at present
  287. require ``manual'' installation. Because of the variety of platforms
  288. (MS-DOS, Macintosh, VAX/VMS, Prime, Amiga, Atari, ....) this is left up to
  289. the users of these platforms. We hope that you can use the distibutable
  290. machine-dependent files as a starting point for this task.
  291. If you have programs or routines written using Meschach v.1.1x, you
  292. should put the statement
  293. #include "oldnames.h"
  294. at the beginning of your files. This is because a large number of the
  295. names of the routines have been changed (e.g. "get_vec()" has become
  296. "v_get()"). This will enable you to use the old names, although all of the
  297. error messages etc., will use the new names. Also note that the new
  298. iterative routines have a very different calling sequence. If you need the
  299. old iterative routines, they are in oldmeschach.shar.
  300. If you wish to let us know what you have done, etc., our email
  301. addresses are
  302. david.stewart@anu.edu.au
  303. zbigniew.leyk@anu.edu.au
  304. Good luck!
  305. ACKNOWLEDGMENTS
  306. Many people have helped in various ways with ideas and suggestions.
  307. Needless to say, the bugs are all ours! But these people should be thanked
  308. for their encouragement etc. These include a number of people at
  309. University of Queensland: Graeme Chandler, David De Wit, Martin Sharry,
  310. Michael Forbes, Phil Kilby, John Holt, Phil Pollett and Tony Watts. At the
  311. Australian National University: Mike Osborne, Steve Roberts, Margaret Kahn
  312. and Teresa Leyk. Karen George of the University of Canberra has been a
  313. source of both ideas and encouragement. Email has become significant part
  314. of work, and many people have pointed out bugs, inconsistencies and
  315. improvements to Meschach by email. These people include Ajay Shah of the
  316. University of Southern California, Dov Grobgeld of the Weizmann Institute,
  317. John Edstrom of the University of Calgary, Eric Grosse, one of the netlib
  318. organisers, Ole Saether of Oslo, Norway, Alfred Thiele and Pierre
  319. Asselin of Carnegie-Mellon Univeristy, Daniel Polani of the University of
  320. Mainz, Marian Slodicka of Slovakia, Kaifu Wu of Pomona, Hidetoshi
  321. Shimodaira of the University of Tokyo, Eng Siong of Edinburgh, Hirokawa Rui
  322. of the University of Tokyo, Marko Slyz of the University of Michigan, and
  323. Brook Milligan of the University of Texas. This list is only partial, and
  324. there are many others who have corresponded with us on details about
  325. Meschach and the like. Finally our thanks go to all those that have had to
  326. struggle with compilers and other things to get Meschach to work.