GNU Octave  4.4.1
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-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_chMatrix_h)
25 #define octave_chMatrix_h 1
26 
27 #include "octave-config.h"
28 
29 #include <string>
30 
31 #include "Array.h"
32 #include "chNDArray.h"
33 #include "mx-defs.h"
34 #include "mx-op-decl.h"
35 #include "str-vec.h"
36 
37 class
38 OCTAVE_API
39 charMatrix : public charNDArray
40 {
41  friend class ComplexMatrix;
42 
43 public:
44 
45  charMatrix (void) : charNDArray () { }
46 
48  : charNDArray (dim_vector (r, c)) { }
49 
51  : charNDArray (dim_vector (r, c), val) { }
52 
53  charMatrix (const dim_vector& dv) : charNDArray (dv.redim (2)) { }
54 
55  charMatrix (const dim_vector& dv, char val)
56  : charNDArray (dv.redim (2), val) { }
57 
59 
60  charMatrix (const charMatrix& a) : charNDArray (a) { }
61 
62  charMatrix (char c) : charNDArray (c) { }
63 
64  charMatrix (const char *s) : charNDArray (s) { }
65 
67 
68  charMatrix (const string_vector& s, char fill_value = '\0')
69  : charNDArray (s, fill_value) { }
70 
71  bool operator == (const charMatrix& a) const;
72  bool operator != (const charMatrix& a) const;
73 
74  charMatrix transpose (void) const { return Array<char>::transpose (); }
75 
76  // destructive insert/delete/reorder operations
77 
79  charMatrix& insert (const charMatrix& a,
81 
82  std::string row_as_string (octave_idx_type, bool strip_ws = false) const;
83 
84  // resize is the destructive equivalent for this one
85 
87  octave_idx_type r2, octave_idx_type c2) const;
88 
89  void resize (octave_idx_type nr, octave_idx_type nc, char rfv = 0)
90  {
91  Array<char>::resize (dim_vector (nr, nc), rfv);
92  }
93 
94 #if 0
95  // i/o
96 
97  friend std::ostream& operator << (std::ostream& os, const Matrix& a);
98  friend std::istream& operator >> (std::istream& is, Matrix& a);
99 #endif
100 };
101 
102 MS_CMP_OP_DECLS (charMatrix, char, OCTAVE_API)
103 MS_BOOL_OP_DECLS (charMatrix, char, OCTAVE_API)
104 
105 SM_CMP_OP_DECLS (char, charMatrix, OCTAVE_API)
106 SM_BOOL_OP_DECLS (char, charMatrix, OCTAVE_API)
107 
110 
111 #endif
charMatrix(octave_idx_type r, octave_idx_type c, char val)
Definition: chMatrix.h:50
bool operator!=(const dim_vector &a, const dim_vector &b)
Definition: dim-vector.h:566
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
charMatrix(const dim_vector &dv)
Definition: chMatrix.h:53
#define SM_CMP_OP_DECLS(S, M, API)
Definition: mx-op-decl.h:114
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several though writing to the same file through several different file ids may produce unexpected results The possible values of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the you may append a you must also open the file in binary mode The parameter conversions are currently only supported for and permissions will be set to and then everything is written in a single operation This is very efficient and improves performance c
Definition: file-io.cc:587
s
Definition: file-io.cc:2729
Array< Complex > as_matrix(void) const
Return the array as a matrix.
Definition: Array.h:390
charMatrix(const charMatrix &a)
Definition: chMatrix.h:60
charMatrix(const string_vector &s, char fill_value='\0')
Definition: chMatrix.h:68
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
charMatrix(const char *s)
Definition: chMatrix.h:64
#define SM_BOOL_OP_DECLS(S, M, API)
Definition: mx-op-decl.h:122
charMatrix transpose(void) const
Definition: chMatrix.h:74
#define MM_CMP_OP_DECLS(M1, M2, API)
Definition: mx-op-decl.h:139
#define MM_BOOL_OP_DECLS(M1, M2, API)
Definition: mx-op-decl.h:147
void resize(const dim_vector &dv, const T &rfv)
Resizing (with fill).
Definition: Array.cc:1010
void resize(octave_idx_type nr, octave_idx_type nc, char rfv=0)
Definition: chMatrix.h:89
Array< T > transpose(void) const
Definition: Array.cc:1598
Definition: dMatrix.h:36
ComplexMatrix & insert(const Matrix &a, octave_idx_type r, octave_idx_type c)
Definition: CMatrix.cc:194
charMatrix(const std::string &s)
Definition: chMatrix.h:66
charMatrix(const dim_vector &dv, char val)
Definition: chMatrix.h:55
bool operator==(const dim_vector &a, const dim_vector &b)
Definition: dim-vector.h:550
charMatrix(octave_idx_type r, octave_idx_type c)
Definition: chMatrix.h:47
#define MS_CMP_OP_DECLS(M, S, API)
Definition: mx-op-decl.h:89
ComplexMatrix extract(octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2) const
Definition: CMatrix.cc:682
charMatrix(char c)
Definition: chMatrix.h:62
template OCTAVE_API std::ostream & operator<<(std::ostream &, const Array< bool > &)
#define MS_BOOL_OP_DECLS(M, S, API)
Definition: mx-op-decl.h:97
charMatrix(void)
Definition: chMatrix.h:45
charMatrix(const Array< char > &a)
Definition: chMatrix.h:58
write the output to stdout if nargout is
Definition: load-save.cc:1612
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:87
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:888
dim_vector dv
Definition: sub2ind.cc:263
octave::stream os
Definition: file-io.cc:627