home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / sci / math / symbolic / 2267 < prev    next >
Encoding:
Text File  |  1992-08-26  |  2.5 KB  |  69 lines

  1. Newsgroups: sci.math.symbolic
  2. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!wupost!cs.utexas.edu!torn!watserv2.uwaterloo.ca!watdragon.uwaterloo.ca!daisy.uwaterloo.ca!kogeddes
  3. From: kogeddes@daisy.uwaterloo.ca (Keith O. Geddes)
  4. Subject: Re: function arguments type checking in MapleV
  5. Message-ID: <BtLGK2.9AC@watdragon.uwaterloo.ca>
  6. Sender: news@watdragon.uwaterloo.ca (USENET News System)
  7. Organization: University of Waterloo
  8. References: <FMMOORE.92Aug25193637@momoney.mit.edu>
  9. Date: Wed, 26 Aug 1992 14:07:14 GMT
  10. Lines: 57
  11.  
  12. In article <FMMOORE.92Aug25193637@momoney.mit.edu> fmmoore@athena.mit.edu (Fes-Mike Moore) writes:
  13. >I'm trying to define type/procargs as described in ?type[argcheck] (page
  14. >223 of the Maple V Library Reference manual).  This is what I'm
  15. >entering:
  16. >
  17. >    > `type/expectationargs` := [indexed * function(indexed)];
  18. >              type/expectationargs := [indexed function(indexed)]
  19. >    > expectation := proc(expr)
  20. >    > local i,j,k,l;
  21. >    >   if not type([expr], expectationargs) then
  22. >    >       ERROR(
  23. >    >   `invalid arguments; must be in form of indexed * function(indexed)`)
  24. >    > fi;
  25. >    > i := op(1,op(1,expr)); 
  26. >    > j := op(2,op(1,expr)); 
  27. >    > k := op(1,op(1,op(2,expr))); 
  28. >    > l := op(2,op(1,op(2,expr))); 
  29. >    > print(i,j,k,l) 
  30. >    > end;
  31. >
  32. >When I run the program, though, I get:
  33. >
  34. >    > testarg := z[a,b]*conjugate(z[fes,mike]);
  35. >                   testarg := z[a, b] conjugate(z[fes, mike])
  36. >
  37. >    _____________________________________________________________________
  38. >    > expectation(testarg);
  39. >    Error, (in expectation) testing against an invalid type
  40. >
  41. >Aren't function and indexed valid types?  If so, why can't they be used
  42. >in this manner?  Or am I overlooking something else?
  43. >
  44.  
  45. Yes, function and indexed are valid types.
  46.  
  47. The problem is with the "product" type.
  48. As one discovers from the help page  ?type[structured]  (or equivalently,
  49. in the Maple V Library Reference Manual, Section 2.1.335 "Definition of
  50. a structured type in Maple" -- see the table on page 252),
  51. the type "product of terms" must be specified using  &*
  52. and similarly the type "sum of terms" must be specified using  &+ .
  53. An alternative in cases where all terms are of the same type, is to use
  54. the forms  `*`(type)  or  `+`(type) .
  55.  
  56. In your case, by changing your first line to
  57.  
  58. > `type/expectationargs` := [indexed &* function(indexed)];
  59.  
  60. it will work fine.
  61.  
  62.  
  63. Professor Keith Geddes
  64. Director, Symbolic Computation Group
  65. Department of Computer Science
  66. University of Waterloo
  67. Waterloo, Ontario
  68. Canada N2L 3G1                     kogeddes@daisy.uwaterloo.ca
  69.