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_RowVector_h) |
|
25 #define octave_RowVector_h 1 |
|
26 |
|
27 #include "Array.h" |
|
28 |
|
29 #include "mx-defs.h" |
|
30 |
|
31 extern "C++" { |
|
32 |
|
33 class RowVector : public Array<double> |
|
34 { |
|
35 friend class ColumnVector; |
532
|
36 friend class ComplexRowVector; |
458
|
37 |
|
38 public: |
|
39 |
|
40 RowVector (void) : Array<double> () { } |
|
41 RowVector (int n) : Array<double> (n) { } |
|
42 RowVector (int n, double val) : Array<double> (n, val) { } |
|
43 RowVector (const Array<double>& a) : Array<double> (a) { } |
|
44 RowVector (const RowVector& a) : Array<double> (a) { } |
|
45 // RowVector (double a) : Array<double> (1, a) { } |
|
46 |
|
47 RowVector& operator = (const RowVector& a) |
|
48 { |
|
49 Array<double>::operator = (a); |
|
50 return *this; |
|
51 } |
|
52 |
|
53 // operator Array<double>& () const { return *this; } |
|
54 |
|
55 int operator == (const RowVector& a) const; |
|
56 int operator != (const RowVector& a) const; |
|
57 |
|
58 // destructive insert/delete/reorder operations |
|
59 |
|
60 RowVector& insert (const RowVector& a, int c); |
|
61 |
|
62 RowVector& fill (double val); |
|
63 RowVector& fill (double val, int c1, int c2); |
|
64 |
|
65 RowVector append (const RowVector& a) const; |
|
66 |
|
67 ColumnVector transpose (void) const; |
|
68 |
|
69 // resize is the destructive equivalent for this one |
|
70 |
|
71 RowVector extract (int c1, int c2) const; |
|
72 |
|
73 // row vector by row vector -> row vector operations |
|
74 |
|
75 RowVector& operator += (const RowVector& a); |
|
76 RowVector& operator -= (const RowVector& a); |
|
77 |
|
78 // row vector by scalar -> row vector operations |
|
79 |
|
80 friend ComplexRowVector operator + (const RowVector& a, const Complex& s); |
|
81 friend ComplexRowVector operator - (const RowVector& a, const Complex& s); |
|
82 friend ComplexRowVector operator * (const RowVector& a, const Complex& s); |
|
83 friend ComplexRowVector operator / (const RowVector& a, const Complex& s); |
|
84 |
|
85 // scalar by row vector -> row vector operations |
|
86 |
|
87 friend ComplexRowVector operator + (const Complex& s, const RowVector& a); |
|
88 friend ComplexRowVector operator - (const Complex& s, const RowVector& a); |
|
89 friend ComplexRowVector operator * (const Complex& s, const RowVector& a); |
|
90 friend ComplexRowVector operator / (const Complex& s, const RowVector& a); |
|
91 |
|
92 // row vector by column vector -> scalar |
|
93 |
|
94 friend double operator * (const RowVector& a, const ColumnVector& b); |
|
95 |
|
96 friend Complex operator * (const RowVector& a, const ComplexColumnVector& b); |
|
97 |
|
98 // row vector by matrix -> row vector |
|
99 |
|
100 friend RowVector operator * (const RowVector& a, const Matrix& b); |
|
101 |
|
102 friend ComplexRowVector operator * (const RowVector& a, |
|
103 const ComplexMatrix& b); |
|
104 |
|
105 // row vector by row vector -> row vector operations |
|
106 |
|
107 friend ComplexRowVector operator + (const RowVector& a, |
|
108 const ComplexRowVector& b); |
|
109 friend ComplexRowVector operator - (const RowVector& a, |
|
110 const ComplexRowVector& b); |
|
111 |
|
112 friend ComplexRowVector product (const RowVector& a, |
|
113 const ComplexRowVector& b); |
|
114 friend ComplexRowVector quotient (const RowVector& a, |
|
115 const ComplexRowVector& b); |
|
116 |
|
117 // other operations |
|
118 |
|
119 friend RowVector map (d_d_Mapper f, const RowVector& a); |
|
120 void map (d_d_Mapper f); |
|
121 |
1195
|
122 RowVector linspace (double x1, double x2, int n); |
|
123 |
458
|
124 double min (void) const; |
|
125 double max (void) const; |
|
126 |
|
127 // i/o |
|
128 |
|
129 friend ostream& operator << (ostream& os, const RowVector& a); |
532
|
130 friend istream& operator >> (istream& is, RowVector& a); |
458
|
131 |
|
132 #define KLUDGE_VECTORS |
|
133 #define TYPE double |
|
134 #define KL_VEC_TYPE RowVector |
|
135 #include "mx-kludge.h" |
|
136 #undef KLUDGE_VECTORS |
|
137 #undef TYPE |
|
138 #undef KL_VEC_TYPE |
|
139 |
|
140 private: |
|
141 |
|
142 RowVector (double *d, int l) : Array<double> (d, l) { } |
|
143 }; |
|
144 |
|
145 } // extern "C++" |
|
146 |
|
147 #endif |
|
148 |
|
149 /* |
|
150 ;;; Local Variables: *** |
|
151 ;;; mode: C++ *** |
|
152 ;;; page-delimiter: "^/\\*" *** |
|
153 ;;; End: *** |
|
154 */ |