chMatrix.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 1995-2012 John W. Eaton
00004 Copyright (C) 2010 VZLU Prague
00005 
00006 This file is part of Octave.
00007 
00008 Octave is free software; you can redistribute it and/or modify it
00009 under the terms of the GNU General Public License as published by the
00010 Free Software Foundation; either version 3 of the License, or (at your
00011 option) any later version.
00012 
00013 Octave is distributed in the hope that it will be useful, but WITHOUT
00014 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00015 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00016 for more details.
00017 
00018 You should have received a copy of the GNU General Public License
00019 along with Octave; see the file COPYING.  If not, see
00020 <http://www.gnu.org/licenses/>.
00021 
00022 */
00023 
00024 #if !defined (octave_chMatrix_int_h)
00025 #define octave_chMatrix_int_h 1
00026 
00027 #include <string>
00028 
00029 #include "Array.h"
00030 
00031 #include "mx-defs.h"
00032 #include "mx-op-decl.h"
00033 #include "str-vec.h"
00034 
00035 class
00036 OCTAVE_API
00037 charMatrix : public Array<char>
00038 {
00039 friend class ComplexMatrix;
00040 
00041 public:
00042 
00043   charMatrix (void) : Array<char> () { }
00044 
00045   charMatrix (octave_idx_type r, octave_idx_type c)
00046     : Array<char> (dim_vector (r, c)) { }
00047 
00048   charMatrix (octave_idx_type r, octave_idx_type c, char val)
00049     : Array<char> (dim_vector (r, c), val) { }
00050 
00051   charMatrix (const dim_vector& dv) : Array<char> (dv) { }
00052 
00053   charMatrix (const dim_vector& dv, char val) : Array<char> (dv, val) { }
00054 
00055   charMatrix (const Array<char>& a) : Array<char> (a.as_matrix ()) { }
00056 
00057   charMatrix (const charMatrix& a) : Array<char> (a) { }
00058 
00059   charMatrix (char c);
00060 
00061   charMatrix (const char *s);
00062 
00063   charMatrix (const std::string& s);
00064 
00065   charMatrix (const string_vector& s, char fill_value = '\0');
00066 
00067   charMatrix& operator = (const charMatrix& a)
00068     {
00069       Array<char>::operator = (a);
00070       return *this;
00071     }
00072 
00073   bool operator == (const charMatrix& a) const;
00074   bool operator != (const charMatrix& a) const;
00075 
00076   charMatrix transpose (void) const { return Array<char>::transpose (); }
00077 
00078   // destructive insert/delete/reorder operations
00079 
00080   charMatrix& insert (const char *s, octave_idx_type r, octave_idx_type c);
00081   charMatrix& insert (const charMatrix& a, octave_idx_type r, octave_idx_type c);
00082 
00083   std::string row_as_string (octave_idx_type, bool strip_ws = false) const;
00084 
00085   // resize is the destructive equivalent for this one
00086 
00087   charMatrix extract (octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2) const;
00088 
00089   void resize (octave_idx_type nr, octave_idx_type nc,
00090                char rfv = resize_fill_value ())
00091   {
00092     Array<char>::resize (dim_vector (nr, nc), rfv);
00093   }
00094 
00095   charMatrix diag (octave_idx_type k = 0) const;
00096 
00097   boolMatrix all (int dim = -1) const;
00098   boolMatrix any (int dim = -1) const;
00099 
00100 #if 0
00101   // i/o
00102 
00103   friend std::ostream& operator << (std::ostream& os, const Matrix& a);
00104   friend std::istream& operator >> (std::istream& is, Matrix& a);
00105 #endif
00106 
00107   static char resize_fill_value (void) { return '\0'; }
00108 
00109 };
00110 
00111 MS_CMP_OP_DECLS (charMatrix, char, OCTAVE_API)
00112 MS_BOOL_OP_DECLS (charMatrix, char, OCTAVE_API)
00113 
00114 SM_CMP_OP_DECLS (char, charMatrix, OCTAVE_API)
00115 SM_BOOL_OP_DECLS (char, charMatrix, OCTAVE_API)
00116 
00117 MM_CMP_OP_DECLS (charMatrix, charMatrix, OCTAVE_API)
00118 MM_BOOL_OP_DECLS (charMatrix, charMatrix, OCTAVE_API)
00119 
00120 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines