237
|
1 // kludge.h -*- C++ -*- |
|
2 /* |
|
3 |
1011
|
4 Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton |
237
|
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 |
1315
|
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
237
|
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 |
1359
|
35 // Like type operations for vectors. |
237
|
36 |
|
37 // Element by element vector by scalar ops. |
|
38 |
|
39 friend KL_VEC_TYPE operator + (const KL_VEC_TYPE& a, const TYPE& s); |
|
40 friend KL_VEC_TYPE operator - (const KL_VEC_TYPE& a, const TYPE& s); |
|
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 |
|
44 // Element by element scalar by vector ops. |
|
45 |
|
46 friend KL_VEC_TYPE operator + (const TYPE& s, const KL_VEC_TYPE& a); |
|
47 friend KL_VEC_TYPE operator - (const TYPE& s, const KL_VEC_TYPE& a); |
|
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 |
|
51 // Element by element vector by vector ops. |
|
52 |
|
53 friend KL_VEC_TYPE operator + (const KL_VEC_TYPE& a, const KL_VEC_TYPE& b); |
|
54 friend KL_VEC_TYPE operator - (const KL_VEC_TYPE& a, const KL_VEC_TYPE& b); |
|
55 |
|
56 friend KL_VEC_TYPE product (const KL_VEC_TYPE& a, const KL_VEC_TYPE& b); |
|
57 friend KL_VEC_TYPE quotient (const KL_VEC_TYPE& a, const KL_VEC_TYPE& b); |
|
58 |
|
59 // Unary MArray ops. |
|
60 |
|
61 friend KL_VEC_TYPE operator - (const KL_VEC_TYPE& a); |
|
62 |
|
63 #endif |
|
64 |
|
65 #ifdef KLUDGE_MATRICES |
|
66 |
1359
|
67 // Like type operations for matrices |
237
|
68 |
|
69 // Element by element matrix by scalar ops. |
|
70 |
|
71 friend KL_MAT_TYPE operator + (const KL_MAT_TYPE& a, const TYPE& s); |
|
72 friend KL_MAT_TYPE operator - (const KL_MAT_TYPE& a, const TYPE& s); |
|
73 friend KL_MAT_TYPE operator * (const KL_MAT_TYPE& a, const TYPE& s); |
|
74 friend KL_MAT_TYPE operator / (const KL_MAT_TYPE& a, const TYPE& s); |
|
75 |
|
76 // Element by element scalar by matrix ops. |
|
77 |
|
78 friend KL_MAT_TYPE operator + (const TYPE& s, const KL_MAT_TYPE& a); |
|
79 friend KL_MAT_TYPE operator - (const TYPE& s, const KL_MAT_TYPE& a); |
|
80 friend KL_MAT_TYPE operator * (const TYPE& s, const KL_MAT_TYPE& a); |
|
81 friend KL_MAT_TYPE operator / (const TYPE& s, const KL_MAT_TYPE& a); |
|
82 |
|
83 // Element by element matrix by matrix ops. |
|
84 |
|
85 friend KL_MAT_TYPE operator + (const KL_MAT_TYPE& a, const KL_MAT_TYPE& b); |
|
86 friend KL_MAT_TYPE operator - (const KL_MAT_TYPE& a, const KL_MAT_TYPE& b); |
|
87 |
|
88 friend KL_MAT_TYPE product (const KL_MAT_TYPE& a, const KL_MAT_TYPE& b); |
|
89 friend KL_MAT_TYPE quotient (const KL_MAT_TYPE& a, const KL_MAT_TYPE& b); |
|
90 |
|
91 // Unary matrix ops. |
|
92 |
|
93 friend KL_MAT_TYPE operator - (const KL_MAT_TYPE& a); |
|
94 |
|
95 #endif |
|
96 |
|
97 #ifdef KLUDGE_DIAG_MATRICES |
|
98 |
1359
|
99 // Like type operations for diagonal matrices. |
237
|
100 |
|
101 // Element by element MDiagArray by scalar ops. |
|
102 |
|
103 friend KL_DMAT_TYPE operator * (const KL_DMAT_TYPE& a, const TYPE& s); |
|
104 friend KL_DMAT_TYPE operator / (const KL_DMAT_TYPE& a, const TYPE& s); |
|
105 |
|
106 // Element by element scalar by MDiagArray ops. |
|
107 |
|
108 friend KL_DMAT_TYPE operator * (const TYPE& s, const KL_DMAT_TYPE& a); |
|
109 |
|
110 // Element by element MDiagArray by MDiagArray ops. |
|
111 |
|
112 friend KL_DMAT_TYPE operator + (const KL_DMAT_TYPE& a, const KL_DMAT_TYPE& b); |
|
113 friend KL_DMAT_TYPE operator - (const KL_DMAT_TYPE& a, const KL_DMAT_TYPE& b); |
|
114 |
|
115 friend KL_DMAT_TYPE product (const KL_DMAT_TYPE& a, const KL_DMAT_TYPE& b); |
|
116 |
|
117 // Unary MDiagArray ops. |
|
118 |
|
119 friend KL_DMAT_TYPE operator - (const KL_DMAT_TYPE& a); |
|
120 |
|
121 #endif |
|
122 |
|
123 /* |
|
124 ;;; Local Variables: *** |
|
125 ;;; mode: C++ *** |
|
126 ;;; page-delimiter: "^/\\*" *** |
|
127 ;;; End: *** |
|
128 */ |