Mercurial > octave-nkf
annotate liboctave/dColVector.h @ 14616:13cc11418393
improve handling of default resize fill value for arrays
* Array.cc (Array<T>::resize_fill_value): Return T, not const T&.
* Array.h (Array<T>::resize_fill_value): Now virtual member function
instead of static.
(Array<T>::resize1 (octave_idx_type)): New function.
(Array<T>::resize1 (octave_idx_type, const T&)):
Eliminate default value for second arg.
(Array<T>::resize (octave_idx_type, octave_idx_type)): New function.
(Array<T>::resize (octave_idx_type, octave_idx_type, const T&)):
Eliminate default value for third arg.
(Array<T>::resize (const dim_vector&)): New function.
(Array<T>::resize (const dim_vector&, const T&)): New function.
(Array<T>::resize2 (octave_idx_type, octave_idx_type)): New function.
(Array<T>::resize2 (octave_idx_type, octave_idx_type, const T&)):
Eliminate default value for third arg.
(Array<T>::index (const idx_vector&, bool) const): New function.
(Array<T>::index (const idx_vector&, bool, const T&) const):
Eliminate default value for third arg.
(Array<T>::index (const idx_vector&, const idx_vector&, bool) const):
New function.
(Array<T>::index (const idx_vector&, const idx_vector&, bool,
const T&) const): Eliminate default value for third arg.
(Array<T>::index (const Array<idx_vector>&, bool) const):
New function.
(Array<T>::index (const Array<idx_vector>&, const T&) const):
Eliminate default value for third arg.
(Array<T>::assign (const idx_vector&, const Array<T>&)):
New function.
(Array<T>::assign (const idx_vector&, const Array<T>&, const T&)):
Eliminate default value for third arg.
(Array<T>::assign (const idx_vector&, const idx_vector&,
const Array<T>&)): New function.
(Array<T>::assign (const idx_vector&, const idx_vector&,
const Array<T>&, const T&)): Eliminate default value for third arg.
(Array<T>::assign (const Array<idx_vector>&, const Array<T>&)):
New function.
(Array<T>::assign (const Array<idx_vector>&, const Array<T>&,
const T&)): Eliminate default value for third arg.
* DiagArray2.h (DiagArray2<T>::resize (octave_idx_type,
octave_idx_type)): New function.
(DiagArray2<T>::resize (octave_idx_type, octave_idx_type, const T&)):
Eliminate default value for third arg.
* CColVector.h (ComplexColumnVector::resize): Use Complex (0) as
default value instead of Array<Complex>::resize_fill_value ().
* CMatrix.h (ComplexMatrix::resize): Use Complex (0) as
default value instead of Array<Complex>::resize_fill_value ().
(ComplexMatrix::resize_fill_value): Delete.
* CNDArray.h (ComplexNDArray::resize_fill_value): Delete.
* CRowVector.h (ComplexRowVector::resize): Use Complex (0) as default
value instead of Array<Complex>::resize_fill_value ().
* boolMatrix.h (boolMatrix::resize): Use false as default value
instead of resize_fill_value ().
(boolMatrix::resize_fill_value): Delete.
* boolNDArray.h (boolNDArray::resize_fill_value): Delete.
* chMatrix.h (charMatrix::resize): Use 0 as default value instead of
resize_fill_value.
(charMatrix::resize_fill_value): Delete.
* chNDArray.h (charNDArray::resize_fill_value): Delete.
* dColVector.h (ColumnVector::resize): Use 0 as default value instead
of Array<double>::resize_fill_value ().
* dMatrix.h (Matrix::resize): Use 0 as default value instead of
resize_fill_value ().
(Matrix::resize_fill_value): Delete.
* dNDArray.h (NDArray::resize_fill_value): Delete.
* dRowVector.h (RowVector::resize): Use 0 as default value instead of
Array<double>::resize_fill_value ().
* fCColVector.h (FloatComplexColumnVector::resize): Use FloatComplex (0)
as default value instead of Array<FloatComplex>::resize_fill_value ().
* fCMatrix.h (FloatComplexMatrix::resize): Use FloatComplex (0) as
default value instead of resize_fill_value ()).
FloatCmplexMatrix::resize_fill_value): Delete.
* fCNDArray.h (FloatComplexNDArray::resize_fill_value): Delete.
* fCRowVector.h (FloatComplexRowVector::resize): Use FloatComplex (0)
as default value instead of Array<FloatComplex>::resize_fill_value ().
* fColVector.h (FloatColumnVector::resize): Use 0 as default value
instead of Array<float>::resize_fill_value ().
* fMatrix.h (FloatMatrix::resize): Use 0 as default value instead of
resize_fill_value ().
* fMatrix.h (FloatMatrix::resize_fill_value): Delete.
* fNDArray.h (FloatNDArray::resize_fill_value): Delete.
* fRowVector.h (FloatRowVector::resize): Use 0 as default value
instead of Array<float>::resize_fill_value ().
* intNDArray.h (intNDArray<T>::resize_fill_value): Delete.
* str-vec.h (string_vector::resize): Use std::string as default value
instead of resize_fill_value ().
* Cell.cc, Cell.h (Cell::Cell, Cell::assign, Cell::index):
Use Matrix () as default value instead of resize_fill_value ().
(Cell::resize_fill_value): No longer static.
* oct-map.cc (octave_map::resize, octave_map::assign,
Octave_map::resize, Octave_map::assign): Use Matrix () as default
value instead of Cell::resize_fill_value.
* oct-obj.h (octave_value_list::resize): Use octave_value () instead
of Array<octave_value>::resize_fill_value ().
* ov-complex.cc (octave_complex::resize): Use Complex (0) for fill
value instead of ComplexNDArray::resize_fill_value ().
* ov-float.cc (octave_float_scalar::resize): Use 0 for fill value
instead of NDArray::resize_fill_value ().
* ov-flt-complex.cc (octave_float_complex_scalar::resize): Use Complex
(0) for fill value instead of ComplexNDArray::resize_fill_value ().
* ov-range.cc (octave_range::resize): Use 0 for fill value instead of
NDArray::resize_fill_value ().
* ov-scalar.cc (octave_scalar::resize): Use 0 for fill value instead
of NDArray::resize_fill_value ().
* ov-str-mat.cc (octave_char_matrix_str::resize): Use 0 for fill value
instead of charNDArray::resize_fill_value ().
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 10 May 2012 16:31:02 -0400 |
parents | 72c96de7a403 |
children |
rev | line source |
---|---|
458 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
3 Copyright (C) 1994-2012 John W. Eaton |
10521
4d1fc073fbb7
add some missing copyright stmts
Jaroslav Hajek <highegg@gmail.com>
parents:
10364
diff
changeset
|
4 Copyright (C) 2010 VZLU Prague |
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 | |
11570
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
37 ColumnVector (void) : MArray<double> (dim_vector (0, 1)) { } |
3585 | 38 |
11570
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
39 explicit ColumnVector (octave_idx_type n) |
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
40 : MArray<double> (dim_vector (n, 1)) { } |
3585 | 41 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
42 explicit ColumnVector (const dim_vector& dv) |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
43 : MArray<double> (dv.as_column ()) { } |
9612
66970dd627f6
further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
44 |
11570
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
45 ColumnVector (octave_idx_type n, double val) |
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
46 : MArray<double> (dim_vector (n, 1), val) { } |
3585 | 47 |
48 ColumnVector (const ColumnVector& a) : MArray<double> (a) { } | |
49 | |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
50 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
|
51 ColumnVector (const Array<double>& a) : MArray<double> (a.as_column ()) { } |
458 | 52 |
53 ColumnVector& operator = (const ColumnVector& a) | |
54 { | |
1214 | 55 MArray<double>::operator = (a); |
458 | 56 return *this; |
57 } | |
58 | |
2386 | 59 bool operator == (const ColumnVector& a) const; |
60 bool operator != (const ColumnVector& a) const; | |
458 | 61 |
1359 | 62 // destructive insert/delete/reorder operations |
458 | 63 |
5275 | 64 ColumnVector& insert (const ColumnVector& a, octave_idx_type r); |
458 | 65 |
66 ColumnVector& fill (double val); | |
5275 | 67 ColumnVector& fill (double val, octave_idx_type r1, octave_idx_type r2); |
458 | 68 |
69 ColumnVector stack (const ColumnVector& a) const; | |
70 | |
71 RowVector transpose (void) const; | |
72 | |
6108 | 73 friend OCTAVE_API ColumnVector real (const ComplexColumnVector& a); |
74 friend OCTAVE_API ColumnVector imag (const ComplexColumnVector& a); | |
1205 | 75 |
1359 | 76 // resize is the destructive equivalent for this one |
458 | 77 |
5275 | 78 ColumnVector extract (octave_idx_type r1, octave_idx_type r2) const; |
458 | 79 |
5275 | 80 ColumnVector extract_n (octave_idx_type r1, octave_idx_type n) const; |
4316 | 81 |
1359 | 82 // matrix by column vector -> column vector operations |
458 | 83 |
6108 | 84 friend OCTAVE_API ColumnVector operator * (const Matrix& a, const ColumnVector& b); |
458 | 85 |
1359 | 86 // diagonal matrix by column vector -> column vector operations |
458 | 87 |
6108 | 88 friend OCTAVE_API ColumnVector operator * (const DiagMatrix& a, const ColumnVector& b); |
458 | 89 |
1359 | 90 // other operations |
458 | 91 |
92 double min (void) const; | |
93 double max (void) const; | |
94 | |
10363
a0728e81ed25
improve diag matrix interface & implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
95 ColumnVector abs (void) const; |
a0728e81ed25
improve diag matrix interface & implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
96 |
1359 | 97 // i/o |
458 | 98 |
6108 | 99 friend OCTAVE_API std::ostream& operator << (std::ostream& os, const ColumnVector& a); |
100 friend OCTAVE_API std::istream& operator >> (std::istream& is, ColumnVector& a); | |
458 | 101 |
14616
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
102 void resize (octave_idx_type n, const double& rfv = 0) |
11574
a83bad07f7e3
attempt better backward compatibility for Array resize functions
John W. Eaton <jwe@octave.org>
parents:
11570
diff
changeset
|
103 { |
a83bad07f7e3
attempt better backward compatibility for Array resize functions
John W. Eaton <jwe@octave.org>
parents:
11570
diff
changeset
|
104 Array<double>::resize (dim_vector (n, 1), rfv); |
a83bad07f7e3
attempt better backward compatibility for Array resize functions
John W. Eaton <jwe@octave.org>
parents:
11570
diff
changeset
|
105 } |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
106 |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
107 void clear (octave_idx_type n) |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
108 { Array<double>::clear (n, 1); } |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
109 |
458 | 110 }; |
111 | |
5508 | 112 // Publish externally used friend functions. |
113 | |
6108 | 114 extern OCTAVE_API ColumnVector real (const ComplexColumnVector& a); |
115 extern OCTAVE_API ColumnVector imag (const ComplexColumnVector& a); | |
5508 | 116 |
3573 | 117 MARRAY_FORWARD_DEFS (MArray, ColumnVector, double) |
118 | |
458 | 119 #endif |