Mercurial > octave
annotate liboctave/array/CColVector.cc @ 21301:40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
* mk-octave-config-h.sh, mk-opts.pl, Backend.cc, BaseControl.cc,
ButtonControl.cc, Canvas.cc, CheckBoxControl.cc, Container.cc, ContextMenu.cc,
EditControl.cc, Figure.cc, FigureWindow.cc, GLCanvas.cc, KeyMap.cc,
ListBoxControl.cc, Logger.cc, Menu.cc, MouseModeActionGroup.cc, Object.cc,
ObjectFactory.cc, ObjectProxy.cc, Panel.cc, PopupMenuControl.cc,
PushButtonControl.cc, PushTool.cc, QtHandlesUtils.cc, RadioButtonControl.cc,
SliderControl.cc, TextControl.cc, TextEdit.cc, ToggleButtonControl.cc,
ToggleTool.cc, ToolBar.cc, ToolBarButton.cc, __init_qt__.cc,
annotation-dialog.cc, gl-select.cc, module.mk, kpty.cpp, color-picker.cc,
dialog.cc, documentation-dock-widget.cc, files-dock-widget.cc,
find-files-dialog.cc, find-files-model.cc, history-dock-widget.cc,
file-editor-tab.cc, file-editor-tab.h, file-editor.cc, find-dialog.cc,
marker.cc, octave-qscintilla.cc, octave-txt-lexer.cc, main-window.cc,
octave-cmd.cc, octave-dock-widget.cc, octave-gui.cc, octave-interpreter.cc,
octave-qt-link.cc, parser.cc, webinfo.cc, resource-manager.cc,
settings-dialog.cc, shortcut-manager.cc, terminal-dock-widget.cc,
thread-manager.cc, welcome-wizard.cc, workspace-model.cc, workspace-view.cc,
build-env-features.sh, build-env.in.cc, Cell.cc, __contourc__.cc,
__dispatch__.cc, __dsearchn__.cc, __ichol__.cc, __ilu__.cc, __lin_interpn__.cc,
__pchip_deriv__.cc, __qp__.cc, balance.cc, besselj.cc, betainc.cc, bitfcns.cc,
bsxfun.cc, c-file-ptr-stream.cc, cdisplay.c, cellfun.cc, coct-hdf5-types.c,
colloc.cc, comment-list.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc,
debug.cc, defaults.cc, defun.cc, det.cc, dirfns.cc, display.cc, dlmread.cc,
dot.cc, dynamic-ld.cc, eig.cc, ellipj.cc, error.cc, errwarn.cc, event-queue.cc,
fft.cc, fft2.cc, fftn.cc, file-io.cc, filter.cc, find.cc, ft-text-renderer.cc,
gammainc.cc, gcd.cc, getgrent.cc, getpwent.cc, getrusage.cc, givens.cc,
gl-render.cc, gl2ps-print.cc, graphics.cc, gripes.cc, hash.cc, help.cc,
hess.cc, hex2num.cc, hook-fcn.cc, input.cc, inv.cc, jit-ir.cc, jit-typeinfo.cc,
jit-util.cc, kron.cc, load-path.cc, load-save.cc, lookup.cc,
ls-ascii-helper.cc, ls-hdf5.cc, ls-mat-ascii.cc, ls-mat4.cc, ls-mat5.cc,
ls-oct-binary.cc, ls-oct-text.cc, ls-utils.cc, lsode.cc, lu.cc, luinc.cc,
mappers.cc, matrix_type.cc, max.cc, mex.cc, mgorth.cc, nproc.cc,
oct-errno.in.cc, oct-fstrm.cc, oct-hdf5-types.cc, oct-hist.cc, oct-iostrm.cc,
oct-lvalue.cc, oct-map.cc, oct-prcstrm.cc, oct-procbuf.cc, oct-stream.cc,
oct-strstrm.cc, oct-tex-lexer.in.ll, oct-tex-parser.in.yy, octave-link.cc,
ordschur.cc, pager.cc, pinv.cc, pr-output.cc, procstream.cc, profiler.cc,
psi.cc, pt-jit.cc, quad.cc, quadcc.cc, qz.cc, rand.cc, rcond.cc, regexp.cc,
schur.cc, sighandlers.cc, siglist.c, sparse-xdiv.cc, sparse-xpow.cc, sparse.cc,
spparms.cc, sqrtm.cc, str2double.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc,
sylvester.cc, symtab.cc, syscalls.cc, sysdep.cc, text-renderer.cc, time.cc,
toplev.cc, tril.cc, tsearch.cc, txt-eng.cc, typecast.cc, urlwrite.cc, utils.cc,
variables.cc, xdiv.cc, xgl2ps.c, xnorm.cc, xpow.cc, zfstream.cc,
__delaunayn__.cc, __eigs__.cc, __fltk_uigetfile__.cc, __glpk__.cc,
__init_fltk__.cc, __init_gnuplot__.cc, __magick_read__.cc, __osmesa_print__.cc,
__voronoi__.cc, amd.cc, audiodevinfo.cc, audioread.cc, ccolamd.cc, chol.cc,
colamd.cc, convhulln.cc, dmperm.cc, fftw.cc, qr.cc, symbfact.cc, symrcm.cc,
mkbuiltins, mkops, ov-base-diag.cc, ov-base-int.cc, ov-base-mat.cc,
ov-base-scalar.cc, ov-base-sparse.cc, ov-base.cc, ov-bool-mat.cc,
ov-bool-sparse.cc, ov-bool.cc, ov-builtin.cc, ov-cell.cc, ov-ch-mat.cc,
ov-class.cc, ov-classdef.cc, ov-colon.cc, ov-complex.cc, ov-cs-list.cc,
ov-cx-diag.cc, ov-cx-mat.cc, ov-cx-sparse.cc, ov-dld-fcn.cc, ov-fcn-handle.cc,
ov-fcn-inline.cc, ov-fcn.cc, ov-float.cc, ov-flt-complex.cc, ov-flt-cx-diag.cc,
ov-flt-cx-mat.cc, ov-flt-re-diag.cc, ov-flt-re-mat.cc, ov-int16.cc,
ov-int32.cc, ov-int64.cc, ov-int8.cc, ov-java.cc, ov-lazy-idx.cc,
ov-mex-fcn.cc, ov-null-mat.cc, ov-oncleanup.cc, ov-perm.cc, ov-range.cc,
ov-re-diag.cc, ov-re-mat.cc, ov-re-sparse.cc, ov-scalar.cc, ov-str-mat.cc,
ov-struct.cc, ov-typeinfo.cc, ov-uint16.cc, ov-uint32.cc, ov-uint64.cc,
ov-uint8.cc, ov-usr-fcn.cc, ov.cc, ovl.cc, octave.cc, op-b-b.cc, op-b-bm.cc,
op-b-sbm.cc, op-bm-b.cc, op-bm-bm.cc, op-bm-sbm.cc, op-cdm-cdm.cc, op-cell.cc,
op-chm.cc, op-class.cc, op-cm-cm.cc, op-cm-cs.cc, op-cm-m.cc, op-cm-s.cc,
op-cm-scm.cc, op-cm-sm.cc, op-cs-cm.cc, op-cs-cs.cc, op-cs-m.cc, op-cs-s.cc,
op-cs-scm.cc, op-cs-sm.cc, op-dm-dm.cc, op-dm-scm.cc, op-dm-sm.cc,
op-dm-template.cc, op-dms-template.cc, op-double-conv.cc, op-fcdm-fcdm.cc,
op-fcdm-fdm.cc, op-fcm-fcm.cc, op-fcm-fcs.cc, op-fcm-fm.cc, op-fcm-fs.cc,
op-fcn.cc, op-fcs-fcm.cc, op-fcs-fcs.cc, op-fcs-fm.cc, op-fcs-fs.cc,
op-fdm-fdm.cc, op-float-conv.cc, op-fm-fcm.cc, op-fm-fcs.cc, op-fm-fm.cc,
op-fm-fs.cc, op-fs-fcm.cc, op-fs-fcs.cc, op-fs-fm.cc, op-fs-fs.cc,
op-i16-i16.cc, op-i32-i32.cc, op-i64-i64.cc, op-i8-i8.cc, op-int-concat.cc,
op-int-conv.cc, op-m-cm.cc, op-m-cs.cc, op-m-m.cc, op-m-s.cc, op-m-scm.cc,
op-m-sm.cc, op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc, op-pm-template.cc,
op-range.cc, op-s-cm.cc, op-s-cs.cc, op-s-m.cc, op-s-s.cc, op-s-scm.cc,
op-s-sm.cc, op-sbm-b.cc, op-sbm-bm.cc, op-sbm-sbm.cc, op-scm-cm.cc,
op-scm-cs.cc, op-scm-m.cc, op-scm-s.cc, op-scm-scm.cc, op-scm-sm.cc,
op-sm-cm.cc, op-sm-cs.cc, op-sm-m.cc, op-sm-s.cc, op-sm-scm.cc, op-sm-sm.cc,
op-str-m.cc, op-str-s.cc, op-str-str.cc, op-struct.cc, op-ui16-ui16.cc,
op-ui32-ui32.cc, op-ui64-ui64.cc, op-ui8-ui8.cc, lex.ll, oct-parse.in.yy,
pt-arg-list.cc, pt-array-list.cc, pt-assign.cc, pt-binop.cc, pt-bp.cc,
pt-cbinop.cc, pt-cell.cc, pt-check.cc, pt-classdef.cc, pt-cmd.cc, pt-colon.cc,
pt-const.cc, pt-decl.cc, pt-eval.cc, pt-except.cc, pt-exp.cc, pt-fcn-handle.cc,
pt-funcall.cc, pt-id.cc, pt-idx.cc, pt-jump.cc, pt-loop.cc, pt-mat.cc,
pt-misc.cc, pt-pr-code.cc, pt-select.cc, pt-stmt.cc, pt-unop.cc, pt.cc,
token.cc, Array-jit.cc, Array-os.cc, Array-sym.cc, Array-tc.cc, version.cc,
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, 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, 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,
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, lo-error.c, quit.cc, CollocWt.cc, DASPK.cc, DASRT.cc,
DASSL.cc, EIG.cc, LSODE.cc, ODES.cc, Quad.cc, aepbalance.cc, chol.cc,
eigs-base.cc, fEIG.cc, gepbalance.cc, hess.cc, lo-mappers.cc, lo-specfun.cc,
lu.cc, oct-convn.cc, oct-fftw.cc, oct-norm.cc, oct-rand.cc, oct-spparms.cc,
qr.cc, qrp.cc, randgamma.c, randmtzig.c, randpoisson.c, schur.cc,
sparse-chol.cc, sparse-dmsolve.cc, sparse-lu.cc, sparse-qr.cc, svd.cc,
mk-ops.awk, dir-ops.cc, file-ops.cc, file-stat.cc, lo-sysdep.cc, mach-info.cc,
oct-env.cc, oct-group.cc, oct-passwd.cc, oct-syscalls.cc, oct-time.cc,
oct-uname.cc, cmd-edit.cc, cmd-hist.cc, data-conv.cc, f2c-main.c,
glob-match.cc, kpse.cc, lo-array-errwarn.cc, lo-array-gripes.cc, lo-cutils.c,
lo-ieee.cc, lo-regexp.cc, lo-utils.cc, oct-base64.cc, oct-glob.cc,
oct-inttypes.cc, oct-locbuf.cc, oct-mutex.cc, 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, str-vec.cc, unwind-prot.cc, url-transfer.cc,
display-available.c, main-cli.cc, main-gui.cc, main.in.cc, mkoctfile.in.cc,
octave-config.in.cc:
Use '#include "config.h"' rather than <config.h>.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 18 Feb 2016 13:34:50 -0800 |
parents | f7121e111991 |
children | aba2e6293dd8 |
rev | line source |
---|---|
1993 | 1 // ColumnVector 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 |
10521
4d1fc073fbb7
add some missing copyright stmts
Jaroslav Hajek <highegg@gmail.com>
parents:
10363
diff
changeset
|
5 Copyright (C) 2010 VZLU Prague |
458 | 6 |
7 This file is part of Octave. | |
8 | |
9 Octave is free software; you can redistribute it and/or modify it | |
10 under the terms of the GNU General Public License as published by the | |
7016 | 11 Free Software Foundation; either version 3 of the License, or (at your |
12 option) any later version. | |
458 | 13 |
14 Octave is distributed in the hope that it will be useful, but WITHOUT | |
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
17 for more details. | |
18 | |
19 You should have received a copy of the GNU General Public License | |
7016 | 20 along with Octave; see the file COPYING. If not, see |
21 <http://www.gnu.org/licenses/>. | |
458 | 22 |
23 */ | |
24 | |
25 #ifdef HAVE_CONFIG_H | |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21202
diff
changeset
|
26 # include "config.h" |
458 | 27 #endif |
28 | |
3503 | 29 #include <iostream> |
458 | 30 |
4669 | 31 #include "Array-util.h" |
1847 | 32 #include "f77-fcn.h" |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
33 #include "functor.h" |
1368 | 34 #include "lo-error.h" |
458 | 35 #include "mx-base.h" |
36 #include "mx-inlines.cc" | |
1650 | 37 #include "oct-cmplx.h" |
458 | 38 |
39 // Fortran functions we call. | |
40 | |
41 extern "C" | |
42 { | |
4552 | 43 F77_RET_T |
44 F77_FUNC (zgemv, ZGEMV) (F77_CONST_CHAR_ARG_DECL, | |
11518 | 45 const octave_idx_type&, const octave_idx_type&, |
46 const Complex&, const Complex*, | |
47 const octave_idx_type&, const Complex*, | |
48 const octave_idx_type&, const Complex&, | |
49 Complex*, const octave_idx_type& | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
50 F77_CHAR_ARG_LEN_DECL); |
458 | 51 } |
52 | |
1360 | 53 // Complex Column Vector class |
458 | 54 |
55 ComplexColumnVector::ComplexColumnVector (const ColumnVector& a) | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
56 : MArray<Complex> (a) |
458 | 57 { |
58 } | |
59 | |
2386 | 60 bool |
458 | 61 ComplexColumnVector::operator == (const ComplexColumnVector& a) const |
62 { | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
63 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
|
64 if (len != a.numel ()) |
458 | 65 return 0; |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8999
diff
changeset
|
66 return mx_inline_equal (len, data (), a.data ()); |
458 | 67 } |
68 | |
2386 | 69 bool |
458 | 70 ComplexColumnVector::operator != (const ComplexColumnVector& a) const |
71 { | |
72 return !(*this == a); | |
73 } | |
74 | |
75 // destructive insert/delete/reorder operations | |
76 | |
77 ComplexColumnVector& | |
5275 | 78 ComplexColumnVector::insert (const ColumnVector& a, octave_idx_type r) |
458 | 79 { |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
80 octave_idx_type a_len = a.numel (); |
4316 | 81 |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
82 if (r < 0 || r + a_len > numel ()) |
21136
7cac4e7458f2
maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents:
21129
diff
changeset
|
83 (*current_liboctave_error_handler) ("range error for insert"); |
458 | 84 |
4316 | 85 if (a_len > 0) |
86 { | |
87 make_unique (); | |
88 | |
5275 | 89 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
|
90 xelem (r+i) = a.elem (i); |
4316 | 91 } |
458 | 92 |
93 return *this; | |
94 } | |
95 | |
96 ComplexColumnVector& | |
5275 | 97 ComplexColumnVector::insert (const ComplexColumnVector& a, octave_idx_type r) |
458 | 98 { |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
99 octave_idx_type a_len = a.numel (); |
4316 | 100 |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
101 if (r < 0 || r + a_len > numel ()) |
21136
7cac4e7458f2
maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents:
21129
diff
changeset
|
102 (*current_liboctave_error_handler) ("range error for insert"); |
458 | 103 |
4316 | 104 if (a_len > 0) |
105 { | |
106 make_unique (); | |
107 | |
5275 | 108 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
|
109 xelem (r+i) = a.elem (i); |
4316 | 110 } |
458 | 111 |
112 return *this; | |
113 } | |
114 | |
115 ComplexColumnVector& | |
116 ComplexColumnVector::fill (double val) | |
117 { | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
118 octave_idx_type len = numel (); |
4316 | 119 |
458 | 120 if (len > 0) |
4316 | 121 { |
122 make_unique (); | |
123 | |
5275 | 124 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
|
125 xelem (i) = val; |
4316 | 126 } |
127 | |
458 | 128 return *this; |
129 } | |
130 | |
131 ComplexColumnVector& | |
132 ComplexColumnVector::fill (const Complex& val) | |
133 { | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
134 octave_idx_type len = numel (); |
4316 | 135 |
458 | 136 if (len > 0) |
4316 | 137 { |
138 make_unique (); | |
139 | |
5275 | 140 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
|
141 xelem (i) = val; |
4316 | 142 } |
143 | |
144 | |
458 | 145 return *this; |
146 } | |
147 | |
148 ComplexColumnVector& | |
5275 | 149 ComplexColumnVector::fill (double val, octave_idx_type r1, octave_idx_type r2) |
458 | 150 { |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
151 octave_idx_type len = numel (); |
4316 | 152 |
458 | 153 if (r1 < 0 || r2 < 0 || r1 >= len || r2 >= len) |
21136
7cac4e7458f2
maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents:
21129
diff
changeset
|
154 (*current_liboctave_error_handler) ("range error for fill"); |
458 | 155 |
17663
7975d75f933c
Use std::swap in liboctave instead of temporary variable.
Rik <rik@octave.org>
parents:
15271
diff
changeset
|
156 if (r1 > r2) { std::swap (r1, r2); } |
458 | 157 |
4316 | 158 if (r2 >= r1) |
159 { | |
160 make_unique (); | |
161 | |
5275 | 162 for (octave_idx_type i = r1; i <= r2; i++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
163 xelem (i) = val; |
4316 | 164 } |
458 | 165 |
166 return *this; | |
167 } | |
168 | |
169 ComplexColumnVector& | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
170 ComplexColumnVector::fill (const Complex& val, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
171 octave_idx_type r1, octave_idx_type r2) |
458 | 172 { |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
173 octave_idx_type len = numel (); |
4316 | 174 |
458 | 175 if (r1 < 0 || r2 < 0 || r1 >= len || r2 >= len) |
21136
7cac4e7458f2
maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents:
21129
diff
changeset
|
176 (*current_liboctave_error_handler) ("range error for fill"); |
458 | 177 |
17663
7975d75f933c
Use std::swap in liboctave instead of temporary variable.
Rik <rik@octave.org>
parents:
15271
diff
changeset
|
178 if (r1 > r2) { std::swap (r1, r2); } |
458 | 179 |
4316 | 180 if (r2 >= r1) |
181 { | |
182 make_unique (); | |
183 | |
5275 | 184 for (octave_idx_type i = r1; i <= r2; i++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
185 xelem (i) = val; |
4316 | 186 } |
458 | 187 |
188 return *this; | |
189 } | |
190 | |
191 ComplexColumnVector | |
192 ComplexColumnVector::stack (const ColumnVector& a) const | |
193 { | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
194 octave_idx_type len = numel (); |
5275 | 195 octave_idx_type nr_insert = len; |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
196 ComplexColumnVector retval (len + a.numel ()); |
458 | 197 retval.insert (*this, 0); |
198 retval.insert (a, nr_insert); | |
199 return retval; | |
200 } | |
201 | |
202 ComplexColumnVector | |
203 ComplexColumnVector::stack (const ComplexColumnVector& a) const | |
204 { | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
205 octave_idx_type len = numel (); |
5275 | 206 octave_idx_type nr_insert = len; |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
207 ComplexColumnVector retval (len + a.numel ()); |
458 | 208 retval.insert (*this, 0); |
209 retval.insert (a, nr_insert); | |
210 return retval; | |
211 } | |
212 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
213 ComplexRowVector |
458 | 214 ComplexColumnVector::hermitian (void) const |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
215 { |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7503
diff
changeset
|
216 return MArray<Complex>::hermitian (std::conj); |
458 | 217 } |
218 | |
219 ComplexRowVector | |
220 ComplexColumnVector::transpose (void) const | |
221 { | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7503
diff
changeset
|
222 return MArray<Complex>::transpose (); |
458 | 223 } |
224 | |
10363
a0728e81ed25
improve diag matrix interface & implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
225 ColumnVector |
a0728e81ed25
improve diag matrix interface & implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
226 ComplexColumnVector::abs (void) const |
a0728e81ed25
improve diag matrix interface & implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
227 { |
a0728e81ed25
improve diag matrix interface & implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
228 return do_mx_unary_map<double, Complex, std::abs> (*this); |
a0728e81ed25
improve diag matrix interface & implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
229 } |
a0728e81ed25
improve diag matrix interface & implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
230 |
458 | 231 ComplexColumnVector |
232 conj (const ComplexColumnVector& a) | |
233 { | |
13107
353c71c76f22
maint: fix compilation problem with g++ -std=c++0x option
Júlio Hoffimann <julio.hoffimann@gmail.com>
parents:
11586
diff
changeset
|
234 return do_mx_unary_map<Complex, Complex, std::conj<double> > (a); |
458 | 235 } |
236 | |
237 // resize is the destructive equivalent for this one | |
238 | |
239 ComplexColumnVector | |
5275 | 240 ComplexColumnVector::extract (octave_idx_type r1, octave_idx_type r2) const |
458 | 241 { |
17663
7975d75f933c
Use std::swap in liboctave instead of temporary variable.
Rik <rik@octave.org>
parents:
15271
diff
changeset
|
242 if (r1 > r2) { std::swap (r1, r2); } |
458 | 243 |
5275 | 244 octave_idx_type new_r = r2 - r1 + 1; |
458 | 245 |
246 ComplexColumnVector result (new_r); | |
247 | |
5275 | 248 for (octave_idx_type i = 0; i < new_r; i++) |
458 | 249 result.elem (i) = elem (r1+i); |
250 | |
251 return result; | |
252 } | |
253 | |
4316 | 254 ComplexColumnVector |
5275 | 255 ComplexColumnVector::extract_n (octave_idx_type r1, octave_idx_type n) const |
4316 | 256 { |
257 ComplexColumnVector result (n); | |
258 | |
5275 | 259 for (octave_idx_type i = 0; i < n; i++) |
4316 | 260 result.elem (i) = elem (r1+i); |
261 | |
262 return result; | |
263 } | |
264 | |
458 | 265 // column vector by column vector -> column vector operations |
266 | |
267 ComplexColumnVector& | |
268 ComplexColumnVector::operator += (const ColumnVector& a) | |
269 { | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
270 octave_idx_type len = numel (); |
2386 | 271 |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
272 octave_idx_type a_len = a.numel (); |
2386 | 273 |
274 if (len != a_len) | |
21129
228b65504557
maint: Eliminate useless statements after err_XXX.
Rik <rik@octave.org>
parents:
21120
diff
changeset
|
275 err_nonconformant ("operator +=", len, a_len); |
458 | 276 |
277 if (len == 0) | |
278 return *this; | |
279 | |
280 Complex *d = fortran_vec (); // Ensures only one reference to my privates! | |
281 | |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8999
diff
changeset
|
282 mx_inline_add2 (len, d, a.data ()); |
458 | 283 return *this; |
284 } | |
285 | |
286 ComplexColumnVector& | |
287 ComplexColumnVector::operator -= (const ColumnVector& a) | |
288 { | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
289 octave_idx_type len = numel (); |
2386 | 290 |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
291 octave_idx_type a_len = a.numel (); |
2386 | 292 |
293 if (len != a_len) | |
21129
228b65504557
maint: Eliminate useless statements after err_XXX.
Rik <rik@octave.org>
parents:
21120
diff
changeset
|
294 err_nonconformant ("operator -=", len, a_len); |
458 | 295 |
296 if (len == 0) | |
297 return *this; | |
298 | |
299 Complex *d = fortran_vec (); // Ensures only one reference to my privates! | |
300 | |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8999
diff
changeset
|
301 mx_inline_sub2 (len, d, a.data ()); |
458 | 302 return *this; |
303 } | |
304 | |
1205 | 305 // matrix by column vector -> column vector operations |
306 | |
307 ComplexColumnVector | |
308 operator * (const ComplexMatrix& m, const ColumnVector& a) | |
309 { | |
310 ComplexColumnVector tmp (a); | |
311 return m * tmp; | |
312 } | |
313 | |
314 ComplexColumnVector | |
315 operator * (const ComplexMatrix& m, const ComplexColumnVector& a) | |
316 { | |
1947 | 317 ComplexColumnVector retval; |
318 | |
5275 | 319 octave_idx_type nr = m.rows (); |
320 octave_idx_type nc = m.cols (); | |
1947 | 321 |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
322 octave_idx_type a_len = a.numel (); |
2386 | 323 |
324 if (nc != a_len) | |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
20232
diff
changeset
|
325 err_nonconformant ("operator *", nr, nc, a_len, 1); |
21120
499b851fbfae
Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
326 |
499b851fbfae
Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
327 retval.clear (nr); |
499b851fbfae
Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
328 |
499b851fbfae
Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
329 if (nr != 0) |
458 | 330 { |
21120
499b851fbfae
Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
331 if (nc == 0) |
499b851fbfae
Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
332 retval.fill (0.0); |
499b851fbfae
Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
333 else |
9625
cbabf50315ca
optimize Matrix*ColumnVector
Jaroslav Hajek <highegg@gmail.com>
parents:
9550
diff
changeset
|
334 { |
21120
499b851fbfae
Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
335 Complex *y = retval.fortran_vec (); |
1947 | 336 |
21120
499b851fbfae
Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
337 F77_XFCN (zgemv, ZGEMV, (F77_CONST_CHAR_ARG2 ("N", 1), |
499b851fbfae
Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
338 nr, nc, 1.0, m.data (), nr, |
499b851fbfae
Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
339 a.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
|
340 F77_CHAR_ARG_LEN (1))); |
9625
cbabf50315ca
optimize Matrix*ColumnVector
Jaroslav Hajek <highegg@gmail.com>
parents:
9550
diff
changeset
|
341 } |
21120
499b851fbfae
Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
342 } |
14394
ed8c4921bf61
correctly fill result for M * v for Nx0 * 0x1 operations
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
343 |
458 | 344 |
1947 | 345 return retval; |
458 | 346 } |
347 | |
1205 | 348 // matrix by column vector -> column vector operations |
349 | |
350 ComplexColumnVector | |
351 operator * (const Matrix& m, const ComplexColumnVector& a) | |
352 { | |
353 ComplexMatrix tmp (m); | |
354 return tmp * a; | |
355 } | |
356 | |
357 // diagonal matrix by column vector -> column vector operations | |
358 | |
359 ComplexColumnVector | |
360 operator * (const DiagMatrix& m, const ComplexColumnVector& a) | |
361 { | |
5275 | 362 octave_idx_type nr = m.rows (); |
363 octave_idx_type nc = m.cols (); | |
2386 | 364 |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
365 octave_idx_type a_len = a.numel (); |
2386 | 366 |
1205 | 367 if (nc != a_len) |
21129
228b65504557
maint: Eliminate useless statements after err_XXX.
Rik <rik@octave.org>
parents:
21120
diff
changeset
|
368 err_nonconformant ("operator *", nr, nc, a_len, 1); |
1205 | 369 |
370 if (nc == 0 || nr == 0) | |
371 return ComplexColumnVector (0); | |
372 | |
373 ComplexColumnVector result (nr); | |
374 | |
5275 | 375 for (octave_idx_type i = 0; i < a_len; i++) |
1205 | 376 result.elem (i) = a.elem (i) * m.elem (i, i); |
377 | |
5275 | 378 for (octave_idx_type i = a_len; i < nr; i++) |
1205 | 379 result.elem (i) = 0.0; |
380 | |
381 return result; | |
382 } | |
383 | |
384 ComplexColumnVector | |
385 operator * (const ComplexDiagMatrix& m, const ColumnVector& a) | |
386 { | |
5275 | 387 octave_idx_type nr = m.rows (); |
388 octave_idx_type nc = m.cols (); | |
2386 | 389 |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
390 octave_idx_type a_len = a.numel (); |
2386 | 391 |
1205 | 392 if (nc != a_len) |
21129
228b65504557
maint: Eliminate useless statements after err_XXX.
Rik <rik@octave.org>
parents:
21120
diff
changeset
|
393 err_nonconformant ("operator *", nr, nc, a_len, 1); |
1205 | 394 |
395 if (nc == 0 || nr == 0) | |
396 return ComplexColumnVector (0); | |
397 | |
398 ComplexColumnVector result (nr); | |
399 | |
5275 | 400 for (octave_idx_type i = 0; i < a_len; i++) |
1205 | 401 result.elem (i) = a.elem (i) * m.elem (i, i); |
402 | |
5275 | 403 for (octave_idx_type i = a_len; i < nr; i++) |
1205 | 404 result.elem (i) = 0.0; |
405 | |
406 return result; | |
407 } | |
408 | |
409 ComplexColumnVector | |
410 operator * (const ComplexDiagMatrix& m, const ComplexColumnVector& a) | |
411 { | |
5275 | 412 octave_idx_type nr = m.rows (); |
413 octave_idx_type nc = m.cols (); | |
2386 | 414 |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
415 octave_idx_type a_len = a.numel (); |
2386 | 416 |
1205 | 417 if (nc != a_len) |
21129
228b65504557
maint: Eliminate useless statements after err_XXX.
Rik <rik@octave.org>
parents:
21120
diff
changeset
|
418 err_nonconformant ("operator *", nr, nc, a_len, 1); |
1205 | 419 |
420 if (nc == 0 || nr == 0) | |
421 return ComplexColumnVector (0); | |
422 | |
423 ComplexColumnVector result (nr); | |
424 | |
5275 | 425 for (octave_idx_type i = 0; i < a_len; i++) |
1205 | 426 result.elem (i) = a.elem (i) * m.elem (i, i); |
427 | |
5275 | 428 for (octave_idx_type i = a_len; i < nr; i++) |
1205 | 429 result.elem (i) = 0.0; |
430 | |
431 return result; | |
432 } | |
433 | |
458 | 434 // other operations |
435 | |
436 Complex | |
437 ComplexColumnVector::min (void) const | |
438 { | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
439 octave_idx_type len = numel (); |
458 | 440 if (len == 0) |
441 return 0.0; | |
442 | |
443 Complex res = elem (0); | |
5260 | 444 double absres = std::abs (res); |
458 | 445 |
5275 | 446 for (octave_idx_type i = 1; i < len; i++) |
5260 | 447 if (std::abs (elem (i)) < absres) |
458 | 448 { |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
449 res = elem (i); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
450 absres = std::abs (res); |
458 | 451 } |
452 | |
453 return res; | |
454 } | |
455 | |
456 Complex | |
457 ComplexColumnVector::max (void) const | |
458 { | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
459 octave_idx_type len = numel (); |
458 | 460 if (len == 0) |
461 return 0.0; | |
462 | |
463 Complex res = elem (0); | |
5260 | 464 double absres = std::abs (res); |
458 | 465 |
5275 | 466 for (octave_idx_type i = 1; i < len; i++) |
5260 | 467 if (std::abs (elem (i)) > absres) |
458 | 468 { |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
469 res = elem (i); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
470 absres = std::abs (res); |
458 | 471 } |
472 | |
473 return res; | |
474 } | |
475 | |
476 // i/o | |
477 | |
3504 | 478 std::ostream& |
479 operator << (std::ostream& os, const ComplexColumnVector& a) | |
458 | 480 { |
481 // 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
|
482 for (octave_idx_type i = 0; i < a.numel (); i++) |
458 | 483 os << /* setw (field_width) << */ a.elem (i) << "\n"; |
484 return os; | |
485 } | |
486 | |
3504 | 487 std::istream& |
488 operator >> (std::istream& is, ComplexColumnVector& a) | |
458 | 489 { |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
490 octave_idx_type len = a.numel (); |
458 | 491 |
8999
dc07bc4157b8
allow empty matrices in stream input operators
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
492 if (len > 0) |
458 | 493 { |
494 double tmp; | |
5275 | 495 for (octave_idx_type i = 0; i < len; i++) |
458 | 496 { |
497 is >> tmp; | |
498 if (is) | |
499 a.elem (i) = tmp; | |
500 else | |
501 break; | |
502 } | |
503 } | |
532 | 504 return is; |
458 | 505 } |