Mercurial > octave-nkf
annotate liboctave/MArrayN.cc @ 9607:1be3c73ed7b5
reuse temporary arrays in nested expressions
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 03 Sep 2009 08:48:51 +0200 |
parents | 3a1dd361f978 |
children | 66970dd627f6 |
rev | line source |
---|---|
4508 | 1 /* |
2 | |
9245 | 3 Copyright (C) 1996, 1997, 2003, 2004, 2005, 2007, 2009 John W. Eaton |
4508 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
4508 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
4508 | 20 |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include <config.h> | |
25 #endif | |
26 | |
27 #include "MArrayN.h" | |
4669 | 28 #include "Array-util.h" |
4508 | 29 #include "lo-error.h" |
30 | |
31 #include "MArray-defs.h" | |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9557
diff
changeset
|
32 #include "mx-inlines.cc" |
4508 | 33 |
4513 | 34 // N-dimensional array with math ops. |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9557
diff
changeset
|
35 template <class T> |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9557
diff
changeset
|
36 void |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9557
diff
changeset
|
37 MArrayN<T>::changesign (void) |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9557
diff
changeset
|
38 { |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9557
diff
changeset
|
39 if (Array<T>::is_shared ()) |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9557
diff
changeset
|
40 *this = - *this; |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9557
diff
changeset
|
41 else |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9557
diff
changeset
|
42 do_mx_inplace_op<MArrayN<T> > (*this, mx_inline_uminus2); |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9557
diff
changeset
|
43 } |
4508 | 44 |
45 // Element by element MArrayN by scalar ops. | |
46 | |
47 template <class T> | |
48 MArrayN<T>& | |
49 operator += (MArrayN<T>& a, const T& s) | |
50 { | |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
51 if (a.is_shared ()) |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
52 return a = a + s; |
4646 | 53 DO_VS_OP2 (T, a, +=, s) |
4508 | 54 return a; |
55 } | |
56 | |
57 template <class T> | |
58 MArrayN<T>& | |
59 operator -= (MArrayN<T>& a, const T& s) | |
60 { | |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
61 if (a.is_shared ()) |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
62 return a = a - s; |
4646 | 63 DO_VS_OP2 (T, a, -=, s) |
4508 | 64 return a; |
65 } | |
66 | |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
67 template <class T> |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
68 MArrayN<T>& |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
69 operator *= (MArrayN<T>& a, const T& s) |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
70 { |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
71 if (a.is_shared ()) |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
72 return a = a * s; |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
73 DO_VS_OP2 (T, a, *=, s) |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
74 return a; |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
75 } |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
76 |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
77 template <class T> |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
78 MArrayN<T>& |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
79 operator /= (MArrayN<T>& a, const T& s) |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
80 { |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
81 if (a.is_shared ()) |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
82 return a = a / s; |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
83 DO_VS_OP2 (T, a, /=, s) |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
84 return a; |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
85 } |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
86 |
4543 | 87 // Element by element MArrayN by MArrayN ops. |
88 | |
89 template <class T> | |
90 MArrayN<T>& | |
91 operator += (MArrayN<T>& a, const MArrayN<T>& b) | |
92 { | |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
93 if (a.is_shared ()) |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
94 return a = a + b; |
9548
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
95 |
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
96 dim_vector a_dims = a.dims (); |
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
97 dim_vector b_dims = b.dims (); |
4645 | 98 |
9548
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
99 if (a_dims != b_dims) |
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
100 gripe_nonconformant ("operator +=", a_dims, b_dims); |
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
101 else |
4543 | 102 { |
9548
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
103 octave_idx_type l = a.length (); |
4645 | 104 |
9548
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
105 if (l > 0) |
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
106 DO_VV_OP2 (T, a, +=, b); |
4543 | 107 } |
4645 | 108 |
4543 | 109 return a; |
110 } | |
111 | |
112 template <class T> | |
113 MArrayN<T>& | |
114 operator -= (MArrayN<T>& a, const MArrayN<T>& b) | |
115 { | |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
116 if (a.is_shared ()) |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
117 return a = a - b; |
9548
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
118 |
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
119 dim_vector a_dims = a.dims (); |
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
120 dim_vector b_dims = b.dims (); |
4645 | 121 |
9548
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
122 if (a_dims != b_dims) |
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
123 gripe_nonconformant ("operator -=", a_dims, b_dims); |
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
124 else |
4543 | 125 { |
9548
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
126 octave_idx_type l = a.length (); |
4645 | 127 |
9548
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
128 if (l > 0) |
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
129 DO_VV_OP2 (T, a, -=, b); |
4543 | 130 } |
9548
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
131 |
4543 | 132 return a; |
133 } | |
134 | |
9557
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
135 template <class T> |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
136 MArrayN<T>& |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
137 product_eq (MArrayN<T>& a, const MArrayN<T>& b) |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
138 { |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
139 if (a.is_shared ()) |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
140 return a = product (a, b); |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
141 |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
142 dim_vector a_dims = a.dims (); |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
143 dim_vector b_dims = b.dims (); |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
144 |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
145 if (a_dims != b_dims) |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
146 gripe_nonconformant ("operator .*=", a_dims, b_dims); |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
147 else |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
148 { |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
149 octave_idx_type l = a.length (); |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
150 |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
151 if (l > 0) |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
152 DO_VV_OP2 (T, a, *=, b); |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
153 } |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
154 |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
155 return a; |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
156 } |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
157 |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
158 template <class T> |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
159 MArrayN<T>& |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
160 quotient_eq (MArrayN<T>& a, const MArrayN<T>& b) |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
161 { |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
162 if (a.is_shared ()) |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
163 return a = quotient (a, b); |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
164 |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
165 dim_vector a_dims = a.dims (); |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
166 dim_vector b_dims = b.dims (); |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
167 |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
168 if (a_dims != b_dims) |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
169 gripe_nonconformant ("operator ./=", a_dims, b_dims); |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
170 else |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
171 { |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
172 octave_idx_type l = a.length (); |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
173 |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
174 if (l > 0) |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
175 DO_VV_OP2 (T, a, /=, b); |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
176 } |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
177 |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
178 return a; |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
179 } |
3a1dd361f978
optimize .*=, ./= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
180 |
4543 | 181 // Element by element MArrayN by scalar ops. |
182 | |
4508 | 183 #define MARRAYN_NDS_OP(OP) \ |
184 template <class T> \ | |
185 MArrayN<T> \ | |
186 operator OP (const MArrayN<T>& a, const T& s) \ | |
187 { \ | |
188 MArrayN<T> result (a.dims ()); \ | |
189 T *r = result.fortran_vec (); \ | |
5275 | 190 octave_idx_type l = a.length (); \ |
4508 | 191 const T *v = a.data (); \ |
192 DO_VS_OP (r, l, v, OP, s); \ | |
193 return result; \ | |
194 } | |
195 | |
196 MARRAYN_NDS_OP (+) | |
197 MARRAYN_NDS_OP (-) | |
198 MARRAYN_NDS_OP (*) | |
199 MARRAYN_NDS_OP (/) | |
200 | |
201 // Element by element MArrayN by scalar ops. | |
202 | |
203 #define MARRAYN_SND_OP(OP) \ | |
204 template <class T> \ | |
205 MArrayN<T> \ | |
206 operator OP (const T& s, const MArrayN<T>& a) \ | |
207 { \ | |
208 MArrayN<T> result (a.dims ()); \ | |
209 T *r = result.fortran_vec (); \ | |
5275 | 210 octave_idx_type l = a.length (); \ |
4508 | 211 const T *v = a.data (); \ |
212 DO_SV_OP (r, l, s, OP, v); \ | |
213 return result; \ | |
214 } | |
215 | |
216 MARRAYN_SND_OP (+) | |
217 MARRAYN_SND_OP (-) | |
218 MARRAYN_SND_OP (*) | |
219 MARRAYN_SND_OP (/) | |
220 | |
221 #define MARRAY_NDND_OP(FCN, OP) \ | |
222 template <class T> \ | |
223 MArrayN<T> \ | |
224 FCN (const MArrayN<T>& a, const MArrayN<T>& b) \ | |
225 { \ | |
4513 | 226 dim_vector a_dims = a.dims (); \ |
227 dim_vector b_dims = b.dims (); \ | |
4508 | 228 int dims_ok = 1; \ |
229 int any_dims_zero = 0; \ | |
230 if (a_dims.length () != b_dims.length ()) \ | |
231 dims_ok = 0; \ | |
232 else \ | |
233 { \ | |
234 for (int i = 0; i < a_dims.length (); i++) \ | |
235 { \ | |
236 if (a_dims (i) != b_dims (i)) \ | |
237 { dims_ok = 0; break; } \ | |
238 if (a_dims (i) == 0) \ | |
239 any_dims_zero = 1; \ | |
240 } \ | |
241 } \ | |
242 if (!dims_ok) \ | |
243 { \ | |
244 gripe_nonconformant (#FCN, a_dims, b_dims); \ | |
245 return MArrayN<T> (); \ | |
246 } \ | |
247 if (any_dims_zero) \ | |
248 return MArrayN<T> (a_dims); \ | |
5275 | 249 octave_idx_type l = a.length (); \ |
4508 | 250 MArrayN<T> result (a_dims); \ |
251 T* r = result.fortran_vec (); \ | |
252 const T *x = a.data (); \ | |
253 const T *y = b.data (); \ | |
254 DO_VV_OP (r, l, x, OP, y); \ | |
255 return result; \ | |
256 } | |
257 | |
258 MARRAY_NDND_OP (operator +, +) | |
259 MARRAY_NDND_OP (operator -, -) | |
4543 | 260 MARRAY_NDND_OP (product, *) |
261 MARRAY_NDND_OP (quotient, /) | |
4508 | 262 |
263 template <class T> | |
264 MArrayN<T> | |
265 operator + (const MArrayN<T>& a) | |
266 { | |
267 return a; | |
268 } | |
269 | |
270 template <class T> | |
271 MArrayN<T> | |
272 operator - (const MArrayN<T>& a) | |
273 { | |
5275 | 274 octave_idx_type l = a.length (); |
4508 | 275 MArrayN<T> result (a.dims ()); |
276 T *r = result.fortran_vec (); | |
277 const T *x = a.data (); | |
278 NEG_V (r, l, x); | |
279 return result; | |
280 } | |
281 | |
282 /* | |
283 ;;; Local Variables: *** | |
284 ;;; mode: C++ *** | |
285 ;;; End: *** | |
286 */ |