home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / cplus / 15922 < prev    next >
Encoding:
Text File  |  1992-11-08  |  1.6 KB  |  40 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!think.com!spool.mu.edu!umn.edu!news.orst.edu!belar.ECE.ORST.EDU!gnk
  3. From: gnk@belar.ECE.ORST.EDU (Giri Rangan)
  4. Subject: Multiple representation of an object type
  5. Message-ID: <BxDGKn.4u2@news.orst.edu>
  6. Sender: usenet@news.orst.edu
  7. Nntp-Posting-Host: belar.ece.orst.edu
  8. Organization: none
  9. Date: Sun, 8 Nov 1992 00:41:08 GMT
  10. Lines: 28
  11.  
  12. Hi,
  13.  
  14. I am in search of a correct and a very efficient way of implementing
  15. multiple representations of an object type. Here is an example :
  16.  
  17. I have a polynomial class. A polynomial can be represented in two ways.
  18. One is to store the coefficients of each order term and the other way
  19. is to store the roots of the polynomial. Both the representations are
  20. useful and required, especially since my variable is a complex 
  21. quantity ('z'). Hence, the coefficient representation is useful while
  22. doing addition and subtraction of polynomials while the roots 
  23. representation is useful while doing multiplication or division.
  24.  
  25. Another point to note is that the two representations are inter
  26. convertible. As a result, if I change a particular coefficient, then
  27. the present roots of the polynomial are no longer valid. They will have
  28. to change too.
  29.  
  30. So how are such class types normally implemented ? I feel my  present
  31. way of implementation is rather messy.
  32.  
  33. Please mail to :
  34. gnk@aldur.ece.orst.edu
  35. -- 
  36. =================================================================                       
  37.                         Giri NK Rangan
  38. Dept of ECE, Oregon State University, Corvallis, OR 97331.
  39. =================================================================                       
  40.