GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
dRowVector.h
Go to the documentation of this file.
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_dRowVector_h)
27 #define octave_dRowVector_h 1
28 
29 #include "octave-config.h"
30 
31 #include "MArray.h"
32 #include "mx-defs.h"
33 
34 class
35 OCTAVE_API
37 {
38 public:
39 
40  RowVector (void) : MArray<double> (dim_vector (1, 0)) { }
41 
43  : MArray<double> (dim_vector (1, n)) { }
44 
45  explicit RowVector (const dim_vector& dv) : MArray<double> (dv.as_row ()) { }
46 
47  RowVector (octave_idx_type n, double val)
48  : MArray<double> (dim_vector (1, n), val) { }
49 
50  RowVector (const RowVector& a) : MArray<double> (a) { }
51 
52  RowVector (const MArray<double>& a) : MArray<double> (a.as_row ()) { }
53 
54  RowVector (const Array<double>& a) : MArray<double> (a.as_row ()) { }
55 
56  RowVector& operator = (const RowVector& a)
57  {
59  return *this;
60  }
61 
62  bool operator == (const RowVector& a) const;
63  bool operator != (const RowVector& a) const;
64 
65  // destructive insert/delete/reorder operations
66 
67  RowVector& insert (const RowVector& a, octave_idx_type c);
68 
69  RowVector& fill (double val);
70  RowVector& fill (double val, octave_idx_type c1, octave_idx_type c2);
71 
72  RowVector append (const RowVector& a) const;
73 
74  ColumnVector transpose (void) const;
75 
76  friend OCTAVE_API RowVector real (const ComplexRowVector& a);
77  friend OCTAVE_API RowVector imag (const ComplexRowVector& a);
78 
79  // resize is the destructive equivalent for this one
80 
81  RowVector extract (octave_idx_type c1, octave_idx_type c2) const;
82 
83  RowVector extract_n (octave_idx_type c1, octave_idx_type n) const;
84 
85  // row vector by matrix -> row vector
86 
87  friend OCTAVE_API RowVector operator * (const RowVector& a, const Matrix& b);
88 
89  // other operations
90 
91  double min (void) const;
92  double max (void) const;
93 
94  // i/o
95 
96  friend OCTAVE_API std::ostream& operator << (std::ostream& os,
97  const RowVector& a);
98  friend OCTAVE_API std::istream& operator >> (std::istream& is, RowVector& a);
99 
100  void resize (octave_idx_type n, const double& rfv = 0)
101  {
102  Array<double>::resize (dim_vector (1, n), rfv);
103  }
104 
106  { Array<double>::clear (1, n); }
107 
108 };
109 
110 // row vector by column vector -> scalar
111 
112 double OCTAVE_API operator * (const RowVector& a, const ColumnVector& b);
113 
114 Complex OCTAVE_API operator * (const RowVector& a,
115  const ComplexColumnVector& b);
116 
117 // other operations
118 
119 OCTAVE_API RowVector linspace (double x1, double x2, octave_idx_type n);
120 
122 
123 #endif
template OCTAVE_API std::ostream & operator<<(std::ostream &, const Array< bool > &)
#define MARRAY_FORWARD_DEFS(B, R, T)
Definition: MArray.h:128
std::istream & operator>>(std::istream &is, SparseBoolMatrix &a)
Definition: boolSparse.cc:281
charNDArray max(char d, const charNDArray &m)
Definition: chNDArray.cc:230
charNDArray min(char d, const charNDArray &m)
Definition: chNDArray.cc:207
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
Definition: Array.cc:1011
void clear(void)
Definition: Array.cc:87
MArray< T > & operator=(const MArray< T > &a)
Definition: MArray.h:87
Definition: dMatrix.h:42
RowVector(const Array< double > &a)
Definition: dRowVector.h:54
RowVector(const RowVector &a)
Definition: dRowVector.h:50
RowVector(const dim_vector &dv)
Definition: dRowVector.h:45
void clear(octave_idx_type n)
Definition: dRowVector.h:105
RowVector(octave_idx_type n, double val)
Definition: dRowVector.h:47
RowVector(void)
Definition: dRowVector.h:40
RowVector(octave_idx_type n)
Definition: dRowVector.h:42
void resize(octave_idx_type n, const double &rfv=0)
Definition: dRowVector.h:100
RowVector(const MArray< double > &a)
Definition: dRowVector.h:52
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:95
ColumnVector real(const ComplexColumnVector &a)
Definition: dColVector.cc:137
ColumnVector imag(const ComplexColumnVector &a)
Definition: dColVector.cc:143
OCTAVE_API RowVector linspace(double x1, double x2, octave_idx_type n)
Definition: dRowVector.cc:271
double OCTAVE_API operator*(const RowVector &a, const ColumnVector &b)
Definition: dRowVector.cc:311
bool operator!=(const dim_vector &a, const dim_vector &b)
Definition: dim-vector.h:601
bool operator==(const dim_vector &a, const dim_vector &b)
Definition: dim-vector.h:585
octave_idx_type n
Definition: mx-inlines.cc:753
std::complex< double > Complex
Definition: oct-cmplx.h:33
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:389