home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / pascal / 4610 < prev    next >
Encoding:
Text File  |  1992-07-29  |  1.6 KB  |  51 lines

  1. Newsgroups: comp.lang.pascal
  2. Path: sparky!uunet!sun-barr!cs.utexas.edu!torn!news.ccs.queensu.ca!dmurdoch
  3. From: dmurdoch@QueensU.CA (Duncan Murdoch)
  4. Subject: Re: Matrix routines in pascal
  5. Message-ID: <Bs6M0B.BK6@knot.ccs.queensu.ca>
  6. Sender: news@knot.ccs.queensu.ca (Netnews control)
  7. Organization: Queen's University, Kingston, Canada
  8. References: <1992Jul29.162918.13707@csi.jpl.nasa.gov> <Bs5wKs.3pE@knot.ccs.queensu.ca> <1992Jul30.010006.19073@reed.edu>
  9. Distribution: usa
  10. Date: Thu, 30 Jul 1992 03:07:23 GMT
  11. Lines: 38
  12.  
  13. In article <1992Jul30.010006.19073@reed.edu> orpheus@reed.edu (P. Hawthorne) writes:
  14.  
  15. > QMatrix = object(QContent)
  16. >   EntrySize: Longint;
  17. >   EntriesAcross: Longint;
  18. >   EntriesDown: Longint;
  19. >   Entries: EntryArray;
  20. >
  21. >   function QMatrix.Construct: Boolean;
  22. >   override;
  23. >
  24. >   procedure QMatrix.SetEntry (x, y: Longint; aPtr: univ Ptr);
  25. >   procedure QMatrix.GetEntry (x, y: Longint; aPtr: univ Ptr);
  26. >  end;
  27.  
  28. That's more general than what I did (I decided to specialize from the
  29. beginning on "float" entries, in the hope of getting some efficiency
  30. benefits), but suffers from the same problems as mine:
  31.  
  32. Simple statements like
  33.  
  34.   prod[j,k] := prod[j,k] + factor1[j,i]*factor2[i,k];
  35.  
  36. become ugly messes like:
  37.  
  38.   prod^.setval(j,k, prod^.val(j,k) 
  39.                       + factor1^.val(j,i)*factor2^.val(i,k));
  40.  
  41. and handling expressions like
  42.  
  43.   prod := MatrixProduct(factor1, MatrixSum(term1, term2));
  44.  
  45. becomes a real pain.  This is one area that's made me think seriously of
  46. switching to C++; luckily I tried reading Stroustrup's book, which
  47. brought me back to my senses :-).
  48.  
  49. Duncan Murdoch
  50. dmurdoch@mast.queensu.ca
  51.