1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1994-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING.  If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_CColVector_h)
27 #define octave_CColVector_h 1
28 
29 #include "octave-config.h"
30 
31 #include "MArray.h"
32 #include "mx-defs.h"
33 
34 class
35 OCTAVE_API
36 ComplexColumnVector : public MArray<Complex>
37 {
38   friend class ComplexMatrix;
39   friend class ComplexRowVector;
40 
41 public:
42 
ComplexColumnVector(void)43   ComplexColumnVector (void) : MArray<Complex> (dim_vector (0, 1)) { }
44 
ComplexColumnVector(octave_idx_type n)45   explicit ComplexColumnVector (octave_idx_type n)
46     : MArray<Complex> (dim_vector (n, 1)) { }
47 
ComplexColumnVector(const dim_vector & dv)48   explicit ComplexColumnVector (const dim_vector& dv)
49     : MArray<Complex> (dv.as_column ()) { }
50 
ComplexColumnVector(octave_idx_type n,const Complex & val)51   ComplexColumnVector (octave_idx_type n, const Complex& val)
52     : MArray<Complex> (dim_vector (n, 1), val) { }
53 
ComplexColumnVector(const ComplexColumnVector & a)54   ComplexColumnVector (const ComplexColumnVector& a) : MArray<Complex> (a) { }
55 
ComplexColumnVector(const MArray<Complex> & a)56   ComplexColumnVector (const MArray<Complex>& a)
57     : MArray<Complex> (a.as_column ()) { }
58 
ComplexColumnVector(const Array<Complex> & a)59   ComplexColumnVector (const Array<Complex>& a)
60     : MArray<Complex> (a.as_column ()) { }
61 
62   explicit ComplexColumnVector (const ColumnVector& a);
63 
64   ComplexColumnVector& operator = (const ComplexColumnVector& a)
65   {
66     MArray<Complex>::operator = (a);
67     return *this;
68   }
69 
70   bool operator == (const ComplexColumnVector& a) const;
71   bool operator != (const ComplexColumnVector& a) const;
72 
73   // destructive insert/delete/reorder operations
74 
75   ComplexColumnVector& insert (const ColumnVector& a, octave_idx_type r);
76   ComplexColumnVector& insert (const ComplexColumnVector& a, octave_idx_type r);
77 
78   ComplexColumnVector& fill (double val);
79   ComplexColumnVector& fill (const Complex& val);
80   ComplexColumnVector& fill (double val,
81                              octave_idx_type r1, octave_idx_type r2);
82   ComplexColumnVector& fill (const Complex& val,
83                              octave_idx_type r1, octave_idx_type r2);
84 
85   ComplexColumnVector stack (const ColumnVector& a) const;
86   ComplexColumnVector stack (const ComplexColumnVector& a) const;
87 
88   ComplexRowVector hermitian (void) const;
89   ComplexRowVector transpose (void) const;
90 
91   friend OCTAVE_API ComplexColumnVector conj (const ComplexColumnVector& a);
92 
93   // resize is the destructive equivalent for this one
94 
95   ComplexColumnVector extract (octave_idx_type r1, octave_idx_type r2) const;
96 
97   ComplexColumnVector extract_n (octave_idx_type r1, octave_idx_type n) const;
98 
99   // column vector by column vector -> column vector operations
100 
101   ComplexColumnVector& operator += (const ColumnVector& a);
102   ComplexColumnVector& operator -= (const ColumnVector& a);
103 
104   // matrix by column vector -> column vector operations
105 
106   friend OCTAVE_API ComplexColumnVector operator * (const ComplexMatrix& a,
107                                                     const ColumnVector& b);
108 
109   friend OCTAVE_API ComplexColumnVector operator * (const ComplexMatrix& a,
110                                                     const ComplexColumnVector& b);
111 
112   // matrix by column vector -> column vector operations
113 
114   friend OCTAVE_API ComplexColumnVector operator * (const Matrix& a,
115                                                     const ComplexColumnVector& b);
116 
117   // diagonal matrix by column vector -> column vector operations
118 
119   friend OCTAVE_API ComplexColumnVector operator * (const DiagMatrix& a,
120                                                     const ComplexColumnVector& b);
121 
122   friend OCTAVE_API ComplexColumnVector operator * (const ComplexDiagMatrix& a,
123                                                     const ColumnVector& b);
124 
125   friend OCTAVE_API ComplexColumnVector operator * (const ComplexDiagMatrix& a,
126                                                     const ComplexColumnVector& b);
127 
128   // other operations
129 
130   Complex min (void) const;
131   Complex max (void) const;
132 
133   ColumnVector abs (void) const;
134 
135   // i/o
136 
137   friend OCTAVE_API std::ostream& operator << (std::ostream& os,
138                                                const ComplexColumnVector& a);
139   friend OCTAVE_API std::istream& operator >> (std::istream& is,
140                                                ComplexColumnVector& a);
141 
142   void resize (octave_idx_type n, const Complex& rfv = Complex (0))
143   {
144     Array<Complex>::resize (dim_vector (n, 1), rfv);
145   }
146 
clear(octave_idx_type n)147   void clear (octave_idx_type n)
148   { Array<Complex>::clear (n, 1); }
149 
150 };
151 
152 MARRAY_FORWARD_DEFS (MArray, ComplexColumnVector, Complex)
153 
154 #endif
155