home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 27 / IOPROG_27.ISO / SOFT / DRMATRIX.ZIP / DOC / DRMATRIX.DOC next >
Encoding:
Text File  |  1997-01-01  |  14.7 KB  |  319 lines

  1.                               
  2. ────────────────────────────────────────────────────────────
  3. ────────────────────────────────────────────────────────────
  4.  
  5.                         DOCTOR MATRIX
  6.                         Version 1.00
  7.  
  8. ────────────────────────────────────────────────────────────
  9.                               
  10.              Shareware Vector and Matrix Algebra
  11.                  Programming Package for C++
  12.  
  13. ────────────────────────────────────────────────────────────
  14.  
  15.                      PROGRAMMER'S GUIDE
  16.  
  17. ────────────────────────────────────────────────────────────
  18.                               
  19.                       by Zvika Ben-Haim
  20.  
  21. ────────────────────────────────────────────────────────────
  22. ────────────────────────────────────────────────────────────
  23.  
  24.  
  25.  
  26. INTRODUCTION
  27. ────────────────────────────────────────────────────────────
  28.       This document describes the most basic characteristics
  29. of  the Doctor Matrix programming package, explained  in  an
  30. easy,  straightforward manner. It is  intended  to  get  you
  31. started  using  Doctor Matrix, and is by  no  means  a  full
  32. description  of the package, which includes over  50  vector
  33. and  matrix  functions.  After  you  figure  out  the  basic
  34. features  described in this document, you may be  interested
  35. in   reading  about  advanced  functions  in  the   Function
  36. Reference.
  37.      Dr. Matrix is a C++ programming package that allows the
  38. calculation  of  matrix  and  vector  functions  easily  and
  39. painlessly. All of the calculations are transparent  to  the
  40. programmer, and are used, as much as possible, in  the  same
  41. way   as  arithmetic  operations  of  standard  data  types.
  42. Supported   vector   operations  include  vector   addition,
  43. multiplication of a vector by a scalar, vector products, and
  44. more.   Supported   matrix  operations   include   addition,
  45. multiplication,   matrix  trace,  matrix   ranking,   matrix
  46. inversion, finding stepped and canonized matrices and more.
  47.      Dr.   Matrix  takes  full  advantage  of  the  template
  48. facility supported by the ANSI C++ Standard, Release 3. This
  49. allows  you  to customize the matrix and vector classes  for
  50. your  own use. If you are looking for fast, efficient matrix
  51. calculations, you can define an integer matrix class. If you
  52. want  accurate results, use double matrices,  or  even  long
  53. double matrices. You can even combine the matrix class  with
  54. any  other  numeric  class, for example  to  create  complex
  55. number  matrices.  The unregistered version  allows  you  to
  56. create only int and float objects.
  57.  
  58.  
  59. STATUS OF THIS PROGRAM
  60. ────────────────────────────────────────────────────────────
  61.       This program is shareware. You are allowed to test  it
  62. for  a  reasonable  amount of time for  evaluation  purposes
  63. only.  You  are  encouraged  to copy  the  package  to  your
  64. friends, under the condition that you do not alter any  part
  65. of it.
  66.      If  you  intend  to use Doctor Matrix for  any  purpose
  67. other  than  evaluation,  you must register.  You  have  two
  68. options  for registering: The Economy Package costs  a  mere
  69. $15 and allows you to compile in memory models from Tiny  to
  70. Medium, as well as use matrix and vector objects of standard
  71. data  types (excluding high-precision floating-point types).
  72. Your  other option is to purchase Doctor Matrix Pro,  a  $50
  73. package  that  comes  with complete commented  source  code,
  74. allows  you  to  use all memory models from  Tiny  to  Huge,
  75. allows  you to create matrix and vector objects of all  data
  76. types  (including non-standard classes), and enables you  to
  77. make  your own modifications and enhancements to the source.
  78. You will also receive a free upgrade, should a newer version
  79. be released.
  80.       If  you  find a mistake, have a suggestion for  future
  81. versions,  or  just  have a general  comment,  please  don't
  82. hesitate to write to me. Also, if you have written any  sort
  83. of  extension to the Doctor Matrix package which  you  think
  84. others could use, please send it to me. If I find it useful,
  85. I  will add it to the next version of Doctor Matrix, and you
  86. will receive a registered version (Economy Package) free  of
  87. charge.
  88.       This  package is copyrighted 1996-1997 by  Zvika  Ben-
  89. Haim. All rights reserved.
  90.       I can be contacted by e-mail at the following address:
  91. zvikabh@rotem.technion.ac.il. Remember it takes  courage  to
  92. reveal  one's e-mail publicly like this, so please spare  me
  93. your  junk  mail  and flames, they will be  deleted  without
  94. being read. You can also visit my web site,  where  you  can
  95. download some other shareware programs and packages  that  I
  96. wrote. The URL is http://t2.technion.ac.il/~s3498650/
  97.  
  98.  
  99. SYSTEM REQUIREMENTS
  100. ────────────────────────────────────────────────────────────
  101.       Doctor  Matrix  contains a header file,  DRMATRIX.HPP,
  102. which  should be included in every module using  the  Doctor
  103. Matrix  functions. It also contains a set of library  files.
  104. One  of these library files should be added to your project.
  105. The correct file to be added depends on the memory model you
  106. are  using:  DRMTRXT.OBJ  for  the  Tiny  memory  model   or
  107. DRMTRXS.OBJ  for  the  Small memory  model.  The  registered
  108. version  of  the  program includes support  for  all  memory
  109. models, including Medium, Compact, Large, and Huge.
  110.       Doctor  Matrix requires the inclusion of the  standard
  111. ANSI  C++  header  file IOSTREAM.H and the standard  ANSI  C
  112. header  file  STDLIB.H.  If they  are  not  included  before
  113. including  DRMATRIX.HPP, Doctor Matrix  will  include  these
  114. files  automatically. It also requires the use of the sqrt()
  115. function,  which is non-standard C/C++ but is almost  always
  116. found in the MATH.H header file.
  117.       If you are having trouble getting Doctor Matrix to run
  118. on  your  compiler, particularly if it is  an  old  or  non-
  119. standard  compiler,  refer  to the  Troubleshooting  section
  120. later in this document.
  121.  
  122.  
  123. VECTORS: THE BASICS
  124. ────────────────────────────────────────────────────────────
  125.       A vector is an ordered set of one or more items of the
  126. same  type.  For instance, (3.0  2.3  1.9) is  a  vector  of
  127. order  3  and  of  data type float. Vectors can  be  aligned
  128. vertically  or horizontally, which simply means the  numbers
  129. in  the set can be written from left to right or from top to
  130. bottom. When creating a vector, you must know its order, the
  131. type  of data items it contains, and its alignment. You then
  132. create the vector using the following command:
  133.  
  134.   Vector<float> my_vect(4,V_VERT);
  135.  
  136.      The `float' can be changed to any numeric data type, or
  137. any numeric class (see the section Matrices of Classes). The
  138. vector  name my_vect can be replaced with any legal variable
  139. name.  The  number  4  specifies the order  (the  number  of
  140. elements in the vector), and can be any integer from  1  up,
  141. assuming there is sufficient memory. Following the order, an
  142. optional  alignment specification can follow in parentheses.
  143. The  allowed  alignment  options  are  V_VERT  for  vertical
  144. alignment,  and  V_HORIZ  for horizontal  alignment.  If  no
  145. alignment  mode is specified, the vector is  assumed  to  be
  146. aligned horizontally (V_HORIZ).
  147.        To   access  the  vector  elements,  use  parentheses
  148. containing the subscript. For instance,
  149.  
  150.   my_vect(3) = 1.2;
  151.   cout << my_vect(4);
  152.  
  153.      The subscript operator [] has been avoided to emphasize
  154. the  fact  that, unlike C/C++ subscripts, vector  subscripts
  155. are  1-based; that is, the first element is number 1 (rather
  156. that  0).  This  follows the mathematics convention,  rather
  157. than the C/C++ convention.
  158.       Vectors  of the same size, type and alignment  can  be
  159. added  to each other using the addition operator. The result
  160. is  a  vector of the same size, type and alignment, in which
  161. each  element is the sum of the same element in each of  the
  162. vectors. Likewise, a vector can be multiplied by a scalar (a
  163. variable  of  the same type as the elements in the  vector).
  164. The   resulting  vector  is  of  the  same  type,  size  and
  165. alignment,  and each of its elements is the product  of  the
  166. original vector's respective element by the scalar.  A  "dot
  167. product"  between two vectors can also be calculated.  These
  168. and  many  more  functions  are described  in  the  function
  169. reference.
  170.  
  171.  
  172. MATRICES: THE BASICS
  173. ────────────────────────────────────────────────────────────
  174.       Using  matrices  is basically just as  easy  as  using
  175. vectors. To define a matrix, use the form:
  176.  
  177.   Matrix<float> my_matrix(3,4);
  178.  
  179.      Where "float" can be replaced by any numeric data type,
  180. my_matrix  is the matrix name, and the two numbers represent
  181. the  size of the matrix: the first is the number of rows and
  182. the  second is the number of columns. To access an  element,
  183. use the parenthesis operator (), for example:
  184.  
  185.   my_matrix(1,1) = -.09;
  186.  
  187.       Like vectors, matrix subscripts are 1-based: the first
  188. row  is  number 1 and the first column is number  1.  Matrix
  189. addition  and  multiplication work just  like  addition  and
  190. multiplication in standard data types; for instance,
  191.  
  192.   Z = M1 * M2;
  193.   M1 = Z + M1;
  194.  
  195.       A  detailed  description of  these  and  other  matrix
  196. operators and functions is given in the reference.
  197.  
  198.  
  199. MATRICES OF CLASSES (Registered Version Only)
  200. ────────────────────────────────────────────────────────────
  201.       In most cases, using a standard data type will suffice
  202. for ordinary matrix operations. However, you may want to use
  203. matrices  of user-defined numeric classes, such as  matrices
  204. of  complex  numbers,  matrices of extra-precision  numbers,
  205. etc. This is done in the same way as defining a matrix of an
  206. ordinary data type; however, for the code to compile and run
  207. correctly,  the  class  you use must support  the  following
  208. arithmetic operations:
  209. - Support  for  addition,  subtraction,  multiplication  and
  210.   division of class objects using overloaded  operators,  as
  211.   well as support  for the modification operators  (+=,  -=,
  212.   etc.);
  213. - Support for assignment of class objects to class objects;
  214. - A  constructor  of  the  form   X::X(int)   or  a  similar
  215.   constructor which enables integers to be assigned to class
  216.   objects;
  217. - A function called sqrt() which receives one  parameter  of
  218.   the class type, and returns the square root of the object,
  219.   either as another object of that class or as a  data  type
  220.   that can be cast to the class.
  221.  
  222.  
  223. THE NEXT STEP
  224. ────────────────────────────────────────────────────────────
  225.       You've  only  begun  to explore the  power  of  Doctor
  226. Matrix.  There are many more features you can  learn  about.
  227. The  sample programs that come with this package demonstrate
  228. many of them. You can find the source code for this programs
  229. in  the  EXAMPLES  subdirectory. The DRMDEMO  program  is  a
  230. straightforward  demonstration of many of  the  features  in
  231. Doctor  Matrix. The SOLVER program is an example of the  use
  232. of matrix arithmetic in solving linear equations.
  233.       If  you want specific information about a function  or
  234. operator,  look  it  up  in  the  function  reference.   The
  235. reference  contains  specific  infomration  on  the   usage,
  236. purpose  and exact effect of all operators and functions  in
  237. the package.
  238.  
  239.  
  240. TROUBLESHOOTING
  241. ────────────────────────────────────────────────────────────
  242.       Doctor  Matrix was designed and tested in the  Borland
  243. C++  3.1 IDE. As mentioned, it is fully compliant with other
  244. ANSI C++ Release 3 compilers. However, you may encounter the
  245. following difficulties when using it:
  246.  
  247. Header File Won't Compile:
  248.       Some old compilers do not support ANSI C++ Release  3.
  249. For  example, Borland Turbo C++ versions 1.x and 2.x do  not
  250. support  this  version.  They  are  therefore  incapable  of
  251. handling Doctor Matrix classes.
  252.       If  you  are  using Borland C++ 3.x, see  the  section
  253. "Problems with Debugging".
  254.  
  255. Header File Compiles Incorrectly:
  256.      If   you   are  using  non-standard  versions  of   the
  257. IOSTREAM.H   and  STDLIB.H  header  files,  and   experience
  258. problems  due  to  the fact that Doctor Matrix  attempts  to
  259. include   these  files  although  they  have  already   been
  260. included, add the following lines to your program before the
  261. directive which includes DRMATRIX.HPP:
  262.  
  263.   #define __IOSTREAM_H
  264.   #define __STDLIB_H
  265.  
  266.       These directives tell Doctor Matrix not to attempt  to
  267. include   the   header  files,  and  are   usually   defined
  268. automatically within the header file.
  269.  
  270. Problems with Displaying Errors:
  271.       Doctor Matrix uses the standard error output stream to
  272. print  out  errors that occur during processing  of  various
  273. functions.  These  errors can almost always  be  avoided  by
  274. sufficient input checking by the programmer. However, it  is
  275. best  to  ensure  that the standard error stream  (cerr)  is
  276. valid  and  can  be used for output. In particular,  Windows
  277. programmers  and  other GUI programmers should  ensure  that
  278. cerr  is  redirected to a valid output stream,  such  as  an
  279. error log file. For information on how to do this, refer  to
  280. your C++ manual.
  281.  
  282. Memory Problems:
  283.       Allocating large vectors or matrices, or many of them,
  284. may  cause memory problems. Some tips for freeing up  memory
  285. are listed in the list of errors in the Reference, under the
  286. error "Not enough memory to allocate matrix/vector."
  287.  
  288. Problems with Debugging:
  289.       Borland  C++  3.1 has serious problems with  debugging
  290. programs  with  templates. This problem may occur  in  other
  291. Borland compilers as well. It is a bug in the compiler,  and
  292. not  in  the Dr. Matrix package, so please yell at  Borland,
  293. not at me.
  294.      The effect of this bug is as follows: Borland C++ tends
  295. to  incorrectly  compile  the module  information  into  the
  296. executable. This information tells the compiler which module
  297. contained  the  source  for  the  current  statement   being
  298. executed.  The  effect  of this bug is  that  when  stepping
  299. through  a  program, you may seem to jump into  a  different
  300. file  than  you  actually are. The line  numbers  are  still
  301. correct,  so that you can still figure out where you  really
  302. are, but it's a pain (I know; I had to do this a lot when  I
  303. was debugging Dr. Matrix).
  304.      This bug also causes Borland C++ to report compile-time
  305. errors  as belonging to a different file than they  actually
  306. are. Again, looking through the correct file containing  the
  307. error,  at  the  reported  line  causing  the  error,  is  a
  308. workaround to this problem.
  309.  
  310. If All Else Fails...
  311.       If  you encounter a difficulty in your program and are
  312. convinced  that  it results from the Doctor Matrix  classes,
  313. write  to  me. Describe the problem, and give code  portions
  314. (not complete programs!) that illustrate the error. Indicate
  315. your  OS  name  and version, compiler name and version,  and
  316. anything  else you think might help to explain when  or  why
  317. the problem occurs.
  318.  
  319.