GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
dColVector.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1994-2018 John W. Eaton
4 Copyright (C) 2010 VZLU Prague
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
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12 
13 Octave is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License 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, see
20 <https://www.gnu.org/licenses/>.
21 
22 */
23 
24 #if ! defined (octave_dColVector_h)
25 #define octave_dColVector_h 1
26 
27 #include "octave-config.h"
28 
29 #include "MArray.h"
30 #include "mx-defs.h"
31 
32 class
33 OCTAVE_API
35 {
36 public:
37 
38  ColumnVector (void) : MArray<double> (dim_vector (0, 1)) { }
39 
41  : MArray<double> (dim_vector (n, 1)) { }
42 
43  explicit ColumnVector (const dim_vector& dv)
44  : MArray<double> (dv.as_column ()) { }
45 
47  : MArray<double> (dim_vector (n, 1), val) { }
48 
50 
51  ColumnVector (const MArray<double>& a) : MArray<double> (a.as_column ()) { }
52  ColumnVector (const Array<double>& a) : MArray<double> (a.as_column ()) { }
53 
55  {
57  return *this;
58  }
59 
60  bool operator == (const ColumnVector& a) const;
61  bool operator != (const ColumnVector& a) const;
62 
63  // destructive insert/delete/reorder operations
64 
66 
67  ColumnVector& fill (double val);
68  ColumnVector& fill (double val, octave_idx_type r1, octave_idx_type r2);
69 
70  ColumnVector stack (const ColumnVector& a) const;
71 
72  RowVector transpose (void) const;
73 
74  friend OCTAVE_API ColumnVector real (const ComplexColumnVector& a);
75  friend OCTAVE_API ColumnVector imag (const ComplexColumnVector& a);
76 
77  // resize is the destructive equivalent for this one
78 
79  ColumnVector extract (octave_idx_type r1, octave_idx_type r2) const;
80 
81  ColumnVector extract_n (octave_idx_type r1, octave_idx_type n) const;
82 
83  // matrix by column vector -> column vector operations
84 
85  friend OCTAVE_API ColumnVector operator * (const Matrix& a,
86  const ColumnVector& b);
87 
88  // diagonal matrix by column vector -> column vector operations
89 
90  friend OCTAVE_API ColumnVector operator * (const DiagMatrix& a,
91  const ColumnVector& b);
92 
93  // other operations
94 
95  double min (void) const;
96  double max (void) const;
97 
98  ColumnVector abs (void) const;
99 
100  // i/o
101 
102  friend OCTAVE_API std::ostream& operator << (std::ostream& os,
103  const ColumnVector& a);
104  friend OCTAVE_API std::istream& operator >> (std::istream& is,
105  ColumnVector& a);
106 
107  void resize (octave_idx_type n, const double& rfv = 0)
108  {
109  Array<double>::resize (dim_vector (n, 1), rfv);
110  }
111 
113  { Array<double>::clear (n, 1); }
114 
115 };
116 
117 // Publish externally used friend functions.
118 
119 extern OCTAVE_API ColumnVector real (const ComplexColumnVector& a);
120 extern OCTAVE_API ColumnVector imag (const ComplexColumnVector& a);
121 
123 
124 #endif
OCTAVE_API ColumnVector real(const ComplexColumnVector &a)
Definition: dColVector.cc:135
bool operator!=(const dim_vector &a, const dim_vector &b)
Definition: dim-vector.h:566
void clear(octave_idx_type n)
Definition: dColVector.h:112
std::istream & operator>>(std::istream &is, SparseBoolMatrix &a)
Definition: boolSparse.cc:279
identity matrix If supplied two scalar respectively For allows like xample val
Definition: data.cc:4986
SparseBoolMatrix & operator=(const SparseBoolMatrix &a)
Definition: boolSparse.h:80
static void transpose(octave_idx_type N, const octave_idx_type *ridx, const octave_idx_type *cidx, octave_idx_type *ridx2, octave_idx_type *cidx2)
Definition: symrcm.cc:386
static T abs(T x)
Definition: pr-output.cc:1696
#define MARRAY_FORWARD_DEFS(B, R, T)
Definition: MArray.h:126
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
Definition: cellfun.cc:400
ColumnVector(const dim_vector &dv)
Definition: dColVector.h:43
void resize(const dim_vector &dv, const T &rfv)
Resizing (with fill).
Definition: Array.cc:1010
SparseBoolMatrix & insert(const SparseBoolMatrix &a, octave_idx_type r, octave_idx_type c)
Definition: boolSparse.cc:75
Definition: dMatrix.h:36
OCTAVE_API ColumnVector imag(const ComplexColumnVector &a)
Definition: dColVector.cc:141
bool operator==(const dim_vector &a, const dim_vector &b)
Definition: dim-vector.h:550
ColumnVector(void)
Definition: dColVector.h:38
MArray< T > & operator=(const MArray< T > &a)
Definition: MArray.h:85
charNDArray max(char d, const charNDArray &m)
Definition: chNDArray.cc:227
void clear(void)
Definition: Array.cc:86
ColumnVector(const ColumnVector &a)
Definition: dColVector.h:49
ColumnVector(const MArray< double > &a)
Definition: dColVector.h:51
ColumnVector(const Array< double > &a)
Definition: dColVector.h:52
ColumnVector(octave_idx_type n, double val)
Definition: dColVector.h:46
template OCTAVE_API std::ostream & operator<<(std::ostream &, const Array< bool > &)
b
Definition: cellfun.cc:400
write the output to stdout if nargout is
Definition: load-save.cc:1612
ColumnVector operator*(const ColumnVector &x, const double &y)
Definition: dColVector.h:122
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:87
dim_vector dv
Definition: sub2ind.cc:263
ColumnVector(octave_idx_type n)
Definition: dColVector.h:40
octave::stream os
Definition: file-io.cc:627
charNDArray min(char d, const charNDArray &m)
Definition: chNDArray.cc:204
void resize(octave_idx_type n, const double &rfv=0)
Definition: dColVector.h:107