home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / misc / 2809 < prev    next >
Encoding:
Internet Message Format  |  1992-08-30  |  3.1 KB

  1. Path: sparky!uunet!ogicse!network.ucsd.edu!lyapunov.ucsd.edu!mbk
  2. From: mbk@lyapunov.ucsd.edu (Matt Kennel)
  3. Newsgroups: comp.lang.misc
  4. Subject: Re: Scientists as Programmers (was Re: Small Language Wanted)
  5. Message-ID: <17peeqINNkg8@network.ucsd.edu>
  6. Date: 30 Aug 92 03:14:34 GMT
  7. Article-I.D.: network.17peeqINNkg8
  8. References: <BEVAN.92Aug29191507@tiger.cs.man.ac.uk>
  9. Organization: Institute For Nonlinear Science, UCSD
  10. Lines: 78
  11. NNTP-Posting-Host: lyapunov.ucsd.edu
  12. X-Newsreader: Tin 1.1 PL3
  13.  
  14. bevan@cs.man.ac.uk (Stephen J Bevan) writes:
  15. : In article <17n6fjINNhvt@network.ucsd.edu> mbk@lyapunov.ucsd.edu (Matt Kennel) writes:
  16. :    I have no idea what Mr Rubin really wants but here are a couple of 
  17. :    easy ones of the top of my head:
  18. :     P, D, Q <- singular_value_decomposition(A);
  19. : How about :-
  20. : (p,d,q) = singular_value_decomposition A
  21.  
  22. This is perfectly sensible.
  23.  
  24. :    Array index notation:
  25. :    for all i <= j: a(i,j) <- sum over (k) ( b(i,k)*c(j,N,k) )
  26. : I'm not _exactly_ sure what the above does (e.g. is N constant?), so
  27. : the following may be wrong (but it is better than my previous attempt
  28. : which I hopefully cancelled correctly :-)
  29.  
  30. What I mean is that the upper triangular part of "a" is equal to B *
  31. transpose("C"), but where the matrix "C" is "spread" out through different
  32. parts of a 3tensor arrays.
  33.  
  34. : foo b c = array bds vs
  35. :   where
  36. :     vs = [ (i,j) := f i j | (i,j) <- range bds, i <= j ]
  37. :     f i j = sum [ b!(i,k)*c!(j,n,k) | k <- range (klb,kub) ]
  38. :     bds = ((ilb,jlb),(iub,jub))
  39. :     ((ilb,klb),(iub,kub)) = bounds b
  40. :     ((jlb,_,_),(jub,n,_)) = bounds c
  41.  
  42. This is perfectly ridiculous!  I have no clue what that means.
  43. I don't think one should have to write a subroutine to implement each simple
  44. array statement.
  45.  
  46. : An alternative (and possibly more efficient) version of _vs_ is :-
  47. :   vs = [ (i,j) := f i j | i <- range (ilb,iub), j <- range (i,jub) ]
  48. : Note this is untested as I currently don't have a compiler installed.
  49. : As to the notation, I'll do you a deal: you explain the one you're
  50. : using and I'll explain the one I'm using :-)
  51.  
  52. What's called "implied summation convention" means "sum over repeated
  53. indices"on the right hand side of the assignment
  54. and iterate over covarying indices on both sides.  (No I didn't invent
  55. this...heard it's also called "Einstein summation convention" as it's
  56. very useful in relativity calculations).
  57.  
  58. So if C(i,j,k) is a 3-tensor, then 
  59.  
  60. T(i) = C(i,j,j)
  61.  
  62. means for each matrix C(i,*,*) compute its trace and assign to T(i).
  63. (Yes the indices should automatically figure out their bounds).
  64.  
  65. I think it wouldn't be so bad to allow you to explicitly say these things:
  66.  
  67. for all i T(i) = sum_over(j) C(i,j,j)
  68.  
  69. sum_over or sum or whatever is the of course just the traditional capital
  70. sigma symbol used in math, and of course all it means is add everything
  71. up.
  72.  
  73. :    I won't bore you with the obvious complex numbers, exponentiation, etc.
  74. : Why not, you may be pleasantly suprised.
  75. : bevan
  76.  
  77. --
  78. -Matt Kennel          mbk@inls1.ucsd.edu
  79. -Institute for Nonlinear Science, University of California, San Diego
  80. -*** AD: Archive for nonlinear dynamics papers & programs: FTP to
  81. -***     lyapunov.ucsd.edu, username "anonymous".
  82.