458
|
1 // -*- C++ -*- |
|
2 /* |
|
3 |
1011
|
4 Copyright (C) 1992, 1993, 1994, 1995 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 |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
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 |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
|
20 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
21 |
|
22 */ |
|
23 |
|
24 #if !defined (octave_ColumnVector_h) |
|
25 #define octave_ColumnVector_h 1 |
|
26 |
|
27 #include "Array.h" |
|
28 |
|
29 #include "mx-defs.h" |
|
30 |
|
31 extern "C++" { |
|
32 |
|
33 class ColumnVector : public Array<double> |
|
34 { |
532
|
35 friend class Matrix; |
458
|
36 friend class RowVector; |
532
|
37 friend class ComplexColumnVector; |
458
|
38 |
|
39 public: |
|
40 |
|
41 ColumnVector (void) : Array<double> () { } |
|
42 ColumnVector (int n) : Array<double> (n) { } |
|
43 ColumnVector (int n, double val) : Array<double> (n, val) { } |
|
44 ColumnVector (const Array<double>& a) : Array<double> (a) { } |
|
45 ColumnVector (const ColumnVector& a) : Array<double> (a) { } |
|
46 // ColumnVector (double a) : Array<double> (1, a) { } |
|
47 |
|
48 ColumnVector& operator = (const ColumnVector& a) |
|
49 { |
|
50 Array<double>::operator = (a); |
|
51 return *this; |
|
52 } |
|
53 |
|
54 // operator Array<double>& () const { return *this; } |
|
55 |
|
56 int operator == (const ColumnVector& a) const; |
|
57 int operator != (const ColumnVector& a) const; |
|
58 |
|
59 // destructive insert/delete/reorder operations |
|
60 |
|
61 ColumnVector& insert (const ColumnVector& a, int r); |
|
62 |
|
63 ColumnVector& fill (double val); |
|
64 ColumnVector& fill (double val, int r1, int r2); |
|
65 |
|
66 ColumnVector stack (const ColumnVector& a) const; |
|
67 |
|
68 RowVector transpose (void) const; |
|
69 |
|
70 // resize is the destructive equivalent for this one |
|
71 |
|
72 ColumnVector extract (int r1, int r2) const; |
|
73 |
|
74 // column vector by column vector -> column vector operations |
|
75 |
|
76 ColumnVector& operator += (const ColumnVector& a); |
|
77 ColumnVector& operator -= (const ColumnVector& a); |
|
78 |
|
79 // column vector by scalar -> column vector operations |
|
80 |
|
81 friend ComplexColumnVector operator + (const ColumnVector& a, |
|
82 const Complex& s); |
|
83 friend ComplexColumnVector operator - (const ColumnVector& a, |
|
84 const Complex& s); |
|
85 friend ComplexColumnVector operator * (const ColumnVector& a, |
|
86 const Complex& s); |
|
87 friend ComplexColumnVector operator / (const ColumnVector& a, |
|
88 const Complex& s); |
|
89 |
|
90 // scalar by column vector -> column vector operations |
|
91 |
|
92 friend ComplexColumnVector operator + (const Complex& s, |
|
93 const ColumnVector& a); |
|
94 friend ComplexColumnVector operator - (const Complex& s, |
|
95 const ColumnVector& a); |
|
96 friend ComplexColumnVector operator * (const Complex& s, |
|
97 const ColumnVector& a); |
|
98 friend ComplexColumnVector operator / (const Complex& s, |
|
99 const ColumnVector& a); |
|
100 |
|
101 // column vector by row vector -> matrix operations |
|
102 |
|
103 friend Matrix operator * (const ColumnVector& a, const RowVector& a); |
|
104 |
|
105 friend ComplexMatrix operator * (const ColumnVector& a, |
|
106 const ComplexRowVector& b); |
|
107 |
|
108 // column vector by column vector -> column vector operations |
|
109 |
|
110 friend ComplexColumnVector operator + (const ComplexColumnVector& a, |
|
111 const ComplexColumnVector& b); |
|
112 |
|
113 friend ComplexColumnVector operator - (const ComplexColumnVector& a, |
|
114 const ComplexColumnVector& b); |
|
115 |
|
116 friend ComplexColumnVector product (const ComplexColumnVector& a, |
|
117 const ComplexColumnVector& b); |
|
118 |
|
119 friend ComplexColumnVector quotient (const ComplexColumnVector& a, |
|
120 const ComplexColumnVector& b); |
|
121 |
|
122 // other operations |
|
123 |
|
124 friend ColumnVector map (d_d_Mapper f, const ColumnVector& a); |
|
125 void map (d_d_Mapper f); |
|
126 |
|
127 double min (void) const; |
|
128 double max (void) const; |
|
129 |
|
130 // i/o |
|
131 |
|
132 friend ostream& operator << (ostream& os, const ColumnVector& a); |
532
|
133 friend istream& operator >> (istream& is, ColumnVector& a); |
458
|
134 |
|
135 #define KLUDGE_VECTORS |
|
136 #define TYPE double |
|
137 #define KL_VEC_TYPE ColumnVector |
|
138 #include "mx-kludge.h" |
|
139 #undef KLUDGE_VECTORS |
|
140 #undef TYPE |
|
141 #undef KL_VEC_TYPE |
|
142 |
|
143 private: |
|
144 |
|
145 ColumnVector (double *d, int l) : Array<double> (d, l) { } |
|
146 }; |
|
147 |
|
148 } // extern "C++" |
|
149 |
|
150 #endif |
|
151 |
|
152 /* |
|
153 ;;; Local Variables: *** |
|
154 ;;; mode: C++ *** |
|
155 ;;; page-delimiter: "^/\\*" *** |
|
156 ;;; End: *** |
|
157 */ |