ov-base.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 1996-2012 John W. Eaton
00004 Copyright (C) 2009-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_base_value_h)
00025 #define octave_base_value_h 1
00026 
00027 #include <cstdlib>
00028 
00029 #include <iosfwd>
00030 #include <list>
00031 #include <string>
00032 
00033 #include "Range.h"
00034 #include "data-conv.h"
00035 #include "mxarray.h"
00036 #include "mx-base.h"
00037 #include "str-vec.h"
00038 
00039 #include "error.h"
00040 #include "oct-hdf5.h"
00041 
00042 class Cell;
00043 class octave_map;
00044 class octave_scalar_map;
00045 class octave_value;
00046 class octave_value_list;
00047 class octave_stream;
00048 class octave_function;
00049 class octave_user_function;
00050 class octave_user_script;
00051 class octave_user_code;
00052 class octave_fcn_handle;
00053 class octave_fcn_inline;
00054 class octave_value_list;
00055 class octave_lvalue;
00056 
00057 class tree_walker;
00058 
00059 enum builtin_type_t
00060 {
00061   btyp_double,
00062   btyp_float,
00063   btyp_complex,
00064   btyp_float_complex,
00065   btyp_int8,
00066   btyp_int16,
00067   btyp_int32,
00068   btyp_int64,
00069   btyp_uint8,
00070   btyp_uint16,
00071   btyp_uint32,
00072   btyp_uint64,
00073   btyp_bool,
00074   btyp_char,
00075   btyp_struct,
00076   btyp_cell,
00077   btyp_func_handle,
00078   btyp_unknown,
00079   btyp_num_types = btyp_unknown
00080 };
00081 
00082 extern OCTINTERP_API std::string
00083 btyp_class_name [btyp_num_types];
00084 
00085 extern OCTINTERP_API string_vector
00086 get_builtin_classes (void);
00087 
00088 inline bool btyp_isnumeric (builtin_type_t btyp)
00089 { return btyp <= btyp_uint64; }
00090 
00091 inline bool btyp_isinteger (builtin_type_t btyp)
00092 { return btyp >= btyp_int8 && btyp <= btyp_uint64; }
00093 
00094 inline bool btyp_isfloat (builtin_type_t btyp)
00095 { return btyp <= btyp_float_complex; }
00096 
00097 inline bool btyp_isarray (builtin_type_t btyp)
00098 { return btyp <= btyp_char; }
00099 
00100 // Compute a numeric type for a possibly mixed-type operation, using these rules:
00101 // bool -> double
00102 // single + double -> single
00103 // real + complex -> complex
00104 // integer + real -> integer
00105 // uint + uint -> uint (the bigger one)
00106 // sint + sint -> sint (the bigger one)
00107 //
00108 // failing otherwise.
00109 
00110 extern OCTINTERP_API
00111 builtin_type_t btyp_mixed_numeric (builtin_type_t x, builtin_type_t y);
00112 
00113 template <class T>
00114 struct class_to_btyp
00115 {
00116   static const builtin_type_t btyp = btyp_unknown;
00117 };
00118 
00119 #define DEF_CLASS_TO_BTYP(CLASS,BTYP) \
00120 template <> \
00121 struct class_to_btyp<CLASS> \
00122 { static const builtin_type_t btyp = BTYP; }
00123 
00124 DEF_CLASS_TO_BTYP (double, btyp_double);
00125 DEF_CLASS_TO_BTYP (float, btyp_float);
00126 DEF_CLASS_TO_BTYP (Complex, btyp_complex);
00127 DEF_CLASS_TO_BTYP (FloatComplex, btyp_float_complex);
00128 DEF_CLASS_TO_BTYP (octave_int8, btyp_int8);
00129 DEF_CLASS_TO_BTYP (octave_int16, btyp_int16);
00130 DEF_CLASS_TO_BTYP (octave_int32, btyp_int32);
00131 DEF_CLASS_TO_BTYP (octave_int64, btyp_int64);
00132 DEF_CLASS_TO_BTYP (octave_uint8, btyp_uint8);
00133 DEF_CLASS_TO_BTYP (octave_uint16, btyp_uint16);
00134 DEF_CLASS_TO_BTYP (octave_uint32, btyp_uint32);
00135 DEF_CLASS_TO_BTYP (octave_uint64, btyp_uint64);
00136 DEF_CLASS_TO_BTYP (bool, btyp_bool);
00137 DEF_CLASS_TO_BTYP (char, btyp_char);
00138 
00139 // T_ID is the type id of struct objects, set by register_type().
00140 // T_NAME is the type name of struct objects.
00141 
00142 #define DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA \
00143   DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA2 (OCTAVE_EMPTY_CPP_ARG)
00144 
00145 #define DECLARE_OV_BASE_TYPEID_FUNCTIONS_AND_DATA \
00146   DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA2(virtual)
00147 
00148 #define DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA2(VIRTUAL) \
00149   public: \
00150     VIRTUAL int type_id (void) const { return t_id; } \
00151     VIRTUAL std::string type_name (void) const { return t_name; } \
00152     VIRTUAL std::string class_name (void) const { return c_name; } \
00153     static int static_type_id (void) { return t_id; } \
00154     static std::string static_type_name (void) { return t_name; } \
00155     static std::string static_class_name (void) { return c_name; } \
00156     static void register_type (void); \
00157  \
00158   private: \
00159     static int t_id; \
00160     static const std::string t_name; \
00161     static const std::string c_name;
00162 
00163 
00164 #define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c) \
00165   int t::t_id (-1); \
00166   const std::string t::t_name (n); \
00167   const std::string t::c_name (c); \
00168   void t::register_type (void) \
00169     { \
00170       static t exemplar; \
00171       octave_value v (&exemplar, true); \
00172       t_id = octave_value_typeinfo::register_type (t::t_name, t::c_name, v); \
00173     }
00174 
00175 // A base value type, so that derived types only have to redefine what
00176 // they need (if they are derived from octave_base_value instead of
00177 // octave_value).
00178 
00179 class
00180 OCTINTERP_API
00181 octave_base_value
00182 {
00183 public:
00184 
00185   typedef octave_base_value * (*type_conv_fcn) (const octave_base_value&);
00186 
00187   // type conversion, including result type information
00188   class type_conv_info
00189   {
00190   public:
00191     type_conv_info (type_conv_fcn f = 0, int t = -1) : _fcn (f), _type_id (t) { }
00192 
00193     operator type_conv_fcn (void) const { return _fcn; }
00194 
00195     octave_base_value * operator () (const octave_base_value &v) const
00196       { return (*_fcn) (v); }
00197 
00198     int type_id (void) const { return _type_id; }
00199 
00200   private:
00201     type_conv_fcn _fcn;
00202     int _type_id;
00203   };
00204 
00205   friend class octave_value;
00206 
00207   octave_base_value (void) : count (1) { }
00208 
00209   octave_base_value (const octave_base_value&) : count (1) { }
00210 
00211   virtual ~octave_base_value (void) { }
00212 
00213   // Unconditional clone. Always clones.
00214   virtual octave_base_value *
00215   clone (void) const { return new octave_base_value (*this); }
00216 
00217   // Empty clone.
00218   virtual octave_base_value *
00219   empty_clone (void) const;
00220 
00221   // Unique clone. Usually clones, but may be overriden to fake the
00222   // cloning when sharing copies is to be controlled from within an
00223   // instance (see octave_class).
00224   virtual octave_base_value *
00225   unique_clone (void) { return clone (); }
00226 
00227   virtual type_conv_info
00228   numeric_conversion_function (void) const
00229     { return type_conv_info (); }
00230 
00231   virtual type_conv_info
00232   numeric_demotion_function (void) const
00233     { return type_conv_info (); }
00234 
00235   virtual octave_value squeeze (void) const;
00236 
00237   virtual octave_value full_value (void) const;
00238 
00239   virtual octave_base_value *try_narrowing_conversion (void) { return 0; }
00240 
00241   virtual void maybe_economize (void) { }
00242 
00243   virtual Matrix size (void);
00244 
00245   virtual octave_idx_type numel (const octave_value_list&);
00246 
00247   virtual octave_value
00248   subsref (const std::string& type,
00249            const std::list<octave_value_list>& idx);
00250 
00251   virtual octave_value_list
00252   subsref (const std::string& type,
00253            const std::list<octave_value_list>& idx,
00254            int nargout);
00255 
00256   virtual octave_value
00257   subsref (const std::string& type,
00258            const std::list<octave_value_list>& idx,
00259            bool auto_add);
00260 
00261   virtual octave_value_list
00262   subsref (const std::string& type,
00263            const std::list<octave_value_list>& idx,
00264            int nargout,
00265            const std::list<octave_lvalue> *lvalue_list);
00266 
00267   virtual octave_value
00268   do_index_op (const octave_value_list& idx, bool resize_ok = false);
00269 
00270   virtual octave_value_list
00271   do_multi_index_op (int nargout, const octave_value_list& idx);
00272 
00273   virtual octave_value_list
00274   do_multi_index_op (int nargout, const octave_value_list& idx,
00275                      const std::list<octave_lvalue> *lvalue_list);
00276 
00277   virtual void assign (const std::string&, const octave_value&) { }
00278 
00279   virtual octave_value
00280   subsasgn (const std::string& type,
00281             const std::list<octave_value_list>& idx,
00282             const octave_value& rhs);
00283 
00284   virtual octave_value
00285   undef_subsasgn (const std::string& type,
00286                   const std::list<octave_value_list>& idx,
00287                   const octave_value& rhs);
00288 
00289   virtual idx_vector index_vector (void) const;
00290 
00291   virtual dim_vector dims (void) const { return dim_vector (); }
00292 
00293   octave_idx_type rows (void) const
00294     {
00295       const dim_vector dv = dims ();
00296 
00297       return dv(0);
00298     }
00299 
00300   octave_idx_type columns (void) const
00301     {
00302       const dim_vector dv = dims ();
00303 
00304       return dv(1);
00305     }
00306 
00307   virtual int ndims (void) const
00308     { return dims ().length (); }
00309 
00310   virtual octave_idx_type numel (void) const { return dims ().numel (); }
00311 
00312   virtual octave_idx_type capacity (void) const { return numel (); }
00313 
00314   virtual size_t byte_size (void) const { return 0; }
00315 
00316   virtual octave_idx_type nnz (void) const;
00317 
00318   virtual octave_idx_type nzmax (void) const;
00319 
00320   virtual octave_idx_type nfields (void) const;
00321 
00322   virtual octave_value reshape (const dim_vector&) const;
00323 
00324   virtual octave_value permute (const Array<int>& vec, bool = false) const;
00325 
00326   virtual octave_value resize (const dim_vector&, bool fill = false) const;
00327 
00328   virtual MatrixType matrix_type (void) const;
00329 
00330   virtual MatrixType matrix_type (const MatrixType& typ) const;
00331 
00332   virtual bool is_defined (void) const { return false; }
00333 
00334   bool is_empty (void) const { return numel () == 0; }
00335 
00336   virtual bool is_cell (void) const { return false; }
00337 
00338   virtual bool is_cellstr (void) const { return false; }
00339 
00340   virtual bool is_real_scalar (void) const { return false; }
00341 
00342   virtual bool is_real_matrix (void) const { return false; }
00343 
00344   virtual bool is_real_nd_array (void) const { return false; }
00345 
00346   virtual bool is_complex_scalar (void) const { return false; }
00347 
00348   virtual bool is_complex_matrix (void) const { return false; }
00349 
00350   virtual bool is_bool_scalar (void) const { return false; }
00351 
00352   virtual bool is_bool_matrix (void) const { return false; }
00353 
00354   virtual bool is_char_matrix (void) const { return false; }
00355 
00356   virtual bool is_diag_matrix (void) const { return false; }
00357 
00358   virtual bool is_perm_matrix (void) const { return false; }
00359 
00360   virtual bool is_string (void) const { return false; }
00361 
00362   virtual bool is_sq_string (void) const { return false; }
00363 
00364   virtual bool is_range (void) const { return false; }
00365 
00366   virtual bool is_map (void) const { return false; }
00367 
00368   virtual bool is_object (void) const { return false; }
00369 
00370   virtual bool is_cs_list (void) const { return false; }
00371 
00372   virtual bool is_magic_colon (void) const { return false; }
00373 
00374   virtual bool is_all_va_args (void) const { return false; }
00375 
00376   virtual octave_value all (int = 0) const;
00377 
00378   virtual octave_value any (int = 0) const;
00379 
00380   virtual builtin_type_t builtin_type (void) const { return btyp_unknown; }
00381 
00382   virtual bool is_double_type (void) const { return false; }
00383 
00384   virtual bool is_single_type (void) const { return false; }
00385 
00386   virtual bool is_float_type (void) const { return false; }
00387 
00388   virtual bool is_int8_type (void) const { return false; }
00389 
00390   virtual bool is_int16_type (void) const { return false; }
00391 
00392   virtual bool is_int32_type (void) const { return false; }
00393 
00394   virtual bool is_int64_type (void) const { return false; }
00395 
00396   virtual bool is_uint8_type (void) const { return false; }
00397 
00398   virtual bool is_uint16_type (void) const { return false; }
00399 
00400   virtual bool is_uint32_type (void) const { return false; }
00401 
00402   virtual bool is_uint64_type (void) const { return false; }
00403 
00404   virtual bool is_bool_type (void) const { return false; }
00405 
00406   virtual bool is_integer_type (void) const { return false; }
00407 
00408   virtual bool is_real_type (void) const { return false; }
00409 
00410   virtual bool is_complex_type (void) const { return false; }
00411 
00412   // Would be nice to get rid of the next four functions:
00413 
00414   virtual bool is_scalar_type (void) const { return false; }
00415 
00416   virtual bool is_matrix_type (void) const { return false; }
00417 
00418   virtual bool is_numeric_type (void) const { return false; }
00419 
00420   virtual bool is_sparse_type (void) const { return false; }
00421 
00422   virtual bool is_true (void) const { return false; }
00423 
00424   virtual bool is_null_value (void) const { return false; }
00425 
00426   virtual bool is_constant (void) const { return false; }
00427 
00428   virtual bool is_function_handle (void) const { return false; }
00429 
00430   virtual bool is_anonymous_function (void) const { return false; }
00431 
00432   virtual bool is_inline_function (void) const { return false; }
00433 
00434   virtual bool is_function (void) const { return false; }
00435 
00436   virtual bool is_user_script (void) const { return false; }
00437 
00438   virtual bool is_user_function (void) const { return false; }
00439 
00440   virtual bool is_user_code (void) const { return false; }
00441 
00442   virtual bool is_builtin_function (void) const { return false; }
00443 
00444   virtual bool is_dld_function (void) const { return false; }
00445 
00446   virtual bool is_mex_function (void) const { return false; }
00447 
00448   virtual void erase_subfunctions (void) { }
00449 
00450   virtual short int short_value (bool = false, bool = false) const;
00451 
00452   virtual unsigned short int ushort_value (bool = false, bool = false) const;
00453 
00454   virtual int int_value (bool = false, bool = false) const;
00455 
00456   virtual unsigned int uint_value (bool = false, bool = false) const;
00457 
00458   virtual int nint_value (bool = false) const;
00459 
00460   virtual long int long_value (bool = false, bool = false) const;
00461 
00462   virtual unsigned long int ulong_value (bool = false, bool = false) const;
00463 
00464   virtual double double_value (bool = false) const;
00465 
00466   virtual float float_value (bool = false) const;
00467 
00468   virtual double scalar_value (bool frc_str_conv = false) const
00469     { return double_value (frc_str_conv); }
00470 
00471   virtual float float_scalar_value (bool frc_str_conv = false) const
00472     { return float_value (frc_str_conv); }
00473 
00474   virtual Cell cell_value (void) const;
00475 
00476   virtual Matrix matrix_value (bool = false) const;
00477 
00478   virtual FloatMatrix float_matrix_value (bool = false) const;
00479 
00480   virtual NDArray array_value (bool = false) const;
00481 
00482   virtual FloatNDArray float_array_value (bool = false) const;
00483 
00484   virtual Complex complex_value (bool = false) const;
00485 
00486   virtual FloatComplex float_complex_value (bool = false) const;
00487 
00488   virtual ComplexMatrix complex_matrix_value (bool = false) const;
00489 
00490   virtual FloatComplexMatrix float_complex_matrix_value (bool = false) const;
00491 
00492   virtual ComplexNDArray complex_array_value (bool = false) const;
00493 
00494   virtual FloatComplexNDArray float_complex_array_value (bool = false) const;
00495 
00496   virtual bool bool_value (bool = false) const;
00497 
00498   virtual boolMatrix bool_matrix_value (bool = false) const;
00499 
00500   virtual boolNDArray bool_array_value (bool = false) const;
00501 
00502   virtual charMatrix char_matrix_value (bool force = false) const;
00503 
00504   virtual charNDArray char_array_value (bool = false) const;
00505 
00506   virtual SparseMatrix sparse_matrix_value (bool = false) const;
00507 
00508   virtual SparseComplexMatrix sparse_complex_matrix_value (bool = false) const;
00509 
00510   virtual SparseBoolMatrix sparse_bool_matrix_value (bool = false) const;
00511 
00512   virtual DiagMatrix diag_matrix_value (bool = false) const;
00513 
00514   virtual FloatDiagMatrix float_diag_matrix_value (bool = false) const;
00515 
00516   virtual ComplexDiagMatrix complex_diag_matrix_value (bool = false) const;
00517 
00518   virtual FloatComplexDiagMatrix float_complex_diag_matrix_value (bool = false) const;
00519 
00520   virtual PermMatrix perm_matrix_value (void) const;
00521 
00522   virtual octave_int8 int8_scalar_value (void) const;
00523 
00524   virtual octave_int16 int16_scalar_value (void) const;
00525 
00526   virtual octave_int32 int32_scalar_value (void) const;
00527 
00528   virtual octave_int64 int64_scalar_value (void) const;
00529 
00530   virtual octave_uint8 uint8_scalar_value (void) const;
00531 
00532   virtual octave_uint16 uint16_scalar_value (void) const;
00533 
00534   virtual octave_uint32 uint32_scalar_value (void) const;
00535 
00536   virtual octave_uint64 uint64_scalar_value (void) const;
00537 
00538   virtual int8NDArray int8_array_value (void) const;
00539 
00540   virtual int16NDArray int16_array_value (void) const;
00541 
00542   virtual int32NDArray int32_array_value (void) const;
00543 
00544   virtual int64NDArray int64_array_value (void) const;
00545 
00546   virtual uint8NDArray uint8_array_value (void) const;
00547 
00548   virtual uint16NDArray uint16_array_value (void) const;
00549 
00550   virtual uint32NDArray uint32_array_value (void) const;
00551 
00552   virtual uint64NDArray uint64_array_value (void) const;
00553 
00554   virtual string_vector all_strings (bool pad = false) const;
00555 
00556   virtual std::string string_value (bool force = false) const;
00557 
00558   virtual Array<std::string> cellstr_value (void) const;
00559 
00560   virtual Range range_value (void) const;
00561 
00562   virtual octave_map map_value (void) const;
00563 
00564   virtual octave_scalar_map scalar_map_value (void) const;
00565 
00566   virtual string_vector map_keys (void) const;
00567 
00568   virtual size_t nparents (void) const;
00569 
00570   virtual std::list<std::string> parent_class_name_list (void) const;
00571 
00572   virtual string_vector parent_class_names (void) const;
00573 
00574   virtual octave_base_value *find_parent_class (const std::string&)
00575     { return 0; }
00576 
00577   virtual octave_base_value *unique_parent_class (const std::string&)
00578     { return 0; }
00579 
00580   virtual octave_function *function_value (bool silent = false);
00581 
00582   virtual octave_user_function *user_function_value (bool silent = false);
00583 
00584   virtual octave_user_script *user_script_value (bool silent = false);
00585 
00586   virtual octave_user_code *user_code_value (bool silent = false);
00587 
00588   virtual octave_fcn_handle *fcn_handle_value (bool silent = false);
00589 
00590   virtual octave_fcn_inline *fcn_inline_value (bool silent = false);
00591 
00592   virtual octave_value_list list_value (void) const;
00593 
00594   virtual octave_value convert_to_str (bool pad = false, bool force = false,
00595                                        char type = '\'') const;
00596   virtual octave_value
00597   convert_to_str_internal (bool pad, bool force, char type) const;
00598 
00599   virtual void convert_to_row_or_column_vector (void);
00600 
00601   virtual bool print_as_scalar (void) const { return false; }
00602 
00603   virtual void print (std::ostream& os, bool pr_as_read_syntax = false) const;
00604 
00605   virtual void
00606   print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
00607 
00608   virtual bool
00609   print_name_tag (std::ostream& os, const std::string& name) const;
00610 
00611   virtual void
00612   print_with_name (std::ostream& output_buf, const std::string& name,
00613                    bool print_padding = true);
00614 
00615   virtual void print_info (std::ostream& os, const std::string& prefix) const;
00616 
00617   virtual bool save_ascii (std::ostream& os);
00618 
00619   virtual bool load_ascii (std::istream& is);
00620 
00621   virtual bool save_binary (std::ostream& os, bool& save_as_floats);
00622 
00623   virtual bool load_binary (std::istream& is, bool swap,
00624                             oct_mach_info::float_format fmt);
00625 
00626 #if defined (HAVE_HDF5)
00627   virtual bool
00628   save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats);
00629 
00630   virtual bool
00631   load_hdf5 (hid_t loc_id, const char *name);
00632 #endif
00633 
00634   virtual int
00635   write (octave_stream& os, int block_size,
00636          oct_data_conv::data_type output_type, int skip,
00637          oct_mach_info::float_format flt_fmt) const;
00638 
00639   virtual void *mex_get_data (void) const { return 0; }
00640 
00641   virtual octave_idx_type *mex_get_ir (void) const { return 0; }
00642 
00643   virtual octave_idx_type *mex_get_jc (void) const { return 0; }
00644 
00645   virtual mxArray *as_mxArray (void) const;
00646 
00647   virtual octave_value diag (octave_idx_type k = 0) const;
00648 
00649   virtual octave_value sort (octave_idx_type dim = 0,
00650                              sortmode mode = ASCENDING) const;
00651   virtual octave_value sort (Array<octave_idx_type> &sidx,
00652                              octave_idx_type dim = 0,
00653                              sortmode mode = ASCENDING) const;
00654 
00655   virtual sortmode is_sorted (sortmode mode = UNSORTED) const;
00656 
00657   virtual Array<octave_idx_type>
00658   sort_rows_idx (sortmode mode = ASCENDING) const;
00659 
00660   virtual sortmode is_sorted_rows (sortmode mode = UNSORTED) const;
00661 
00662   virtual void lock (void);
00663 
00664   virtual void unlock (void);
00665 
00666   virtual bool islocked (void) const { return false; }
00667 
00668   virtual void dump (std::ostream& os) const;
00669 
00670   // Standard mappers. Register new ones here.
00671   enum unary_mapper_t
00672     {
00673       umap_abs,
00674       umap_acos,
00675       umap_acosh,
00676       umap_angle,
00677       umap_arg,
00678       umap_asin,
00679       umap_asinh,
00680       umap_atan,
00681       umap_atanh,
00682       umap_cbrt,
00683       umap_ceil,
00684       umap_conj,
00685       umap_cos,
00686       umap_cosh,
00687       umap_erf,
00688       umap_erfinv,
00689       umap_erfc,
00690       umap_erfcx,
00691       umap_exp,
00692       umap_expm1,
00693       umap_finite,
00694       umap_fix,
00695       umap_floor,
00696       umap_gamma,
00697       umap_imag,
00698       umap_isinf,
00699       umap_isna,
00700       umap_isnan,
00701       umap_lgamma,
00702       umap_log,
00703       umap_log2,
00704       umap_log10,
00705       umap_log1p,
00706       umap_real,
00707       umap_round,
00708       umap_roundb,
00709       umap_signum,
00710       umap_sin,
00711       umap_sinh,
00712       umap_sqrt,
00713       umap_tan,
00714       umap_tanh,
00715       umap_xisalnum,
00716       umap_xisalpha,
00717       umap_xisascii,
00718       umap_xiscntrl,
00719       umap_xisdigit,
00720       umap_xisgraph,
00721       umap_xislower,
00722       umap_xisprint,
00723       umap_xispunct,
00724       umap_xisspace,
00725       umap_xisupper,
00726       umap_xisxdigit,
00727       umap_xtoascii,
00728       umap_xtolower,
00729       umap_xtoupper,
00730       umap_unknown,
00731       num_unary_mappers = umap_unknown
00732     };
00733 
00734   virtual octave_value map (unary_mapper_t) const;
00735 
00736   // These are fast indexing & assignment shortcuts for extracting
00737   // or inserting a single scalar from/to an array.
00738 
00739   // Extract the n-th element, aka val(n). Result is undefined if val is not an
00740   // array type or n is out of range. Never error.
00741   virtual octave_value
00742   fast_elem_extract (octave_idx_type n) const;
00743 
00744   // Assign the n-th element, aka val(n) = x. Returns false if val is not an
00745   // array type, x is not a matching scalar type, or n is out of range.
00746   // Never error.
00747   virtual bool
00748   fast_elem_insert (octave_idx_type n, const octave_value& x);
00749 
00750   // This is a helper for the above, to be overriden in scalar types.  The
00751   // whole point is to handle the insertion efficiently with just *two* VM
00752   // calls, which is basically the theoretical minimum.
00753   virtual bool
00754   fast_elem_insert_self (void *where, builtin_type_t btyp) const;
00755 
00756 protected:
00757 
00758   // This should only be called for derived types.
00759 
00760   octave_value numeric_assign (const std::string& type,
00761                                const std::list<octave_value_list>& idx,
00762                                const octave_value& rhs);
00763 
00764   void reset_indent_level (void) const
00765     { curr_print_indent_level = 0; }
00766 
00767   void increment_indent_level (void) const
00768     { curr_print_indent_level += 2; }
00769 
00770   void decrement_indent_level (void) const
00771     { curr_print_indent_level -= 2; }
00772 
00773   int current_print_indent_level (void) const
00774     { return curr_print_indent_level; }
00775 
00776   void indent (std::ostream& os) const;
00777 
00778   void newline (std::ostream& os) const;
00779 
00780   void reset (void) const;
00781 
00782   // A reference count.
00783   // NOTE: the declaration is octave_idx_type because with 64-bit indexing,
00784   // it is well possible to have more than MAX_INT copies of a single value
00785   // (think of an empty cell array with >2G elements).
00786   octave_refcount<octave_idx_type> count;
00787 
00788 private:
00789 
00790   static const char *get_umap_name (unary_mapper_t);
00791 
00792   static int curr_print_indent_level;
00793   static bool beginning_of_line;
00794 
00795   DECLARE_OV_BASE_TYPEID_FUNCTIONS_AND_DATA
00796 };
00797 
00798 // TRUE means to perform automatic sparse to real mutation if there
00799 // is memory to be saved
00800 extern OCTINTERP_API bool Vsparse_auto_mutate;
00801 
00802 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines