annotate liboctave/array/DiagArray2.h @ 21139:538b57866b90

consistently use "typename" intead of "class" in template declarations * Object.h, QtHandlesUtils.cc, QtHandlesUtils.h, ToolBarButton.cc, ToolBarButton.h, Cell.h, __lin_interpn__.cc, bitfcns.cc, bsxfun.cc, cellfun.cc, data.cc, filter.cc, gcd.cc, graphics.cc, help.cc, kron.cc, lookup.cc, ls-mat5.cc, ls-oct-text.h, lu.cc, max.cc, mgorth.cc, oct-map.cc, oct-map.h, oct-stream.cc, oct-stream.h, octave-link.h, pr-output.cc, profiler.h, schur.cc, sparse-xdiv.cc, sparse-xpow.cc, sqrtm.cc, symtab.h, tril.cc, typecast.cc, variables.cc, xdiv.cc, zfstream.h, __init_fltk__.cc, __magick_read__.cc, chol.cc, qr.cc, ov-base-diag.cc, ov-base-diag.h, ov-base-int.cc, ov-base-int.h, ov-base-mat.cc, ov-base-mat.h, ov-base-scalar.cc, ov-base-scalar.h, ov-base-sparse.cc, ov-base-sparse.h, ov-base.h, ov-classdef.cc, ov-int-traits.h, ov-java.h, ov-usr-fcn.h, ov.cc, ov.h, op-dms-template.cc, oct-parse.in.yy, parse.h, pt-mat.cc, Array-b.cc, Array.cc, Array.h, CDiagMatrix.h, CMatrix.h, CNDArray.h, DiagArray2.cc, DiagArray2.h, MArray.cc, MArray.h, MDiagArray2.cc, MDiagArray2.h, MSparse.cc, MSparse.h, MatrixType.cc, Sparse.cc, Sparse.h, dDiagMatrix.h, dMatrix.h, dNDArray.h, fCDiagMatrix.h, fCMatrix.h, fCNDArray.h, fDiagMatrix.h, fMatrix.h, fNDArray.h, idx-vector.cc, idx-vector.h, intNDArray.cc, intNDArray.h, DET.h, base-aepbal.h, base-lu.cc, base-lu.h, base-qr.cc, base-qr.h, bsxfun-defs.cc, eigs-base.cc, lo-mappers.h, lo-specfun.cc, lo-specfun.h, oct-convn.cc, oct-fftw.cc, oct-norm.cc, sparse-base-chol.cc, sparse-base-chol.h, sparse-base-lu.cc, sparse-base-lu.h, sparse-dmsolve.cc, mx-inlines.cc, action-container.h, base-list.h, lo-traits.h, lo-utils.h, oct-base64.h, oct-binmap.h, oct-cmplx.h, oct-inttypes.cc, oct-inttypes.h, oct-locbuf.h, oct-refcount.h, oct-sort.cc, oct-sort.h: Use "typename" instead of "class" in template declarations.
author John W. Eaton <jwe@octave.org>
date Sun, 24 Jan 2016 13:50:04 -0500
parents 2e5c1f766ac9
children a83e7a384ee0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1993
1b57120c997b [project @ 1996-03-03 01:16:15 by jwe]
jwe
parents: 1988
diff changeset
1 // Template array classes
1988
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
2 /*
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
3
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 17769
diff changeset
4 Copyright (C) 1996-2015 John W. Eaton
11523
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 10521
diff changeset
5 Copyright (C) 2008-2009 Jaroslav Hajek
10521
4d1fc073fbb7 add some missing copyright stmts
Jaroslav Hajek <highegg@gmail.com>
parents: 10364
diff changeset
6 Copyright (C) 2010 VZLU Prague
1988
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
7
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
8 This file is part of Octave.
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
9
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
10 Octave is free software; you can redistribute it and/or modify it
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
11 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5775
diff changeset
12 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5775
diff changeset
13 option) any later version.
1988
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
14
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
15 Octave is distributed in the hope that it will be useful, but WITHOUT
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
18 for more details.
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
19
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
20 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5775
diff changeset
21 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5775
diff changeset
22 <http://www.gnu.org/licenses/>.
1988
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
23
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
24 */
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
25
20791
f7084eae3318 maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents: 20232
diff changeset
26 #if ! defined (octave_DiagArray2_h)
1988
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
27 #define octave_DiagArray2_h 1
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
28
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
29 #include <cassert>
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
30 #include <cstdlib>
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
31
4645
bd2067547b40 [project @ 2003-11-23 08:07:52 by jwe]
jwe
parents: 4513
diff changeset
32 #include "Array.h"
1988
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
33
8524
937921654627 clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents: 8375
diff changeset
34 // Array<T> is inherited privately so that some methods, like index, don't
937921654627 clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents: 8375
diff changeset
35 // produce unexpected results.
8375
e3c9102431a9 fix design problems of diag & perm matrix classes
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
36
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 21134
diff changeset
37 template <typename T>
3585
d9803711e047 [project @ 2000-02-08 04:35:39 by jwe]
jwe
parents: 2847
diff changeset
38 class
8524
937921654627 clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents: 8375
diff changeset
39 DiagArray2 : protected Array<T>
1988
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
40 {
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
41 protected:
8524
937921654627 clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents: 8375
diff changeset
42 octave_idx_type d1, d2;
1988
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
43
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
44 public:
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
45
14128
6258e5cd0f56 Use typename keyword to refer to templates
Elias Pipping <pipping@exherbo.org>
parents: 11586
diff changeset
46 using typename Array<T>::element_type;
8375
e3c9102431a9 fix design problems of diag & perm matrix classes
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
47
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
48 DiagArray2 (void)
8524
937921654627 clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents: 8375
diff changeset
49 : Array<T> (), d1 (0), d2 (0) { }
1988
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
50
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
51 DiagArray2 (octave_idx_type r, octave_idx_type c)
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
52 : Array<T> (dim_vector (std::min (r, c), 1)), d1 (r), d2 (c) { }
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4192
diff changeset
53
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
54 DiagArray2 (octave_idx_type r, octave_idx_type c, const T& val)
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
55 : Array<T> (dim_vector (std::min (r, c), 1), val), d1 (r), d2 (c) { }
1988
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
56
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
57 explicit DiagArray2 (const Array<T>& a)
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10312
diff changeset
58 : Array<T> (a.as_column ()), d1 (a.numel ()), d2 (a.numel ()) { }
1988
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
59
10363
a0728e81ed25 improve diag matrix interface & implementation
Jaroslav Hajek <highegg@gmail.com>
parents: 10362
diff changeset
60 DiagArray2 (const Array<T>& a, octave_idx_type r, octave_idx_type c);
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10358
diff changeset
61
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
62 DiagArray2 (const DiagArray2<T>& a)
8524
937921654627 clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents: 8375
diff changeset
63 : Array<T> (a), d1 (a.d1), d2 (a.d2) { }
1988
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
64
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 21134
diff changeset
65 template <typename U>
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
66 DiagArray2 (const DiagArray2<U>& a)
15428
fd5c0159b588 Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14628
diff changeset
67 : Array<T> (a.extract_diag ()), d1 (a.dim1 ()), d2 (a.dim2 ()) { }
8366
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8314
diff changeset
68
1988
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
69 ~DiagArray2 (void) { }
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
70
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
71 DiagArray2<T>& operator = (const DiagArray2<T>& a)
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
72 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
73 if (this != &a)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
74 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
75 Array<T>::operator = (a);
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
76 d1 = a.d1;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
77 d2 = a.d2;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
78 }
1988
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
79
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
80 return *this;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
81 }
1988
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
82
8524
937921654627 clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents: 8375
diff changeset
83 octave_idx_type dim1 (void) const { return d1; }
937921654627 clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents: 8375
diff changeset
84 octave_idx_type dim2 (void) const { return d2; }
8375
e3c9102431a9 fix design problems of diag & perm matrix classes
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
85
e3c9102431a9 fix design problems of diag & perm matrix classes
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
86 octave_idx_type rows (void) const { return dim1 (); }
e3c9102431a9 fix design problems of diag & perm matrix classes
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
87 octave_idx_type cols (void) const { return dim2 (); }
e3c9102431a9 fix design problems of diag & perm matrix classes
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
88 octave_idx_type columns (void) const { return dim2 (); }
e3c9102431a9 fix design problems of diag & perm matrix classes
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
89
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 19697
diff changeset
90 octave_idx_type diag_length (void) const { return Array<T>::numel (); }
8524
937921654627 clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents: 8375
diff changeset
91 // FIXME: a dangerous ambiguity?
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 19697
diff changeset
92 octave_idx_type length (void) const { return Array<T>::numel (); }
8375
e3c9102431a9 fix design problems of diag & perm matrix classes
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
93 octave_idx_type nelem (void) const { return dim1 () * dim2 (); }
e3c9102431a9 fix design problems of diag & perm matrix classes
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
94 octave_idx_type numel (void) const { return nelem (); }
e3c9102431a9 fix design problems of diag & perm matrix classes
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
95
10358
72fab01e5d68 improve some size_t queries
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
96 size_t byte_size (void) const { return Array<T>::byte_size (); }
8375
e3c9102431a9 fix design problems of diag & perm matrix classes
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
97
8524
937921654627 clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents: 8375
diff changeset
98 dim_vector dims (void) const { return dim_vector (d1, d2); }
8375
e3c9102431a9 fix design problems of diag & perm matrix classes
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
99
21134
2e5c1f766ac9 provide replacement hints for deprecated C++ functions
John W. Eaton <jwe@octave.org>
parents: 21131
diff changeset
100 OCTAVE_DEPRECATED ("use 'extract_diag' instead")
2e5c1f766ac9 provide replacement hints for deprecated C++ functions
John W. Eaton <jwe@octave.org>
parents: 21131
diff changeset
101 Array<T> diag (octave_idx_type k = 0) const;
2e5c1f766ac9 provide replacement hints for deprecated C++ functions
John W. Eaton <jwe@octave.org>
parents: 21131
diff changeset
102
15428
fd5c0159b588 Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14628
diff changeset
103 Array<T> extract_diag (octave_idx_type k = 0) const;
fd5c0159b588 Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14628
diff changeset
104 DiagArray2<T> build_diag_matrix () const
fd5c0159b588 Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14628
diff changeset
105 {
fd5c0159b588 Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14628
diff changeset
106 return DiagArray2<T> (array_value ());
fd5c0159b588 Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14628
diff changeset
107 }
8375
e3c9102431a9 fix design problems of diag & perm matrix classes
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
108
8524
937921654627 clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents: 8375
diff changeset
109 // Warning: the non-const two-index versions will silently ignore assignments
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
110 // to off-diagonal elements.
1988
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
111
8366
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8314
diff changeset
112 T elem (octave_idx_type r, octave_idx_type c) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
113 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
114 return (r == c) ? Array<T>::elem (r) : T (0);
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
115 }
8524
937921654627 clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents: 8375
diff changeset
116
937921654627 clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents: 8375
diff changeset
117 T& elem (octave_idx_type r, octave_idx_type c)
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
118 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
119 static T zero (0);
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
120 return (r == c) ? Array<T>::elem (r) : zero;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
121 }
8366
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8314
diff changeset
122
8524
937921654627 clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents: 8375
diff changeset
123 T dgelem (octave_idx_type i) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
124 { return Array<T>::elem (i); }
8524
937921654627 clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents: 8375
diff changeset
125
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
126 T& dgelem (octave_idx_type i)
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
127 { return Array<T>::elem (i); }
8524
937921654627 clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents: 8375
diff changeset
128
14628
63ae976ac2e7 preserve DiagArray2 interface for stable release series
John W. Eaton <jwe@octave.org>
parents: 14590
diff changeset
129 T checkelem (octave_idx_type r, octave_idx_type c) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
130 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
131 return check_idx (r, c) ? elem (r, c) : T (0);
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
132 }
8524
937921654627 clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents: 8375
diff changeset
133
8366
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8314
diff changeset
134 T operator () (octave_idx_type r, octave_idx_type c) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
135 {
21131
54527108599a store more --enable-FEATURE info in octave_config_info
John W. Eaton <jwe@octave.org>
parents: 21040
diff changeset
136 #if defined (ENABLE_BOUNDS_CHECK)
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
137 return checkelem (r, c);
14628
63ae976ac2e7 preserve DiagArray2 interface for stable release series
John W. Eaton <jwe@octave.org>
parents: 14590
diff changeset
138 #else
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
139 return elem (r, c);
14590
6250e1232c9c Implement proper op() indexing for diagonal matrices (bug #36368)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
140 #endif
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
141 }
14628
63ae976ac2e7 preserve DiagArray2 interface for stable release series
John W. Eaton <jwe@octave.org>
parents: 14590
diff changeset
142
63ae976ac2e7 preserve DiagArray2 interface for stable release series
John W. Eaton <jwe@octave.org>
parents: 14590
diff changeset
143 T& checkelem (octave_idx_type r, octave_idx_type c)
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
144 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
145 static T zero (0);
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
146 return check_idx (r, c) ? elem (r, c) : zero;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
147 }
14590
6250e1232c9c Implement proper op() indexing for diagonal matrices (bug #36368)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
148
6250e1232c9c Implement proper op() indexing for diagonal matrices (bug #36368)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
149 T& operator () (octave_idx_type r, octave_idx_type c)
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
150 {
21131
54527108599a store more --enable-FEATURE info in octave_config_info
John W. Eaton <jwe@octave.org>
parents: 21040
diff changeset
151 #if defined (ENABLE_BOUNDS_CHECK)
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
152 return checkelem (r, c);
14628
63ae976ac2e7 preserve DiagArray2 interface for stable release series
John W. Eaton <jwe@octave.org>
parents: 14590
diff changeset
153 #else
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
154 return elem (r, c);
8366
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8314
diff changeset
155 #endif
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
156 }
1988
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
157
8524
937921654627 clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents: 8375
diff changeset
158 // No checking.
8366
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8314
diff changeset
159
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8314
diff changeset
160 T xelem (octave_idx_type r, octave_idx_type c) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
161 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
162 return (r == c) ? Array<T>::xelem (r) : T (0);
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
163 }
1988
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
164
8524
937921654627 clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents: 8375
diff changeset
165 T& dgxelem (octave_idx_type i)
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
166 { return Array<T>::xelem (i); }
8524
937921654627 clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents: 8375
diff changeset
167
937921654627 clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents: 8375
diff changeset
168 T dgxelem (octave_idx_type i) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
169 { return Array<T>::xelem (i); }
8524
937921654627 clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents: 8375
diff changeset
170
14616
13cc11418393 improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents: 14590
diff changeset
171 void resize (octave_idx_type n, octave_idx_type m, const T& rfv);
13cc11418393 improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents: 14590
diff changeset
172 void resize (octave_idx_type n, octave_idx_type m)
13cc11418393 improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents: 14590
diff changeset
173 {
13cc11418393 improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents: 14590
diff changeset
174 resize (n, m, Array<T>::resize_fill_value ());
13cc11418393 improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents: 14590
diff changeset
175 }
1988
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
176
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
177 DiagArray2<T> transpose (void) const;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
178 DiagArray2<T> hermitian (T (*fcn) (const T&) = 0) const;
8375
e3c9102431a9 fix design problems of diag & perm matrix classes
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
179
10363
a0728e81ed25 improve diag matrix interface & implementation
Jaroslav Hajek <highegg@gmail.com>
parents: 10362
diff changeset
180 Array<T> array_value (void) const;
8524
937921654627 clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents: 8375
diff changeset
181
8375
e3c9102431a9 fix design problems of diag & perm matrix classes
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
182 const T *data (void) const { return Array<T>::data (); }
e3c9102431a9 fix design problems of diag & perm matrix classes
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
183
e3c9102431a9 fix design problems of diag & perm matrix classes
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
184 const T *fortran_vec (void) const { return Array<T>::fortran_vec (); }
e3c9102431a9 fix design problems of diag & perm matrix classes
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
185
e3c9102431a9 fix design problems of diag & perm matrix classes
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
186 T *fortran_vec (void) { return Array<T>::fortran_vec (); }
e3c9102431a9 fix design problems of diag & perm matrix classes
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
187
e3c9102431a9 fix design problems of diag & perm matrix classes
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
188 void print_info (std::ostream& os, const std::string& prefix) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
189 { Array<T>::print_info (os, prefix); }
14628
63ae976ac2e7 preserve DiagArray2 interface for stable release series
John W. Eaton <jwe@octave.org>
parents: 14590
diff changeset
190
63ae976ac2e7 preserve DiagArray2 interface for stable release series
John W. Eaton <jwe@octave.org>
parents: 14590
diff changeset
191 private:
63ae976ac2e7 preserve DiagArray2 interface for stable release series
John W. Eaton <jwe@octave.org>
parents: 14590
diff changeset
192
63ae976ac2e7 preserve DiagArray2 interface for stable release series
John W. Eaton <jwe@octave.org>
parents: 14590
diff changeset
193 bool check_idx (octave_idx_type r, octave_idx_type c) const;
1988
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
194 };
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
195
7b56630a1e05 [project @ 1996-03-02 00:33:22 by jwe]
jwe
parents:
diff changeset
196 #endif