home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / octave-1.1.1p1-bin.lha / include / octave / mx-kludge.h < prev    next >
C/C++ Source or Header  |  1996-10-12  |  4KB  |  140 lines

  1. // kludge.h                                             -*- C++ -*-
  2. /*
  3.  
  4. Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton
  5.  
  6. This file is part of Octave.
  7.  
  8. Octave is free software; you can redistribute it and/or modify it
  9. under the terms of the GNU General Public License as published by the
  10. Free Software Foundation; either version 2, or (at your option) any
  11. later version.
  12.  
  13. Octave is distributed in the hope that it will be useful, but WITHOUT
  14. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  15. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  16. for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with Octave; see the file COPYING.  If not, write to the Free
  20. Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22. */
  23.  
  24. // Nothing like a little CPP abuse to brighten everyone's day.  Would
  25. // have been nice to do this with template functions but as of 2.5.x,
  26. // g++ seems to fail in various ways, either not resolving general
  27. // template functions, or not instatiating non-member template
  28. // functions.
  29. //
  30. // When templates work more reliably in g++, this will be replaced by
  31. // the MArray class.
  32.  
  33. #ifdef KLUDGE_VECTORS
  34.  
  35. /*
  36.  * Like type operations for vectors.
  37.  */
  38.  
  39. // Element by element vector by scalar ops.
  40.  
  41. friend KL_VEC_TYPE operator + (const KL_VEC_TYPE& a, const TYPE& s);
  42. friend KL_VEC_TYPE operator - (const KL_VEC_TYPE& a, const TYPE& s);
  43. friend KL_VEC_TYPE operator * (const KL_VEC_TYPE& a, const TYPE& s);
  44. friend KL_VEC_TYPE operator / (const KL_VEC_TYPE& a, const TYPE& s);
  45.  
  46. // Element by element scalar by vector ops.
  47.  
  48. friend KL_VEC_TYPE operator + (const TYPE& s, const KL_VEC_TYPE& a);
  49. friend KL_VEC_TYPE operator - (const TYPE& s, const KL_VEC_TYPE& a);
  50. friend KL_VEC_TYPE operator * (const TYPE& s, const KL_VEC_TYPE& a);
  51. friend KL_VEC_TYPE operator / (const TYPE& s, const KL_VEC_TYPE& a);
  52.  
  53. // Element by element vector by vector ops.
  54.  
  55. friend KL_VEC_TYPE operator + (const KL_VEC_TYPE& a, const KL_VEC_TYPE& b);
  56. friend KL_VEC_TYPE operator - (const KL_VEC_TYPE& a, const KL_VEC_TYPE& b);
  57.  
  58. friend KL_VEC_TYPE product (const KL_VEC_TYPE& a, const KL_VEC_TYPE& b);
  59. friend KL_VEC_TYPE quotient (const KL_VEC_TYPE& a, const KL_VEC_TYPE& b);
  60.  
  61. // Unary MArray ops.
  62.  
  63. friend KL_VEC_TYPE operator - (const KL_VEC_TYPE& a);
  64.  
  65. #endif
  66.  
  67. #ifdef KLUDGE_MATRICES
  68.  
  69. /*
  70.  * Like type operations for matrices
  71.  */
  72.  
  73. // Element by element matrix by scalar ops.
  74.  
  75. friend KL_MAT_TYPE operator + (const KL_MAT_TYPE& a, const TYPE& s);
  76. friend KL_MAT_TYPE operator - (const KL_MAT_TYPE& a, const TYPE& s);
  77. friend KL_MAT_TYPE operator * (const KL_MAT_TYPE& a, const TYPE& s);
  78. friend KL_MAT_TYPE operator / (const KL_MAT_TYPE& a, const TYPE& s);
  79.  
  80. // Element by element scalar by matrix ops.
  81.  
  82. friend KL_MAT_TYPE operator + (const TYPE& s, const KL_MAT_TYPE& a);
  83. friend KL_MAT_TYPE operator - (const TYPE& s, const KL_MAT_TYPE& a);
  84. friend KL_MAT_TYPE operator * (const TYPE& s, const KL_MAT_TYPE& a);
  85. friend KL_MAT_TYPE operator / (const TYPE& s, const KL_MAT_TYPE& a);
  86.  
  87. // Element by element matrix by matrix ops.
  88.  
  89. friend KL_MAT_TYPE operator + (const KL_MAT_TYPE& a, const KL_MAT_TYPE& b);
  90. friend KL_MAT_TYPE operator - (const KL_MAT_TYPE& a, const KL_MAT_TYPE& b);
  91.  
  92. friend KL_MAT_TYPE product (const KL_MAT_TYPE& a, const KL_MAT_TYPE& b);
  93. friend KL_MAT_TYPE quotient (const KL_MAT_TYPE& a, const KL_MAT_TYPE& b);
  94.  
  95. // Unary matrix ops.
  96.  
  97. friend KL_MAT_TYPE operator - (const KL_MAT_TYPE& a);
  98.  
  99. #endif
  100.  
  101. #ifdef KLUDGE_DIAG_MATRICES
  102.  
  103. /*
  104.  * Like type operations for diagonal matrices.
  105.  */
  106.  
  107. // Element by element MDiagArray by scalar ops.
  108.  
  109. friend KL_DMAT_TYPE operator * (const KL_DMAT_TYPE& a, const TYPE& s);
  110. friend KL_DMAT_TYPE operator / (const KL_DMAT_TYPE& a, const TYPE& s);
  111.  
  112. // Element by element scalar by MDiagArray ops.
  113.  
  114. friend KL_DMAT_TYPE operator * (const TYPE& s, const KL_DMAT_TYPE& a);
  115.  
  116. // Element by element MDiagArray by MDiagArray ops.
  117.  
  118. friend KL_DMAT_TYPE operator + (const KL_DMAT_TYPE& a, const KL_DMAT_TYPE& b);
  119. friend KL_DMAT_TYPE operator - (const KL_DMAT_TYPE& a, const KL_DMAT_TYPE& b);
  120.  
  121. friend KL_DMAT_TYPE product (const KL_DMAT_TYPE& a, const KL_DMAT_TYPE& b);
  122.  
  123. // Unary MDiagArray ops.
  124.  
  125. friend KL_DMAT_TYPE operator - (const KL_DMAT_TYPE& a);
  126.  
  127. #endif
  128.  
  129. #undef DO_SV_OP
  130. #undef DO_VS_OP
  131. #undef DO_VV_OP
  132. #undef NEG_V
  133.  
  134. /*
  135. ;;; Local Variables: ***
  136. ;;; mode: C++ ***
  137. ;;; page-delimiter: "^/\\*" ***
  138. ;;; End: ***
  139. */
  140.