GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
chMatrix.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1995-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_chMatrix_h)
27 #define octave_chMatrix_h 1
28 
29 #include "octave-config.h"
30 
31 #include <string>
32 
33 #include "Array.h"
34 #include "chNDArray.h"
35 #include "mx-defs.h"
36 #include "mx-op-decl.h"
37 #include "str-vec.h"
38 
39 class
40 OCTAVE_API
41 charMatrix : public charNDArray
42 {
43  friend class ComplexMatrix;
44 
45 public:
46 
47  charMatrix (void) = default;
48 
49  charMatrix (const charMatrix& a) = default;
50 
51  charMatrix& operator = (const charMatrix& a) = default;
52 
53  ~charMatrix (void) = default;
54 
56  : charNDArray (dim_vector (r, c)) { }
57 
59  : charNDArray (dim_vector (r, c), val) { }
60 
61  charMatrix (const dim_vector& dv) : charNDArray (dv.redim (2)) { }
62 
63  charMatrix (const dim_vector& dv, char val)
64  : charNDArray (dv.redim (2), val) { }
65 
66  charMatrix (const Array<char>& a) : charNDArray (a.as_matrix ()) { }
67 
68  charMatrix (char c) : charNDArray (c) { }
69 
70  charMatrix (const char *s) : charNDArray (s) { }
71 
72  charMatrix (const std::string& s) : charNDArray (s) { }
73 
74  charMatrix (const string_vector& s, char fill_value = '\0')
75  : charNDArray (s, fill_value) { }
76 
77  bool operator == (const charMatrix& a) const;
78  bool operator != (const charMatrix& a) const;
79 
80  charMatrix transpose (void) const { return Array<char>::transpose (); }
81 
82  // destructive insert/delete/reorder operations
83 
84  charMatrix& insert (const char *s, octave_idx_type r, octave_idx_type c);
85  charMatrix& insert (const charMatrix& a,
87 
88  std::string row_as_string (octave_idx_type, bool strip_ws = false) const;
89 
90  // resize is the destructive equivalent for this one
91 
93  octave_idx_type r2, octave_idx_type c2) const;
94 
95  void resize (octave_idx_type nr, octave_idx_type nc, char rfv = 0)
96  {
97  Array<char>::resize (dim_vector (nr, nc), rfv);
98  }
99 
100 #if 0
101  // i/o
102 
103  friend std::ostream& operator << (std::ostream& os, const Matrix& a);
104  friend std::istream& operator >> (std::istream& is, Matrix& a);
105 #endif
106 };
107 
108 MS_CMP_OP_DECLS (charMatrix, char, OCTAVE_API)
109 MS_BOOL_OP_DECLS (charMatrix, char, OCTAVE_API)
110 
111 SM_CMP_OP_DECLS (char, charMatrix, OCTAVE_API)
112 SM_BOOL_OP_DECLS (char, charMatrix, OCTAVE_API)
113 
116 
117 #endif
template OCTAVE_API std::ostream & operator<<(std::ostream &, const Array< bool > &)
std::istream & operator>>(std::istream &is, SparseBoolMatrix &a)
Definition: boolSparse.cc:281
Array< T > as_matrix(void) const
Return the array as a matrix.
Definition: Array.h:401
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
Definition: Array.cc:1011
Array< T > transpose(void) const
Size of the specified dimension.
Definition: Array.cc:1599
ComplexMatrix extract(octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2) const
Definition: CMatrix.cc:683
ComplexMatrix & operator=(const ComplexMatrix &a)=default
ComplexMatrix & insert(const Matrix &a, octave_idx_type r, octave_idx_type c)
Definition: CMatrix.cc:195
Definition: dMatrix.h:42
void resize(octave_idx_type nr, octave_idx_type nc, char rfv=0)
Definition: chMatrix.h:95
charMatrix(const char *s)
Definition: chMatrix.h:70
charMatrix(const std::string &s)
Definition: chMatrix.h:72
charMatrix(char c)
Definition: chMatrix.h:68
charMatrix(void)=default
charMatrix(const Array< char > &a)
Definition: chMatrix.h:66
charMatrix(const dim_vector &dv)
Definition: chMatrix.h:61
charMatrix transpose(void) const
Definition: chMatrix.h:80
~charMatrix(void)=default
charMatrix(octave_idx_type r, octave_idx_type c)
Definition: chMatrix.h:55
charMatrix(const string_vector &s, char fill_value='\0')
Definition: chMatrix.h:74
charMatrix(const charMatrix &a)=default
charMatrix(const dim_vector &dv, char val)
Definition: chMatrix.h:63
charMatrix(octave_idx_type r, octave_idx_type c, char val)
Definition: chMatrix.h:58
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:95
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
T * r
Definition: mx-inlines.cc:773
#define SM_BOOL_OP_DECLS(S, M, API)
Definition: mx-op-decl.h:123
#define MS_CMP_OP_DECLS(M, S, API)
Definition: mx-op-decl.h:90
#define SM_CMP_OP_DECLS(S, M, API)
Definition: mx-op-decl.h:115
#define MS_BOOL_OP_DECLS(M, S, API)
Definition: mx-op-decl.h:98
#define MM_CMP_OP_DECLS(M1, M2, API)
Definition: mx-op-decl.h:140
#define MM_BOOL_OP_DECLS(M1, M2, API)
Definition: mx-op-decl.h:148