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 charMatrix(octave_idx_type r,octave_idx_type c)55 charMatrix (octave_idx_type r, octave_idx_type c) 56 : charNDArray (dim_vector (r, c)) { } 57 charMatrix(octave_idx_type r,octave_idx_type c,char val)58 charMatrix (octave_idx_type r, octave_idx_type c, char val) 59 : charNDArray (dim_vector (r, c), val) { } 60 charMatrix(const dim_vector & dv)61 charMatrix (const dim_vector& dv) : charNDArray (dv.redim (2)) { } 62 charMatrix(const dim_vector & dv,char val)63 charMatrix (const dim_vector& dv, char val) 64 : charNDArray (dv.redim (2), val) { } 65 charMatrix(const Array<char> & a)66 charMatrix (const Array<char>& a) : charNDArray (a.as_matrix ()) { } 67 charMatrix(char c)68 charMatrix (char c) : charNDArray (c) { } 69 charMatrix(const char * s)70 charMatrix (const char *s) : charNDArray (s) { } 71 charMatrix(const std::string & s)72 charMatrix (const std::string& s) : charNDArray (s) { } 73 74 charMatrix (const string_vector& s, char fill_value = '\0') charNDArray(s,fill_value)75 : charNDArray (s, fill_value) { } 76 77 bool operator == (const charMatrix& a) const; 78 bool operator != (const charMatrix& a) const; 79 transpose(void)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, 86 octave_idx_type r, octave_idx_type c); 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 92 charMatrix extract (octave_idx_type r1, octave_idx_type c1, 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 114 MM_CMP_OP_DECLS (charMatrix, charMatrix, OCTAVE_API) 115 MM_BOOL_OP_DECLS (charMatrix, charMatrix, OCTAVE_API) 116 117 #endif 118