[comp.lang.c++] Patch to get RVector to work under 2.0

keffer@blake.acs.washington.edu (Thomas Keffer) (07/28/89)

Some people have been having trouble getting my RVector package to
compile under 2.0.  The problem seems to be a (potential) bug in the
way pointers to overloaded functions are handled.  There's also a
problem with #error preprocessor directives.  Here's a patch to fix
both problems.

This package is available via anonymous ftp to
sperm.ocean.washington.edu (128.208.2.7).

-tk

---
 Dr. Thomas Keffer          | Internet: keffer@sperm.ocean.washington.edu
 School of Oceanography     | BITNET:   keffer%sperm.ocean.washington.edu@UWAVM
 Univ. of Washington, WB-10 | uucp:     uw-beaver!sperm.ocean.washington.edu!keffer
 Seattle, WA 98195          | Telemail: T.KEFFER/OMNET
    (206) 543-6455

<--- cut here ---><--- cut here ---><--- cut here ---><--- cut here --->
diff -rc RWVector1.1/rw/DComplexVec.h RWVector1.1.1/rw/DComplexVec.h
*** RWVector1.1/rw/DComplexVec.h	Thu Jul 27 11:23:15 1989
--- RWVector1.1.1/rw/DComplexVec.h	Thu Jul 27 11:20:40 1989
***************
*** 22,28 ****
   *	This software is provided "as is" without any
   *	expressed or implied warranty.
   *
!  *	@(#)DComplexVec.h	1.1	6/29/89
   */
  
  
--- 22,28 ----
   *	This software is provided "as is" without any
   *	expressed or implied warranty.
   *
!  *	@(#)DComplexVec.h	1.2	7/27/89
   */
  
  
***************
*** 252,259 ****
  inline DComplexVec sinh(const DComplexSlice& V)	{ return V.apply(::sinh); }
  inline DComplexVec sqrt(const DComplexSlice& V)	{ return V.apply(::sqrt); }
  inline DComplexVec conj(const DComplexSlice& V)	{ return V.apply(::conj); }
- INLINE DoubleVec real(const DComplexSlice& V)	{ return V.apply3(::real); }
- INLINE DoubleVec imag(const DComplexSlice& V)	{ return V.apply3(::imag); }
  inline DoubleVec norm(const DComplexSlice& V)	{ return V.apply2(::norm); }
  inline DoubleVec arg(const DComplexSlice& V)	{ return V.apply2(::arg); }
  inline DComplex mean(const DComplexSlice& V)	{ return sum(V)/V.length(); }
--- 252,257 ----
diff -rc RWVector1.1/src/cfft.cc RWVector1.1.1/src/cfft.cc
*** RWVector1.1/src/cfft.cc	Thu Jul 27 13:52:03 1989
--- RWVector1.1.1/src/cfft.cc	Thu Jul 27 14:03:16 1989
***************
*** 19,25 ****
   *	expressed or implied warranty.
   *
   *
!  *	@(#)cfft.cc	1.1	6/29/89
   */
  
  
--- 19,25 ----
   *	expressed or implied warranty.
   *
   *
!  *	@(#)cfft.cc	1.2	7/27/89
   */
  
  
***************
*** 75,81 ****
    DComplexVec inverse = v.copy();
    DCfftf_(&temp_length, inverse.data(), the_weights.data());
  #else
! #error	Code requires that sizeof(complex)==2*sizeof(double)
  #endif
  
    return inverse;
--- 75,81 ----
    DComplexVec inverse = v.copy();
    DCfftf_(&temp_length, inverse.data(), the_weights.data());
  #else
! You lose.	Code requires that sizeof(complex)==2*sizeof(double)
  #endif
  
    return inverse;
***************
*** 96,102 ****
    DComplexVec inverse = v.copy();
    DCfftb_(&temp_length, inverse.data(), the_weights.data());
  #else
! #error	Code requires that sizeof(complex)==2*sizeof(double)
  #endif
  
    return inverse;
--- 96,102 ----
    DComplexVec inverse = v.copy();
    DCfftb_(&temp_length, inverse.data(), the_weights.data());
  #else
! You lose.	Code requires that sizeof(complex)==2*sizeof(double)
  #endif
  
    return inverse;
diff -rc RWVector1.1/src/xslcmath.cc RWVector1.1.1/src/xslcmath.cc
*** RWVector1.1/src/xslcmath.cc	Thu Jun 29 17:42:05 1989
--- RWVector1.1.1/src/xslcmath.cc	Thu Jul 27 11:19:47 1989
***************
*** 19,25 ****
   *	expressed or implied warranty.
   *
   *
!  *	@(#)xslcmath.cc	1.1	6/29/89
   */
  
  /*
--- 19,25 ----
   *	expressed or implied warranty.
   *
   *
!  *	@(#)xslcmath.cc	1.2	7/27/89
   */
  
  /*
***************
*** 54,59 ****
--- 54,85 ----
  	register j = stride();
  	while (i--) { *dp++ = f(*sp);  sp += j; }
  	return temp;
+ }
+ 
+ // Version 2.0 has trouble finding the proper overloaded real.
+ // Put in an explicit version:
+ <P>Vec
+ real(const <T>Slice& v)
+ {
+   register i = v.length();
+   <P>Vec temp(i);
+   register <T>* sp = v.data();
+   register <P>* dp = temp.data();
+   register j = v.stride();
+   while(i--) {*dp++ = real(*sp); sp += j;}
+   return temp;
+ }
+ 
+ <P>Vec
+ imag(const <T>Slice& v)
+ {
+   register i = v.length();
+   <P>Vec temp(i);
+   register <T>* sp = v.data();
+   register <P>* dp = temp.data();
+   register j = v.stride();
+   while(i--) {*dp++ = imag(*sp); sp += j;}
+   return temp;
  }
  
  #ifdef __ATT__