Mercurial > hg > octave-lyh
annotate liboctave/dColVector.h @ 10396:a0b51ac0f88a
optimize accumdim with summation
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Fri, 05 Mar 2010 12:31:30 +0100 |
parents | 96ed7c629bbd |
children | 4d1fc073fbb7 |
rev | line source |
---|---|
458 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1994, 1995, 1996, 1997, 2000, 2002, 2003, 2004, 2005, |
8920 | 4 2006, 2007, 2008 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 #if !defined (octave_ColumnVector_h) | |
25 #define octave_ColumnVector_h 1 | |
26 | |
1214 | 27 #include "MArray.h" |
458 | 28 |
29 #include "mx-defs.h" | |
30 | |
3585 | 31 class |
6108 | 32 OCTAVE_API |
3585 | 33 ColumnVector : public MArray<double> |
458 | 34 { |
35 public: | |
36 | |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
37 ColumnVector (void) : MArray<double> (0, 1) { } |
3585 | 38 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
39 explicit ColumnVector (octave_idx_type n) : MArray<double> (n, 1) { } |
3585 | 40 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
41 explicit ColumnVector (const dim_vector& dv) |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
42 : MArray<double> (dv.as_column ()) { } |
9612
66970dd627f6
further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
43 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
44 ColumnVector (octave_idx_type n, double val) : MArray<double> (n, 1, val) { } |
3585 | 45 |
46 ColumnVector (const ColumnVector& a) : MArray<double> (a) { } | |
47 | |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
48 ColumnVector (const MArray<double>& a) : MArray<double> (a.as_column ()) { } |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
49 ColumnVector (const Array<double>& a) : MArray<double> (a.as_column ()) { } |
458 | 50 |
51 ColumnVector& operator = (const ColumnVector& a) | |
52 { | |
1214 | 53 MArray<double>::operator = (a); |
458 | 54 return *this; |
55 } | |
56 | |
2386 | 57 bool operator == (const ColumnVector& a) const; |
58 bool operator != (const ColumnVector& a) const; | |
458 | 59 |
1359 | 60 // destructive insert/delete/reorder operations |
458 | 61 |
5275 | 62 ColumnVector& insert (const ColumnVector& a, octave_idx_type r); |
458 | 63 |
64 ColumnVector& fill (double val); | |
5275 | 65 ColumnVector& fill (double val, octave_idx_type r1, octave_idx_type r2); |
458 | 66 |
67 ColumnVector stack (const ColumnVector& a) const; | |
68 | |
69 RowVector transpose (void) const; | |
70 | |
6108 | 71 friend OCTAVE_API ColumnVector real (const ComplexColumnVector& a); |
72 friend OCTAVE_API ColumnVector imag (const ComplexColumnVector& a); | |
1205 | 73 |
1359 | 74 // resize is the destructive equivalent for this one |
458 | 75 |
5275 | 76 ColumnVector extract (octave_idx_type r1, octave_idx_type r2) const; |
458 | 77 |
5275 | 78 ColumnVector extract_n (octave_idx_type r1, octave_idx_type n) const; |
4316 | 79 |
1359 | 80 // matrix by column vector -> column vector operations |
458 | 81 |
6108 | 82 friend OCTAVE_API ColumnVector operator * (const Matrix& a, const ColumnVector& b); |
458 | 83 |
1359 | 84 // diagonal matrix by column vector -> column vector operations |
458 | 85 |
6108 | 86 friend OCTAVE_API ColumnVector operator * (const DiagMatrix& a, const ColumnVector& b); |
458 | 87 |
1359 | 88 // other operations |
458 | 89 |
90 double min (void) const; | |
91 double max (void) const; | |
92 | |
10363
a0728e81ed25
improve diag matrix interface & implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
93 ColumnVector abs (void) const; |
a0728e81ed25
improve diag matrix interface & implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
94 |
1359 | 95 // i/o |
458 | 96 |
6108 | 97 friend OCTAVE_API std::ostream& operator << (std::ostream& os, const ColumnVector& a); |
98 friend OCTAVE_API std::istream& operator >> (std::istream& is, ColumnVector& a); | |
458 | 99 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
100 void resize (octave_idx_type n, const double& rfv = Array<double>::resize_fill_value ()) |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
101 { Array<double>::resize (n, 1, rfv); } |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
102 |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
103 void clear (octave_idx_type n) |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
104 { Array<double>::clear (n, 1); } |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
105 |
458 | 106 }; |
107 | |
5508 | 108 // Publish externally used friend functions. |
109 | |
6108 | 110 extern OCTAVE_API ColumnVector real (const ComplexColumnVector& a); |
111 extern OCTAVE_API ColumnVector imag (const ComplexColumnVector& a); | |
5508 | 112 |
3573 | 113 MARRAY_FORWARD_DEFS (MArray, ColumnVector, double) |
114 | |
458 | 115 #endif |