Mercurial > octave
annotate liboctave/array/CRowVector.cc @ 21202:f7121e111991
maint: indent #ifdef blocks in liboctave and src directories.
* Array-C.cc, Array-b.cc, Array-ch.cc, Array-d.cc, Array-f.cc, Array-fC.cc,
Array-i.cc, Array-idx-vec.cc, Array-s.cc, Array-str.cc, Array-util.cc,
Array-voidp.cc, Array.cc, CColVector.cc, CDiagMatrix.cc, CMatrix.cc,
CNDArray.cc, CRowVector.cc, CSparse.cc, CSparse.h, DiagArray2.cc, MArray-C.cc,
MArray-d.cc, MArray-f.cc, MArray-fC.cc, MArray-i.cc, MArray-s.cc, MArray.cc,
MDiagArray2.cc, MSparse-C.cc, MSparse-d.cc, MSparse.h, MatrixType.cc,
PermMatrix.cc, Range.cc, Sparse-C.cc, Sparse-b.cc, Sparse-d.cc, Sparse.cc,
boolMatrix.cc, boolNDArray.cc, boolSparse.cc, chMatrix.cc, chNDArray.cc,
dColVector.cc, dDiagMatrix.cc, dMatrix.cc, dNDArray.cc, dRowVector.cc,
dSparse.cc, dSparse.h, dim-vector.cc, fCColVector.cc, fCDiagMatrix.cc,
fCMatrix.cc, fCNDArray.cc, fCRowVector.cc, fColVector.cc, fDiagMatrix.cc,
fMatrix.cc, fNDArray.cc, fRowVector.cc, idx-vector.cc, int16NDArray.cc,
int32NDArray.cc, int64NDArray.cc, int8NDArray.cc, intNDArray.cc,
uint16NDArray.cc, uint32NDArray.cc, uint64NDArray.cc, uint8NDArray.cc,
blaswrap.c, cquit.c, f77-extern.cc, f77-fcn.c, f77-fcn.h, lo-error.c, quit.cc,
quit.h, CmplxAEPBAL.cc, CmplxCHOL.cc, CmplxGEPBAL.cc, CmplxHESS.cc, CmplxLU.cc,
CmplxQR.cc, CmplxQRP.cc, CmplxSCHUR.cc, CmplxSVD.cc, CollocWt.cc, DASPK.cc,
DASRT.cc, DASSL.cc, EIG.cc, LSODE.cc, ODES.cc, Quad.cc, base-lu.cc, base-qr.cc,
dbleAEPBAL.cc, dbleCHOL.cc, dbleGEPBAL.cc, dbleHESS.cc, dbleLU.cc, dbleQR.cc,
dbleQRP.cc, dbleSCHUR.cc, dbleSVD.cc, eigs-base.cc, fCmplxAEPBAL.cc,
fCmplxCHOL.cc, fCmplxGEPBAL.cc, fCmplxHESS.cc, fCmplxLU.cc, fCmplxQR.cc,
fCmplxQRP.cc, fCmplxSCHUR.cc, fCmplxSVD.cc, fEIG.cc, floatAEPBAL.cc,
floatCHOL.cc, floatGEPBAL.cc, floatHESS.cc, floatLU.cc, floatQR.cc,
floatQRP.cc, floatSCHUR.cc, floatSVD.cc, lo-mappers.cc, lo-specfun.cc,
oct-convn.cc, oct-fftw.cc, oct-fftw.h, oct-norm.cc, oct-rand.cc,
oct-spparms.cc, randgamma.c, randmtzig.c, randpoisson.c, sparse-chol.cc,
sparse-dmsolve.cc, sparse-lu.cc, sparse-qr.cc, mx-defs.h, dir-ops.cc,
file-ops.cc, file-stat.cc, lo-sysdep.cc, mach-info.cc, oct-env.cc,
oct-group.cc, oct-openmp.h, oct-passwd.cc, oct-syscalls.cc, oct-time.cc,
oct-uname.cc, pathlen.h, sysdir.h, syswait.h, cmd-edit.cc, cmd-hist.cc,
data-conv.cc, f2c-main.c, glob-match.cc, lo-array-errwarn.cc,
lo-array-gripes.cc, lo-cutils.c, lo-cutils.h, lo-ieee.cc, lo-math.h,
lo-regexp.cc, lo-utils.cc, oct-base64.cc, oct-glob.cc, oct-inttypes.cc,
oct-inttypes.h, oct-locbuf.cc, oct-mutex.cc, oct-refcount.h, oct-rl-edit.c,
oct-rl-hist.c, oct-shlib.cc, oct-sort.cc, pathsearch.cc, singleton-cleanup.cc,
sparse-sort.cc, sparse-util.cc, statdefs.h, str-vec.cc, unwind-prot.cc,
url-transfer.cc, display-available.h, main-cli.cc, main-gui.cc, main.in.cc,
mkoctfile.in.cc, octave-config.in.cc, shared-fcns.h:
indent #ifdef blocks in liboctave and src directories.
author | Rik <rik@octave.org> |
---|---|
date | Sat, 06 Feb 2016 06:40:13 -0800 |
parents | 7cac4e7458f2 |
children | 40de9f8f23a6 |
rev | line source |
---|---|
1993 | 1 // RowVector manipulations. |
458 | 2 /* |
3 | |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
4 Copyright (C) 1994-2015 John W. Eaton |
458 | 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 | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
458 | 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 | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
458 | 21 |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
21202
f7121e111991
maint: indent #ifdef blocks in liboctave and src directories.
Rik <rik@octave.org>
parents:
21136
diff
changeset
|
25 # include <config.h> |
458 | 26 #endif |
27 | |
3503 | 28 #include <iostream> |
458 | 29 |
4669 | 30 #include "Array-util.h" |
1847 | 31 #include "f77-fcn.h" |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
32 #include "functor.h" |
1368 | 33 #include "lo-error.h" |
458 | 34 #include "mx-base.h" |
35 #include "mx-inlines.cc" | |
1650 | 36 #include "oct-cmplx.h" |
458 | 37 |
38 // Fortran functions we call. | |
39 | |
40 extern "C" | |
41 { | |
4552 | 42 F77_RET_T |
43 F77_FUNC (zgemv, ZGEMV) (F77_CONST_CHAR_ARG_DECL, | |
11518 | 44 const octave_idx_type&, const octave_idx_type&, |
45 const Complex&, const Complex*, | |
46 const octave_idx_type&, const Complex*, | |
47 const octave_idx_type&, const Complex&, Complex*, | |
48 const octave_idx_type& | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
49 F77_CHAR_ARG_LEN_DECL); |
5983 | 50 |
51 F77_RET_T | |
11518 | 52 F77_FUNC (xzdotu, XZDOTU) (const octave_idx_type&, const Complex*, |
53 const octave_idx_type&, const Complex*, | |
54 const octave_idx_type&, Complex&); | |
458 | 55 } |
56 | |
1360 | 57 // Complex Row Vector class |
458 | 58 |
2386 | 59 bool |
458 | 60 ComplexRowVector::operator == (const ComplexRowVector& a) const |
61 { | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
62 octave_idx_type len = numel (); |
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
63 if (len != a.numel ()) |
458 | 64 return 0; |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8999
diff
changeset
|
65 return mx_inline_equal (len, data (), a.data ()); |
458 | 66 } |
67 | |
2386 | 68 bool |
458 | 69 ComplexRowVector::operator != (const ComplexRowVector& a) const |
70 { | |
71 return !(*this == a); | |
72 } | |
73 | |
74 // destructive insert/delete/reorder operations | |
75 | |
76 ComplexRowVector& | |
5275 | 77 ComplexRowVector::insert (const RowVector& a, octave_idx_type c) |
458 | 78 { |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
79 octave_idx_type a_len = a.numel (); |
4316 | 80 |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
81 if (c < 0 || c + a_len > numel ()) |
21136
7cac4e7458f2
maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents:
21129
diff
changeset
|
82 (*current_liboctave_error_handler) ("range error for insert"); |
458 | 83 |
4316 | 84 if (a_len > 0) |
85 { | |
86 make_unique (); | |
87 | |
5275 | 88 for (octave_idx_type i = 0; i < a_len; i++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
89 xelem (c+i) = a.elem (i); |
4316 | 90 } |
458 | 91 |
92 return *this; | |
93 } | |
94 | |
95 ComplexRowVector& | |
5275 | 96 ComplexRowVector::insert (const ComplexRowVector& a, octave_idx_type c) |
458 | 97 { |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
98 octave_idx_type a_len = a.numel (); |
4316 | 99 |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
100 if (c < 0 || c + a_len > numel ()) |
21136
7cac4e7458f2
maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents:
21129
diff
changeset
|
101 (*current_liboctave_error_handler) ("range error for insert"); |
458 | 102 |
4316 | 103 if (a_len > 0) |
104 { | |
105 make_unique (); | |
106 | |
5275 | 107 for (octave_idx_type i = 0; i < a_len; i++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
108 xelem (c+i) = a.elem (i); |
4316 | 109 } |
458 | 110 |
111 return *this; | |
112 } | |
113 | |
114 ComplexRowVector& | |
115 ComplexRowVector::fill (double val) | |
116 { | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
117 octave_idx_type len = numel (); |
4316 | 118 |
458 | 119 if (len > 0) |
4316 | 120 { |
121 make_unique (); | |
122 | |
5275 | 123 for (octave_idx_type i = 0; i < len; i++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
124 xelem (i) = val; |
4316 | 125 } |
126 | |
458 | 127 return *this; |
128 } | |
129 | |
130 ComplexRowVector& | |
131 ComplexRowVector::fill (const Complex& val) | |
132 { | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
133 octave_idx_type len = numel (); |
4316 | 134 |
458 | 135 if (len > 0) |
4316 | 136 { |
137 make_unique (); | |
138 | |
5275 | 139 for (octave_idx_type i = 0; i < len; i++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
140 xelem (i) = val; |
4316 | 141 } |
142 | |
458 | 143 return *this; |
144 } | |
145 | |
146 ComplexRowVector& | |
5275 | 147 ComplexRowVector::fill (double val, octave_idx_type c1, octave_idx_type c2) |
458 | 148 { |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
149 octave_idx_type len = numel (); |
4316 | 150 |
458 | 151 if (c1 < 0 || c2 < 0 || c1 >= len || c2 >= len) |
21136
7cac4e7458f2
maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents:
21129
diff
changeset
|
152 (*current_liboctave_error_handler) ("range error for fill"); |
458 | 153 |
17663
7975d75f933c
Use std::swap in liboctave instead of temporary variable.
Rik <rik@octave.org>
parents:
15271
diff
changeset
|
154 if (c1 > c2) { std::swap (c1, c2); } |
458 | 155 |
4316 | 156 if (c2 >= c1) |
157 { | |
158 make_unique (); | |
159 | |
5275 | 160 for (octave_idx_type i = c1; i <= c2; i++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
161 xelem (i) = val; |
4316 | 162 } |
458 | 163 |
164 return *this; | |
165 } | |
166 | |
167 ComplexRowVector& | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
168 ComplexRowVector::fill (const Complex& val, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
169 octave_idx_type c1, octave_idx_type c2) |
458 | 170 { |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
171 octave_idx_type len = numel (); |
4316 | 172 |
458 | 173 if (c1 < 0 || c2 < 0 || c1 >= len || c2 >= len) |
21136
7cac4e7458f2
maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents:
21129
diff
changeset
|
174 (*current_liboctave_error_handler) ("range error for fill"); |
458 | 175 |
17663
7975d75f933c
Use std::swap in liboctave instead of temporary variable.
Rik <rik@octave.org>
parents:
15271
diff
changeset
|
176 if (c1 > c2) { std::swap (c1, c2); } |
458 | 177 |
4316 | 178 if (c2 >= c1) |
179 { | |
180 make_unique (); | |
181 | |
5275 | 182 for (octave_idx_type i = c1; i <= c2; i++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
183 xelem (i) = val; |
4316 | 184 } |
458 | 185 |
186 return *this; | |
187 } | |
188 | |
189 ComplexRowVector | |
190 ComplexRowVector::append (const RowVector& a) const | |
191 { | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
192 octave_idx_type len = numel (); |
5275 | 193 octave_idx_type nc_insert = len; |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
194 ComplexRowVector retval (len + a.numel ()); |
458 | 195 retval.insert (*this, 0); |
196 retval.insert (a, nc_insert); | |
197 return retval; | |
198 } | |
199 | |
200 ComplexRowVector | |
201 ComplexRowVector::append (const ComplexRowVector& a) const | |
202 { | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
203 octave_idx_type len = numel (); |
5275 | 204 octave_idx_type nc_insert = len; |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
205 ComplexRowVector retval (len + a.numel ()); |
458 | 206 retval.insert (*this, 0); |
207 retval.insert (a, nc_insert); | |
208 return retval; | |
209 } | |
210 | |
211 ComplexColumnVector | |
212 ComplexRowVector::hermitian (void) const | |
213 { | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7503
diff
changeset
|
214 return MArray<Complex>::hermitian (std::conj); |
458 | 215 } |
216 | |
217 ComplexColumnVector | |
218 ComplexRowVector::transpose (void) const | |
219 { | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7503
diff
changeset
|
220 return MArray<Complex>::transpose (); |
458 | 221 } |
222 | |
223 ComplexRowVector | |
224 conj (const ComplexRowVector& a) | |
225 { | |
13107
353c71c76f22
maint: fix compilation problem with g++ -std=c++0x option
Júlio Hoffimann <julio.hoffimann@gmail.com>
parents:
11523
diff
changeset
|
226 return do_mx_unary_map<Complex, Complex, std::conj<double> > (a); |
458 | 227 } |
228 | |
229 // resize is the destructive equivalent for this one | |
230 | |
231 ComplexRowVector | |
5275 | 232 ComplexRowVector::extract (octave_idx_type c1, octave_idx_type c2) const |
458 | 233 { |
17663
7975d75f933c
Use std::swap in liboctave instead of temporary variable.
Rik <rik@octave.org>
parents:
15271
diff
changeset
|
234 if (c1 > c2) { std::swap (c1, c2); } |
458 | 235 |
5275 | 236 octave_idx_type new_c = c2 - c1 + 1; |
458 | 237 |
238 ComplexRowVector result (new_c); | |
239 | |
5275 | 240 for (octave_idx_type i = 0; i < new_c; i++) |
458 | 241 result.elem (i) = elem (c1+i); |
242 | |
243 return result; | |
244 } | |
245 | |
4316 | 246 ComplexRowVector |
5275 | 247 ComplexRowVector::extract_n (octave_idx_type r1, octave_idx_type n) const |
4316 | 248 { |
249 ComplexRowVector result (n); | |
250 | |
5275 | 251 for (octave_idx_type i = 0; i < n; i++) |
4316 | 252 result.elem (i) = elem (r1+i); |
253 | |
254 return result; | |
255 } | |
256 | |
458 | 257 // row vector by row vector -> row vector operations |
258 | |
259 ComplexRowVector& | |
260 ComplexRowVector::operator += (const RowVector& a) | |
261 { | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
262 octave_idx_type len = numel (); |
2386 | 263 |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
264 octave_idx_type a_len = a.numel (); |
2386 | 265 |
266 if (len != a_len) | |
21129
228b65504557
maint: Eliminate useless statements after err_XXX.
Rik <rik@octave.org>
parents:
21120
diff
changeset
|
267 err_nonconformant ("operator +=", len, a_len); |
458 | 268 |
269 if (len == 0) | |
270 return *this; | |
271 | |
272 Complex *d = fortran_vec (); // Ensures only one reference to my privates! | |
273 | |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8999
diff
changeset
|
274 mx_inline_add2 (len, d, a.data ()); |
458 | 275 return *this; |
276 } | |
277 | |
278 ComplexRowVector& | |
279 ComplexRowVector::operator -= (const RowVector& a) | |
280 { | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
281 octave_idx_type len = numel (); |
2386 | 282 |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
283 octave_idx_type a_len = a.numel (); |
2386 | 284 |
285 if (len != a_len) | |
21129
228b65504557
maint: Eliminate useless statements after err_XXX.
Rik <rik@octave.org>
parents:
21120
diff
changeset
|
286 err_nonconformant ("operator -=", len, a_len); |
458 | 287 |
288 if (len == 0) | |
289 return *this; | |
290 | |
291 Complex *d = fortran_vec (); // Ensures only one reference to my privates! | |
292 | |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8999
diff
changeset
|
293 mx_inline_sub2 (len, d, a.data ()); |
458 | 294 return *this; |
295 } | |
296 | |
297 // row vector by matrix -> row vector | |
298 | |
299 ComplexRowVector | |
300 operator * (const ComplexRowVector& v, const ComplexMatrix& a) | |
301 { | |
1947 | 302 ComplexRowVector retval; |
303 | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
304 octave_idx_type len = v.numel (); |
1947 | 305 |
5275 | 306 octave_idx_type a_nr = a.rows (); |
307 octave_idx_type a_nc = a.cols (); | |
2386 | 308 |
309 if (a_nr != len) | |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
20466
diff
changeset
|
310 err_nonconformant ("operator *", 1, len, a_nr, a_nc); |
21120
499b851fbfae
Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
311 |
499b851fbfae
Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
312 if (len == 0) |
499b851fbfae
Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
313 retval.resize (a_nc, 0.0); |
1947 | 314 else |
458 | 315 { |
21120
499b851fbfae
Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
316 // Transpose A to form A'*x == (x'*A)' |
1947 | 317 |
21120
499b851fbfae
Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
318 octave_idx_type ld = a_nr; |
1947 | 319 |
21120
499b851fbfae
Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
320 retval.resize (a_nc); |
499b851fbfae
Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
321 Complex *y = retval.fortran_vec (); |
1947 | 322 |
21120
499b851fbfae
Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
323 F77_XFCN (zgemv, ZGEMV, (F77_CONST_CHAR_ARG2 ("T", 1), |
499b851fbfae
Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
324 a_nr, a_nc, 1.0, a.data (), |
499b851fbfae
Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
325 ld, v.data (), 1, 0.0, y, 1 |
499b851fbfae
Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
326 F77_CHAR_ARG_LEN (1))); |
458 | 327 } |
328 | |
1947 | 329 return retval; |
458 | 330 } |
331 | |
1205 | 332 ComplexRowVector |
333 operator * (const RowVector& v, const ComplexMatrix& a) | |
334 { | |
335 ComplexRowVector tmp (v); | |
336 return tmp * a; | |
337 } | |
338 | |
458 | 339 // other operations |
340 | |
341 Complex | |
342 ComplexRowVector::min (void) const | |
343 { | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
344 octave_idx_type len = numel (); |
458 | 345 if (len == 0) |
346 return Complex (0.0); | |
347 | |
348 Complex res = elem (0); | |
5260 | 349 double absres = std::abs (res); |
458 | 350 |
5275 | 351 for (octave_idx_type i = 1; i < len; i++) |
5260 | 352 if (std::abs (elem (i)) < absres) |
458 | 353 { |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
354 res = elem (i); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
355 absres = std::abs (res); |
458 | 356 } |
357 | |
358 return res; | |
359 } | |
360 | |
361 Complex | |
362 ComplexRowVector::max (void) const | |
363 { | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
364 octave_idx_type len = numel (); |
458 | 365 if (len == 0) |
366 return Complex (0.0); | |
367 | |
368 Complex res = elem (0); | |
5260 | 369 double absres = std::abs (res); |
458 | 370 |
5275 | 371 for (octave_idx_type i = 1; i < len; i++) |
5260 | 372 if (std::abs (elem (i)) > absres) |
458 | 373 { |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
374 res = elem (i); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
375 absres = std::abs (res); |
458 | 376 } |
377 | |
378 return res; | |
379 } | |
380 | |
381 // i/o | |
382 | |
3504 | 383 std::ostream& |
384 operator << (std::ostream& os, const ComplexRowVector& a) | |
458 | 385 { |
386 // int field_width = os.precision () + 7; | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
387 for (octave_idx_type i = 0; i < a.numel (); i++) |
458 | 388 os << " " /* setw (field_width) */ << a.elem (i); |
389 return os; | |
390 } | |
391 | |
3504 | 392 std::istream& |
393 operator >> (std::istream& is, ComplexRowVector& a) | |
458 | 394 { |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
395 octave_idx_type len = a.numel (); |
458 | 396 |
8999
dc07bc4157b8
allow empty matrices in stream input operators
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
397 if (len > 0) |
458 | 398 { |
399 Complex tmp; | |
5275 | 400 for (octave_idx_type i = 0; i < len; i++) |
458 | 401 { |
402 is >> tmp; | |
403 if (is) | |
404 a.elem (i) = tmp; | |
405 else | |
406 break; | |
407 } | |
408 } | |
532 | 409 return is; |
458 | 410 } |
411 | |
1205 | 412 // row vector by column vector -> scalar |
413 | |
414 // row vector by column vector -> scalar | |
415 | |
416 Complex | |
417 operator * (const ComplexRowVector& v, const ColumnVector& a) | |
418 { | |
419 ComplexColumnVector tmp (a); | |
420 return v * tmp; | |
421 } | |
422 | |
423 Complex | |
424 operator * (const ComplexRowVector& v, const ComplexColumnVector& a) | |
425 { | |
5983 | 426 Complex retval (0.0, 0.0); |
427 | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
428 octave_idx_type len = v.numel (); |
2386 | 429 |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
430 octave_idx_type a_len = a.numel (); |
2386 | 431 |
432 if (len != a_len) | |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
20466
diff
changeset
|
433 err_nonconformant ("operator *", len, a_len); |
21120
499b851fbfae
Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
434 if (len != 0) |
5983 | 435 F77_FUNC (xzdotu, XZDOTU) (len, v.data (), 1, a.data (), 1, retval); |
1205 | 436 |
437 return retval; | |
438 } | |
439 | |
440 // other operations | |
441 | |
442 ComplexRowVector | |
5275 | 443 linspace (const Complex& x1, const Complex& x2, octave_idx_type n) |
1205 | 444 { |
20466
16b9ec39ff46
Return empty matrix when linspace called with 0 points (bug #45820)
Rik <rik@octave.org>
parents:
20232
diff
changeset
|
445 NoAlias<ComplexRowVector> retval; |
9653
e087d7c77ff9
improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9550
diff
changeset
|
446 |
20466
16b9ec39ff46
Return empty matrix when linspace called with 0 points (bug #45820)
Rik <rik@octave.org>
parents:
20232
diff
changeset
|
447 if (n < 1) |
16b9ec39ff46
Return empty matrix when linspace called with 0 points (bug #45820)
Rik <rik@octave.org>
parents:
20232
diff
changeset
|
448 return retval; |
16b9ec39ff46
Return empty matrix when linspace called with 0 points (bug #45820)
Rik <rik@octave.org>
parents:
20232
diff
changeset
|
449 else |
16b9ec39ff46
Return empty matrix when linspace called with 0 points (bug #45820)
Rik <rik@octave.org>
parents:
20232
diff
changeset
|
450 retval.clear (n); |
16b9ec39ff46
Return empty matrix when linspace called with 0 points (bug #45820)
Rik <rik@octave.org>
parents:
20232
diff
changeset
|
451 |
16b9ec39ff46
Return empty matrix when linspace called with 0 points (bug #45820)
Rik <rik@octave.org>
parents:
20232
diff
changeset
|
452 retval(0) = x1; |
1205 | 453 |
9653
e087d7c77ff9
improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9550
diff
changeset
|
454 Complex delta = (x2 - x1) / (n - 1.0); |
e087d7c77ff9
improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9550
diff
changeset
|
455 for (octave_idx_type i = 1; i < n-1; i++) |
9658
3429c956de6f
extend linspace & fix up liboctave rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
9653
diff
changeset
|
456 retval(i) = x1 + static_cast<double> (i)*delta; |
20466
16b9ec39ff46
Return empty matrix when linspace called with 0 points (bug #45820)
Rik <rik@octave.org>
parents:
20232
diff
changeset
|
457 |
9653
e087d7c77ff9
improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9550
diff
changeset
|
458 retval(n-1) = x2; |
1205 | 459 |
460 return retval; | |
461 } |