00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #if !defined (octave_value_h)
00025 #define octave_value_h 1
00026
00027 #include <cstdlib>
00028
00029 #include <iosfwd>
00030 #include <string>
00031 #include <list>
00032
00033 #include "Range.h"
00034 #include "data-conv.h"
00035 #include "idx-vector.h"
00036 #include "mach-info.h"
00037 #include "mxarray.h"
00038 #include "mx-base.h"
00039 #include "oct-alloc.h"
00040 #include "oct-time.h"
00041 #include "str-vec.h"
00042
00043 #include "oct-hdf5.h"
00044 #include "oct-sort.h"
00045
00046 class Cell;
00047 class Octave_map;
00048 class octave_stream;
00049 class octave_function;
00050 class octave_user_function;
00051 class octave_fcn_handle;
00052 class octave_fcn_inline;
00053 class octave_value_list;
00054 class octave_lvalue;
00055
00056 #include "ov-base.h"
00057
00058
00059
00060 class octave_value;
00061
00062 class
00063 OCTINTERP_API
00064 octave_value
00065 {
00066 public:
00067
00068 enum unary_op
00069 {
00070 op_not,
00071 op_uplus,
00072 op_uminus,
00073 op_transpose,
00074 op_hermitian,
00075 op_incr,
00076 op_decr,
00077 num_unary_ops,
00078 unknown_unary_op
00079 };
00080
00081 enum binary_op
00082 {
00083 op_add,
00084 op_sub,
00085 op_mul,
00086 op_div,
00087 op_pow,
00088 op_ldiv,
00089 op_lshift,
00090 op_rshift,
00091 op_lt,
00092 op_le,
00093 op_eq,
00094 op_ge,
00095 op_gt,
00096 op_ne,
00097 op_el_mul,
00098 op_el_div,
00099 op_el_pow,
00100 op_el_ldiv,
00101 op_el_and,
00102 op_el_or,
00103 op_struct_ref,
00104 num_binary_ops,
00105 unknown_binary_op
00106 };
00107
00108 enum compound_binary_op
00109 {
00110
00111 op_trans_mul,
00112 op_mul_trans,
00113 op_herm_mul,
00114 op_mul_herm,
00115 op_trans_ldiv,
00116 op_herm_ldiv,
00117 op_el_not_and,
00118 op_el_not_or,
00119 op_el_and_not,
00120 op_el_or_not,
00121 num_compound_binary_ops,
00122 unknown_compound_binary_op
00123 };
00124
00125 enum assign_op
00126 {
00127 op_asn_eq,
00128 op_add_eq,
00129 op_sub_eq,
00130 op_mul_eq,
00131 op_div_eq,
00132 op_ldiv_eq,
00133 op_pow_eq,
00134 op_lshift_eq,
00135 op_rshift_eq,
00136 op_el_mul_eq,
00137 op_el_div_eq,
00138 op_el_ldiv_eq,
00139 op_el_pow_eq,
00140 op_el_and_eq,
00141 op_el_or_eq,
00142 num_assign_ops,
00143 unknown_assign_op
00144 };
00145
00146 static assign_op binary_op_to_assign_op (binary_op);
00147
00148 static std::string unary_op_as_string (unary_op);
00149 static std::string unary_op_fcn_name (unary_op);
00150
00151 static std::string binary_op_as_string (binary_op);
00152 static std::string binary_op_fcn_name (binary_op);
00153
00154 static std::string binary_op_fcn_name (compound_binary_op);
00155
00156 static std::string assign_op_as_string (assign_op);
00157
00158 static octave_value empty_conv (const std::string& type,
00159 const octave_value& rhs = octave_value ());
00160
00161 enum magic_colon { magic_colon_t };
00162
00163 octave_value (void)
00164 {
00165 static octave_base_value nil_rep;
00166 rep = &nil_rep;
00167 rep->count++;
00168 }
00169
00170 octave_value (short int i);
00171 octave_value (unsigned short int i);
00172 octave_value (int i);
00173 octave_value (unsigned int i);
00174 octave_value (long int i);
00175 octave_value (unsigned long int i);
00176
00177
00178
00179
00180
00181
00182
00183 #if defined (HAVE_LONG_LONG_INT)
00184 octave_value (long long int i);
00185 #endif
00186 #if defined (HAVE_UNSIGNED_LONG_LONG_INT)
00187 octave_value (unsigned long long int i);
00188 #endif
00189
00190 octave_value (octave_time t);
00191 octave_value (double d);
00192 octave_value (float d);
00193 octave_value (const Array<octave_value>& a, bool is_cs_list = false);
00194 octave_value (const Cell& c, bool is_cs_list = false);
00195 octave_value (const Matrix& m, const MatrixType& t = MatrixType());
00196 octave_value (const FloatMatrix& m, const MatrixType& t = MatrixType());
00197 octave_value (const NDArray& nda);
00198 octave_value (const FloatNDArray& nda);
00199 octave_value (const Array<double>& m);
00200 octave_value (const Array<float>& m);
00201 octave_value (const DiagMatrix& d);
00202 octave_value (const FloatDiagMatrix& d);
00203 octave_value (const RowVector& v);
00204 octave_value (const FloatRowVector& v);
00205 octave_value (const ColumnVector& v);
00206 octave_value (const FloatColumnVector& v);
00207 octave_value (const Complex& C);
00208 octave_value (const FloatComplex& C);
00209 octave_value (const ComplexMatrix& m, const MatrixType& t = MatrixType());
00210 octave_value (const FloatComplexMatrix& m, const MatrixType& t = MatrixType());
00211 octave_value (const ComplexNDArray& cnda);
00212 octave_value (const FloatComplexNDArray& cnda);
00213 octave_value (const Array<Complex>& m);
00214 octave_value (const Array<FloatComplex>& m);
00215 octave_value (const ComplexDiagMatrix& d);
00216 octave_value (const FloatComplexDiagMatrix& d);
00217 octave_value (const ComplexRowVector& v);
00218 octave_value (const FloatComplexRowVector& v);
00219 octave_value (const ComplexColumnVector& v);
00220 octave_value (const FloatComplexColumnVector& v);
00221 octave_value (const PermMatrix& p);
00222 octave_value (bool b);
00223 octave_value (const boolMatrix& bm, const MatrixType& t = MatrixType());
00224 octave_value (const boolNDArray& bnda);
00225 octave_value (const Array<bool>& bnda);
00226 octave_value (char c, char type = '\'');
00227 octave_value (const char *s, char type = '\'');
00228 octave_value (const std::string& s, char type = '\'');
00229 octave_value (const string_vector& s, char type = '\'');
00230 octave_value (const charMatrix& chm, char type = '\'');
00231 octave_value (const charNDArray& chnda, char type = '\'');
00232 octave_value (const Array<char>& chnda, char type = '\'');
00233 octave_value (const charMatrix& chm, bool is_string,
00234 char type = '\'') GCC_ATTR_DEPRECATED;
00235 octave_value (const charNDArray& chnda, bool is_string,
00236 char type = '\'') GCC_ATTR_DEPRECATED;
00237 octave_value (const Array<char>& chnda, bool is_string,
00238 char type = '\'') GCC_ATTR_DEPRECATED;
00239 octave_value (const SparseMatrix& m, const MatrixType& t = MatrixType ());
00240 octave_value (const Sparse<double>& m, const MatrixType& t = MatrixType ());
00241 octave_value (const SparseComplexMatrix& m,
00242 const MatrixType& t = MatrixType ());
00243 octave_value (const Sparse<Complex>& m, const MatrixType& t = MatrixType ());
00244 octave_value (const SparseBoolMatrix& bm,
00245 const MatrixType& t = MatrixType ());
00246 octave_value (const Sparse<bool>& m, const MatrixType& t = MatrixType ());
00247 octave_value (const octave_int8& i);
00248 octave_value (const octave_int16& i);
00249 octave_value (const octave_int32& i);
00250 octave_value (const octave_int64& i);
00251 octave_value (const octave_uint8& i);
00252 octave_value (const octave_uint16& i);
00253 octave_value (const octave_uint32& i);
00254 octave_value (const octave_uint64& i);
00255 octave_value (const int8NDArray& inda);
00256 octave_value (const Array<octave_int8>& inda);
00257 octave_value (const int16NDArray& inda);
00258 octave_value (const Array<octave_int16>& inda);
00259 octave_value (const int32NDArray& inda);
00260 octave_value (const Array<octave_int32>& inda);
00261 octave_value (const int64NDArray& inda);
00262 octave_value (const Array<octave_int64>& inda);
00263 octave_value (const uint8NDArray& inda);
00264 octave_value (const Array<octave_uint8>& inda);
00265 octave_value (const uint16NDArray& inda);
00266 octave_value (const Array<octave_uint16>& inda);
00267 octave_value (const uint32NDArray& inda);
00268 octave_value (const Array<octave_uint32>& inda);
00269 octave_value (const uint64NDArray& inda);
00270 octave_value (const Array<octave_uint64>& inda);
00271 octave_value (const Array<octave_idx_type>& inda,
00272 bool zero_based = false, bool cache_index = false);
00273 octave_value (const Array<std::string>& cellstr);
00274 octave_value (const idx_vector& idx);
00275 octave_value (double base, double limit, double inc);
00276 octave_value (const Range& r);
00277 octave_value (const Octave_map& m);
00278 octave_value (const Octave_map& m, const std::string& id);
00279 octave_value (const octave_value_list& m, bool is_cs_list = false);
00280 octave_value (octave_value::magic_colon);
00281
00282 octave_value (octave_base_value *new_rep, bool borrow = false);
00283 octave_value (octave_base_value *new_rep, int xcount) GCC_ATTR_DEPRECATED;
00284
00285
00286
00287 octave_value (const octave_value& a)
00288 {
00289 rep = a.rep;
00290 rep->count++;
00291 }
00292
00293
00294
00295 octave_base_value *clone (void) const;
00296
00297 octave_base_value *empty_clone (void) const
00298 { return rep->empty_clone (); }
00299
00300
00301
00302
00303 ~octave_value (void)
00304 {
00305 if (--rep->count == 0)
00306 delete rep;
00307 }
00308
00309 void make_unique (void)
00310 {
00311 if (rep->count > 1)
00312 {
00313 --rep->count;
00314 rep = rep->unique_clone ();
00315 }
00316 }
00317
00318
00319
00320
00321 void make_unique (int obsolete_copies)
00322 {
00323 if (rep->count > obsolete_copies + 1)
00324 {
00325 --rep->count;
00326 rep = rep->unique_clone ();
00327 }
00328 }
00329
00330
00331
00332 octave_value& operator = (const octave_value& a)
00333 {
00334 if (rep != a.rep)
00335 {
00336 if (--rep->count == 0)
00337 delete rep;
00338
00339 rep = a.rep;
00340 rep->count++;
00341 }
00342
00343 return *this;
00344 }
00345
00346 octave_idx_type get_count (void) const { return rep->count; }
00347
00348 octave_base_value::type_conv_info numeric_conversion_function (void) const
00349 { return rep->numeric_conversion_function (); }
00350
00351 octave_base_value::type_conv_info numeric_demotion_function (void) const
00352 { return rep->numeric_demotion_function (); }
00353
00354 void maybe_mutate (void);
00355
00356 octave_value squeeze (void) const
00357 { return rep->squeeze (); }
00358
00359
00360 octave_value full_value (void) const
00361 { return rep->full_value (); }
00362
00363 octave_base_value *try_narrowing_conversion (void)
00364 { return rep->try_narrowing_conversion (); }
00365
00366
00367 Matrix size (void)
00368 { return rep->size (); }
00369
00370 octave_idx_type numel (const octave_value_list& idx)
00371 { return rep->numel (idx); }
00372
00373 octave_value single_subsref (const std::string& type,
00374 const octave_value_list& idx);
00375
00376 octave_value subsref (const std::string& type,
00377 const std::list<octave_value_list>& idx)
00378 { return rep->subsref (type, idx); }
00379
00380 octave_value subsref (const std::string& type,
00381 const std::list<octave_value_list>& idx,
00382 bool auto_add)
00383 { return rep->subsref (type, idx, auto_add); }
00384
00385 octave_value_list subsref (const std::string& type,
00386 const std::list<octave_value_list>& idx,
00387 int nargout);
00388
00389 octave_value next_subsref (const std::string& type, const
00390 std::list<octave_value_list>& idx,
00391 size_t skip = 1);
00392
00393 octave_value_list next_subsref (int nargout,
00394 const std::string& type, const
00395 std::list<octave_value_list>& idx,
00396 size_t skip = 1);
00397
00398 octave_value next_subsref (bool auto_add, const std::string& type, const
00399 std::list<octave_value_list>& idx,
00400 size_t skip = 1);
00401
00402 octave_value do_index_op (const octave_value_list& idx,
00403 bool resize_ok = false)
00404 { return rep->do_index_op (idx, resize_ok); }
00405
00406 octave_value_list
00407 do_multi_index_op (int nargout, const octave_value_list& idx);
00408
00409 octave_value subsasgn (const std::string& type,
00410 const std::list<octave_value_list>& idx,
00411 const octave_value& rhs);
00412
00413 octave_value assign (assign_op op, const std::string& type,
00414 const std::list<octave_value_list>& idx,
00415 const octave_value& rhs);
00416
00417 const octave_value& assign (assign_op, const octave_value& rhs);
00418
00419 idx_vector index_vector (void) const
00420 { return rep->index_vector (); }
00421
00422
00423
00424 dim_vector dims (void) const
00425 { return rep->dims (); }
00426
00427 octave_idx_type rows (void) const { return rep->rows (); }
00428
00429 octave_idx_type columns (void) const { return rep->columns (); }
00430
00431 octave_idx_type length (void) const;
00432
00433 int ndims (void) const { return rep->ndims (); }
00434
00435 bool all_zero_dims (void) const { return dims().all_zero (); }
00436
00437 octave_idx_type numel (void) const
00438 { return rep->numel (); }
00439
00440 octave_idx_type capacity (void) const
00441 { return rep->capacity (); }
00442
00443 size_t byte_size (void) const
00444 { return rep->byte_size (); }
00445
00446 octave_idx_type nnz (void) const { return rep->nnz (); }
00447
00448 octave_idx_type nzmax (void) const { return rep->nzmax (); }
00449
00450 octave_idx_type nfields (void) const { return rep->nfields (); }
00451
00452 octave_value reshape (const dim_vector& dv) const
00453 { return rep->reshape (dv); }
00454
00455 octave_value permute (const Array<int>& vec, bool inv = false) const
00456 { return rep->permute (vec, inv); }
00457
00458 octave_value ipermute (const Array<int>& vec) const
00459 { return rep->permute (vec, true); }
00460
00461 octave_value resize (const dim_vector& dv, bool fill = false) const
00462 { return rep->resize (dv, fill);}
00463
00464 MatrixType matrix_type (void) const
00465 { return rep->matrix_type (); }
00466
00467 MatrixType matrix_type (const MatrixType& typ) const
00468 { return rep->matrix_type (typ); }
00469
00470
00471
00472
00473
00474 bool is_defined (void) const
00475 { return rep->is_defined (); }
00476
00477 bool is_undefined (void) const
00478 { return ! is_defined (); }
00479
00480 bool is_empty (void) const
00481 { return rep->is_empty (); }
00482
00483 bool is_cell (void) const
00484 { return rep->is_cell (); }
00485
00486 bool is_cellstr (void) const
00487 { return rep->is_cellstr (); }
00488
00489 bool is_real_scalar (void) const
00490 { return rep->is_real_scalar (); }
00491
00492 bool is_real_matrix (void) const
00493 { return rep->is_real_matrix (); }
00494
00495 bool is_real_nd_array (void) const
00496 { return rep->is_real_nd_array (); }
00497
00498 bool is_complex_scalar (void) const
00499 { return rep->is_complex_scalar (); }
00500
00501 bool is_complex_matrix (void) const
00502 { return rep->is_complex_matrix (); }
00503
00504 bool is_bool_scalar (void) const
00505 { return rep->is_bool_scalar (); }
00506
00507 bool is_bool_matrix (void) const
00508 { return rep->is_bool_matrix (); }
00509
00510 bool is_char_matrix (void) const
00511 { return rep->is_char_matrix (); }
00512
00513 bool is_diag_matrix (void) const
00514 { return rep->is_diag_matrix (); }
00515
00516 bool is_perm_matrix (void) const
00517 { return rep->is_perm_matrix (); }
00518
00519 bool is_string (void) const
00520 { return rep->is_string (); }
00521
00522 bool is_sq_string (void) const
00523 { return rep->is_sq_string (); }
00524
00525 bool is_dq_string (void) const
00526 { return rep->is_string () && ! rep->is_sq_string (); }
00527
00528 bool is_range (void) const
00529 { return rep->is_range (); }
00530
00531 bool is_map (void) const
00532 { return rep->is_map (); }
00533
00534 bool is_object (void) const
00535 { return rep->is_object (); }
00536
00537 bool is_cs_list (void) const
00538 { return rep->is_cs_list (); }
00539
00540 bool is_list (void) const
00541 { return rep->is_list (); }
00542
00543 bool is_magic_colon (void) const
00544 { return rep->is_magic_colon (); }
00545
00546 bool is_null_value (void) const
00547 { return rep->is_null_value (); }
00548
00549
00550
00551 octave_value all (int dim = 0) const
00552 { return rep->all (dim); }
00553
00554 octave_value any (int dim = 0) const
00555 { return rep->any (dim); }
00556
00557 builtin_type_t builtin_type (void) const
00558 { return rep->builtin_type (); }
00559
00560
00561
00562 bool is_double_type (void) const
00563 { return rep->is_double_type (); }
00564
00565 bool is_single_type (void) const
00566 { return rep->is_single_type (); }
00567
00568 bool is_float_type (void) const
00569 { return rep->is_float_type (); }
00570
00571
00572
00573 bool is_int8_type (void) const
00574 { return rep->is_int8_type (); }
00575
00576 bool is_int16_type (void) const
00577 { return rep->is_int16_type (); }
00578
00579 bool is_int32_type (void) const
00580 { return rep->is_int32_type (); }
00581
00582 bool is_int64_type (void) const
00583 { return rep->is_int64_type (); }
00584
00585 bool is_uint8_type (void) const
00586 { return rep->is_uint8_type (); }
00587
00588 bool is_uint16_type (void) const
00589 { return rep->is_uint16_type (); }
00590
00591 bool is_uint32_type (void) const
00592 { return rep->is_uint32_type (); }
00593
00594 bool is_uint64_type (void) const
00595 { return rep->is_uint64_type (); }
00596
00597
00598
00599 bool is_bool_type (void) const
00600 { return rep->is_bool_type (); }
00601
00602 bool is_integer_type (void) const
00603 { return rep->is_integer_type (); }
00604
00605 bool is_real_type (void) const
00606 { return rep->is_real_type (); }
00607
00608 bool is_complex_type (void) const
00609 { return rep->is_complex_type (); }
00610
00611 bool is_scalar_type (void) const
00612 { return rep->is_scalar_type (); }
00613
00614 bool is_matrix_type (void) const
00615 { return rep->is_matrix_type (); }
00616
00617 bool is_numeric_type (void) const
00618 { return rep->is_numeric_type (); }
00619
00620 bool is_sparse_type (void) const
00621 { return rep->is_sparse_type (); }
00622
00623
00624
00625 bool is_true (void) const
00626 { return rep->is_true (); }
00627
00628
00629
00630 bool is_equal (const octave_value&) const;
00631
00632
00633
00634 bool is_zero_by_zero (void) const
00635 { return (rows () == 0 && columns () == 0); }
00636
00637 bool is_constant (void) const
00638 { return rep->is_constant (); }
00639
00640 bool is_function_handle (void) const
00641 { return rep->is_function_handle (); }
00642
00643 bool is_inline_function (void) const
00644 { return rep->is_inline_function (); }
00645
00646 bool is_function (void) const
00647 { return rep->is_function (); }
00648
00649 bool is_user_script (void) const
00650 { return rep->is_user_script (); }
00651
00652 bool is_user_function (void) const
00653 { return rep->is_user_function (); }
00654
00655 bool is_user_code (void) const
00656 { return rep->is_user_code (); }
00657
00658 bool is_builtin_function (void) const
00659 { return rep->is_builtin_function (); }
00660
00661 bool is_dld_function (void) const
00662 { return rep->is_dld_function (); }
00663
00664 bool is_mex_function (void) const
00665 { return rep->is_mex_function (); }
00666
00667 void erase_subfunctions (void) { rep->erase_subfunctions (); }
00668
00669
00670
00671 octave_value eval (void) { return *this; }
00672
00673 short int
00674 short_value (bool req_int = false, bool frc_str_conv = false) const
00675 { return rep->short_value (req_int, frc_str_conv); }
00676
00677 unsigned short int
00678 ushort_value (bool req_int = false, bool frc_str_conv = false) const
00679 { return rep->ushort_value (req_int, frc_str_conv); }
00680
00681 int int_value (bool req_int = false, bool frc_str_conv = false) const
00682 { return rep->int_value (req_int, frc_str_conv); }
00683
00684 unsigned int
00685 uint_value (bool req_int = false, bool frc_str_conv = false) const
00686 { return rep->uint_value (req_int, frc_str_conv); }
00687
00688 int nint_value (bool frc_str_conv = false) const
00689 { return rep->nint_value (frc_str_conv); }
00690
00691 long int
00692 long_value (bool req_int = false, bool frc_str_conv = false) const
00693 { return rep->long_value (req_int, frc_str_conv); }
00694
00695 unsigned long int
00696 ulong_value (bool req_int = false, bool frc_str_conv = false) const
00697 { return rep->ulong_value (req_int, frc_str_conv); }
00698
00699 octave_idx_type
00700 idx_type_value (bool req_int = false, bool frc_str_conv = false) const;
00701
00702 double double_value (bool frc_str_conv = false) const
00703 { return rep->double_value (frc_str_conv); }
00704
00705 float float_value (bool frc_str_conv = false) const
00706 { return rep->float_value (frc_str_conv); }
00707
00708 double scalar_value (bool frc_str_conv = false) const
00709 { return rep->scalar_value (frc_str_conv); }
00710
00711 float float_scalar_value (bool frc_str_conv = false) const
00712 { return rep->float_scalar_value (frc_str_conv); }
00713
00714 Cell cell_value (void) const;
00715
00716 Matrix matrix_value (bool frc_str_conv = false) const
00717 { return rep->matrix_value (frc_str_conv); }
00718
00719 FloatMatrix float_matrix_value (bool frc_str_conv = false) const
00720 { return rep->float_matrix_value (frc_str_conv); }
00721
00722 NDArray array_value (bool frc_str_conv = false) const
00723 { return rep->array_value (frc_str_conv); }
00724
00725 FloatNDArray float_array_value (bool frc_str_conv = false) const
00726 { return rep->float_array_value (frc_str_conv); }
00727
00728 Complex complex_value (bool frc_str_conv = false) const
00729 { return rep->complex_value (frc_str_conv); }
00730
00731 FloatComplex float_complex_value (bool frc_str_conv = false) const
00732 { return rep->float_complex_value (frc_str_conv); }
00733
00734 ComplexMatrix complex_matrix_value (bool frc_str_conv = false) const
00735 { return rep->complex_matrix_value (frc_str_conv); }
00736
00737 FloatComplexMatrix float_complex_matrix_value (bool frc_str_conv = false) const
00738 { return rep->float_complex_matrix_value (frc_str_conv); }
00739
00740 ComplexNDArray complex_array_value (bool frc_str_conv = false) const
00741 { return rep->complex_array_value (frc_str_conv); }
00742
00743 FloatComplexNDArray float_complex_array_value (bool frc_str_conv = false) const
00744 { return rep->float_complex_array_value (frc_str_conv); }
00745
00746 bool bool_value (bool warn = false) const
00747 { return rep->bool_value (warn); }
00748
00749 boolMatrix bool_matrix_value (bool warn = false) const
00750 { return rep->bool_matrix_value (warn); }
00751
00752 boolNDArray bool_array_value (bool warn = false) const
00753 { return rep->bool_array_value (warn); }
00754
00755 charMatrix char_matrix_value (bool frc_str_conv = false) const
00756 { return rep->char_matrix_value (frc_str_conv); }
00757
00758 charNDArray char_array_value (bool frc_str_conv = false) const
00759 { return rep->char_array_value (frc_str_conv); }
00760
00761 SparseMatrix sparse_matrix_value (bool frc_str_conv = false) const
00762 { return rep->sparse_matrix_value (frc_str_conv); }
00763
00764 SparseComplexMatrix sparse_complex_matrix_value (bool frc_str_conv = false) const
00765 { return rep->sparse_complex_matrix_value (frc_str_conv); }
00766
00767 SparseBoolMatrix sparse_bool_matrix_value (bool frc_str_conv = false) const
00768 { return rep->sparse_bool_matrix_value (frc_str_conv); }
00769
00770 DiagMatrix diag_matrix_value (bool force = false) const
00771 { return rep->diag_matrix_value (force); }
00772
00773 FloatDiagMatrix float_diag_matrix_value (bool force = false) const
00774 { return rep->float_diag_matrix_value (force); }
00775
00776 ComplexDiagMatrix complex_diag_matrix_value (bool force = false) const
00777 { return rep->complex_diag_matrix_value (force); }
00778
00779 FloatComplexDiagMatrix float_complex_diag_matrix_value (bool force = false) const
00780 { return rep->float_complex_diag_matrix_value (force); }
00781
00782 PermMatrix perm_matrix_value (void) const
00783 { return rep->perm_matrix_value (); }
00784
00785 octave_int8 int8_scalar_value (void) const
00786 { return rep->int8_scalar_value (); }
00787
00788 octave_int16 int16_scalar_value (void) const
00789 { return rep->int16_scalar_value (); }
00790
00791 octave_int32 int32_scalar_value (void) const
00792 { return rep->int32_scalar_value (); }
00793
00794 octave_int64 int64_scalar_value (void) const
00795 { return rep->int64_scalar_value (); }
00796
00797 octave_uint8 uint8_scalar_value (void) const
00798 { return rep->uint8_scalar_value (); }
00799
00800 octave_uint16 uint16_scalar_value (void) const
00801 { return rep->uint16_scalar_value (); }
00802
00803 octave_uint32 uint32_scalar_value (void) const
00804 { return rep->uint32_scalar_value (); }
00805
00806 octave_uint64 uint64_scalar_value (void) const
00807 { return rep->uint64_scalar_value (); }
00808
00809 int8NDArray int8_array_value (void) const
00810 { return rep->int8_array_value (); }
00811
00812 int16NDArray int16_array_value (void) const
00813 { return rep->int16_array_value (); }
00814
00815 int32NDArray int32_array_value (void) const
00816 { return rep->int32_array_value (); }
00817
00818 int64NDArray int64_array_value (void) const
00819 { return rep->int64_array_value (); }
00820
00821 uint8NDArray uint8_array_value (void) const
00822 { return rep->uint8_array_value (); }
00823
00824 uint16NDArray uint16_array_value (void) const
00825 { return rep->uint16_array_value (); }
00826
00827 uint32NDArray uint32_array_value (void) const
00828 { return rep->uint32_array_value (); }
00829
00830 uint64NDArray uint64_array_value (void) const
00831 { return rep->uint64_array_value (); }
00832
00833 string_vector all_strings (bool pad = false) const
00834 { return rep->all_strings (pad); }
00835
00836 std::string string_value (bool force = false) const
00837 { return rep->string_value (force); }
00838
00839 Array<std::string> cellstr_value (void) const
00840 { return rep->cellstr_value (); }
00841
00842 Range range_value (void) const
00843 { return rep->range_value (); }
00844
00845 Octave_map map_value (void) const;
00846
00847 string_vector map_keys (void) const
00848 { return rep->map_keys (); }
00849
00850 size_t nparents (void) const
00851 { return rep->nparents (); }
00852
00853 std::list<std::string> parent_class_name_list (void) const
00854 { return rep->parent_class_name_list (); }
00855
00856 string_vector parent_class_names (void) const
00857 { return rep->parent_class_names (); }
00858
00859 octave_base_value *
00860 find_parent_class (const std::string& parent_class_name)
00861 { return rep->find_parent_class (parent_class_name); }
00862
00863 octave_function *function_value (bool silent = false);
00864
00865 const octave_function *function_value (bool silent = false) const;
00866
00867 octave_user_function *user_function_value (bool silent = false);
00868
00869 octave_user_script *user_script_value (bool silent = false);
00870
00871 octave_user_code *user_code_value (bool silent = false);
00872
00873 octave_fcn_handle *fcn_handle_value (bool silent = false);
00874
00875 octave_fcn_inline *fcn_inline_value (bool silent = false);
00876
00877 octave_value_list list_value (void) const;
00878
00879 ColumnVector column_vector_value (bool frc_str_conv = false,
00880 bool frc_vec_conv = false) const;
00881
00882 ComplexColumnVector
00883 complex_column_vector_value (bool frc_str_conv = false,
00884 bool frc_vec_conv = false) const;
00885
00886 RowVector row_vector_value (bool frc_str_conv = false,
00887 bool frc_vec_conv = false) const;
00888
00889 ComplexRowVector
00890 complex_row_vector_value (bool frc_str_conv = false,
00891 bool frc_vec_conv = false) const;
00892
00893
00894 FloatColumnVector float_column_vector_value (bool frc_str_conv = false,
00895 bool frc_vec_conv = false) const;
00896
00897 FloatComplexColumnVector
00898 float_complex_column_vector_value (bool frc_str_conv = false,
00899 bool frc_vec_conv = false) const;
00900
00901 FloatRowVector float_row_vector_value (bool frc_str_conv = false,
00902 bool frc_vec_conv = false) const;
00903
00904 FloatComplexRowVector
00905 float_complex_row_vector_value (bool frc_str_conv = false,
00906 bool frc_vec_conv = false) const;
00907
00908
00909
00910
00911 Array<int> int_vector_value (bool req_int = false,
00912 bool frc_str_conv = false,
00913 bool frc_vec_conv = false) const;
00914
00915 Array<octave_idx_type>
00916 octave_idx_type_vector_value (bool req_int = false,
00917 bool frc_str_conv = false,
00918 bool frc_vec_conv = false) const;
00919
00920 Array<double> vector_value (bool frc_str_conv = false,
00921 bool frc_vec_conv = false) const;
00922
00923 Array<Complex> complex_vector_value (bool frc_str_conv = false,
00924 bool frc_vec_conv = false) const;
00925
00926 Array<float> float_vector_value (bool frc_str_conv = false,
00927 bool frc_vec_conv = false) const;
00928
00929 Array<FloatComplex> float_complex_vector_value (bool frc_str_conv = false,
00930 bool frc_vec_conv = false) const;
00931
00932
00933
00934 void maybe_economize (void)
00935 { rep->maybe_economize (); }
00936
00937
00938
00939
00940
00941 octave_value storable_value (void) const;
00942
00943
00944
00945
00946 void make_storable_value (void);
00947
00948
00949
00950
00951
00952 octave_value convert_to_str (bool pad = false, bool force = false,
00953 char type = '\'') const
00954 { return rep->convert_to_str (pad, force, type); }
00955
00956 octave_value
00957 convert_to_str_internal (bool pad, bool force, char type) const
00958 { return rep->convert_to_str_internal (pad, force, type); }
00959
00960 void convert_to_row_or_column_vector (void)
00961 { rep->convert_to_row_or_column_vector (); }
00962
00963 bool print_as_scalar (void) const
00964 { return rep->print_as_scalar (); }
00965
00966 void print (std::ostream& os, bool pr_as_read_syntax = false) const
00967 { rep->print (os, pr_as_read_syntax); }
00968
00969 void print_raw (std::ostream& os,
00970 bool pr_as_read_syntax = false) const
00971 { rep->print_raw (os, pr_as_read_syntax); }
00972
00973 bool print_name_tag (std::ostream& os, const std::string& name) const
00974 { return rep->print_name_tag (os, name); }
00975
00976 void print_with_name (std::ostream& os, const std::string& name,
00977 bool print_padding = true) const
00978 { rep->print_with_name (os, name, print_padding); }
00979
00980 int type_id (void) const { return rep->type_id (); }
00981
00982 std::string type_name (void) const { return rep->type_name (); }
00983
00984 std::string class_name (void) const { return rep->class_name (); }
00985
00986
00987
00988 friend OCTINTERP_API octave_value do_unary_op (unary_op op,
00989 const octave_value& a);
00990
00991 const octave_value& do_non_const_unary_op (unary_op op);
00992
00993 void do_non_const_unary_op (unary_op op, const octave_value_list& idx);
00994
00995 octave_value do_non_const_unary_op (unary_op op, const std::string& type,
00996 const std::list<octave_value_list>& idx);
00997
00998 friend OCTINTERP_API octave_value do_binary_op (binary_op op,
00999 const octave_value& a,
01000 const octave_value& b);
01001
01002 friend OCTINTERP_API octave_value do_binary_op (compound_binary_op op,
01003 const octave_value& a,
01004 const octave_value& b);
01005
01006 friend OCTINTERP_API octave_value do_cat_op (const octave_value& a,
01007 const octave_value& b,
01008 const Array<octave_idx_type>& ra_idx);
01009
01010 const octave_base_value& get_rep (void) const { return *rep; }
01011
01012 bool is_copy_of (const octave_value &val) const { return rep == val.rep; }
01013
01014 void print_info (std::ostream& os,
01015 const std::string& prefix = std::string ()) const;
01016
01017 bool save_ascii (std::ostream& os) { return rep->save_ascii (os); }
01018
01019 bool load_ascii (std::istream& is) { return rep->load_ascii (is); }
01020
01021 bool save_binary (std::ostream& os, bool& save_as_floats)
01022 { return rep->save_binary (os, save_as_floats); }
01023
01024 bool load_binary (std::istream& is, bool swap,
01025 oct_mach_info::float_format fmt)
01026 { return rep->load_binary (is, swap, fmt); }
01027
01028 #if defined (HAVE_HDF5)
01029 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats)
01030 { return rep->save_hdf5 (loc_id, name, save_as_floats); }
01031
01032 bool load_hdf5 (hid_t loc_id, const char *name,
01033 bool have_h5giterate_bug)
01034 { return rep->load_hdf5 (loc_id, name, have_h5giterate_bug); }
01035 #endif
01036
01037 int write (octave_stream& os, int block_size,
01038 oct_data_conv::data_type output_type, int skip,
01039 oct_mach_info::float_format flt_fmt) const;
01040
01041 octave_base_value *internal_rep (void) const { return rep; }
01042
01043
01044
01045 void *mex_get_data (void) const { return rep->mex_get_data (); }
01046
01047 octave_idx_type *mex_get_ir (void) const { return rep->mex_get_ir (); }
01048
01049 octave_idx_type *mex_get_jc (void) const { return rep->mex_get_jc (); }
01050
01051 mxArray *as_mxArray (void) const { return rep->as_mxArray (); }
01052
01053 octave_value diag (octave_idx_type k = 0) const
01054 { return rep->diag (k); }
01055
01056 octave_value sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const
01057 { return rep->sort (dim, mode); }
01058 octave_value sort (Array<octave_idx_type> &sidx, octave_idx_type dim = 0,
01059 sortmode mode = ASCENDING) const
01060 { return rep->sort (sidx, dim, mode); }
01061
01062 sortmode is_sorted (sortmode mode = UNSORTED) const
01063 { return rep->is_sorted (mode); }
01064
01065 Array<octave_idx_type> sort_rows_idx (sortmode mode = ASCENDING) const
01066 { return rep->sort_rows_idx (mode); }
01067
01068 sortmode is_sorted_rows (sortmode mode = UNSORTED) const
01069 { return rep->is_sorted_rows (mode); }
01070
01071 void lock (void) { rep->lock (); }
01072
01073 void unlock (void) { rep->unlock (); }
01074
01075 bool islocked (void) const { return rep->islocked (); }
01076
01077 void dump (std::ostream& os) const { rep->dump (os); }
01078
01079 #define MAPPER_FORWARD(F) \
01080 octave_value F (void) const { return rep->F (); }
01081
01082 MAPPER_FORWARD (abs)
01083 MAPPER_FORWARD (acos)
01084 MAPPER_FORWARD (acosh)
01085 MAPPER_FORWARD (angle)
01086 MAPPER_FORWARD (arg)
01087 MAPPER_FORWARD (asin)
01088 MAPPER_FORWARD (asinh)
01089 MAPPER_FORWARD (atan)
01090 MAPPER_FORWARD (atanh)
01091 MAPPER_FORWARD (ceil)
01092 MAPPER_FORWARD (conj)
01093 MAPPER_FORWARD (cos)
01094 MAPPER_FORWARD (cosh)
01095 MAPPER_FORWARD (erf)
01096 MAPPER_FORWARD (erfc)
01097 MAPPER_FORWARD (exp)
01098 MAPPER_FORWARD (expm1)
01099 MAPPER_FORWARD (finite)
01100 MAPPER_FORWARD (fix)
01101 MAPPER_FORWARD (floor)
01102 MAPPER_FORWARD (gamma)
01103 MAPPER_FORWARD (imag)
01104 MAPPER_FORWARD (isinf)
01105 MAPPER_FORWARD (isna)
01106 MAPPER_FORWARD (isnan)
01107 MAPPER_FORWARD (lgamma)
01108 MAPPER_FORWARD (log)
01109 MAPPER_FORWARD (log2)
01110 MAPPER_FORWARD (log10)
01111 MAPPER_FORWARD (log1p)
01112 MAPPER_FORWARD (real)
01113 MAPPER_FORWARD (round)
01114 MAPPER_FORWARD (roundb)
01115 MAPPER_FORWARD (signum)
01116 MAPPER_FORWARD (sin)
01117 MAPPER_FORWARD (sinh)
01118 MAPPER_FORWARD (sqrt)
01119 MAPPER_FORWARD (tan)
01120 MAPPER_FORWARD (tanh)
01121
01122
01123
01124
01125 MAPPER_FORWARD (xisalnum)
01126 MAPPER_FORWARD (xisalpha)
01127 MAPPER_FORWARD (xisascii)
01128 MAPPER_FORWARD (xiscntrl)
01129 MAPPER_FORWARD (xisdigit)
01130 MAPPER_FORWARD (xisgraph)
01131 MAPPER_FORWARD (xislower)
01132 MAPPER_FORWARD (xisprint)
01133 MAPPER_FORWARD (xispunct)
01134 MAPPER_FORWARD (xisspace)
01135 MAPPER_FORWARD (xisupper)
01136 MAPPER_FORWARD (xisxdigit)
01137 MAPPER_FORWARD (xtoascii)
01138 MAPPER_FORWARD (xtolower)
01139 MAPPER_FORWARD (xtoupper)
01140
01141 #undef MAPPER_FORWARD
01142
01143 protected:
01144
01145
01146 octave_base_value *rep;
01147
01148 private:
01149
01150 assign_op unary_op_to_assign_op (unary_op op);
01151
01152 binary_op op_eq_to_binary_op (assign_op op);
01153
01154
01155
01156 octave_value (const octave_base_value *);
01157
01158 DECLARE_OCTAVE_ALLOCATOR
01159 };
01160
01161
01162
01163 extern OCTINTERP_API octave_value
01164 do_unary_op (octave_value::unary_op op, const octave_value& a);
01165
01166 extern OCTINTERP_API octave_value
01167 do_binary_op (octave_value::binary_op op,
01168 const octave_value& a, const octave_value& b);
01169
01170 extern OCTINTERP_API octave_value
01171 do_binary_op (octave_value::compound_binary_op op,
01172 const octave_value& a, const octave_value& b);
01173
01174 #define OV_UNOP_FN(name) \
01175 inline octave_value \
01176 name (const octave_value& a) \
01177 { \
01178 return do_unary_op (octave_value::name, a); \
01179 }
01180
01181 #define OV_UNOP_OP(name, op) \
01182 inline octave_value \
01183 operator op (const octave_value& a) \
01184 { \
01185 return name (a); \
01186 }
01187
01188 #define OV_UNOP_FN_OP(name, op) \
01189 OV_UNOP_FN (name) \
01190 OV_UNOP_OP (name, op)
01191
01192 OV_UNOP_FN_OP (op_not, !)
01193 OV_UNOP_FN_OP (op_uplus, +)
01194 OV_UNOP_FN_OP (op_uminus, -)
01195
01196 OV_UNOP_FN (op_transpose)
01197 OV_UNOP_FN (op_hermitian)
01198
01199
01200
01201
01202
01203
01204 #define OV_BINOP_FN(name) \
01205 inline octave_value \
01206 name (const octave_value& a1, const octave_value& a2) \
01207 { \
01208 return do_binary_op (octave_value::name, a1, a2); \
01209 }
01210
01211 #define OV_BINOP_OP(name, op) \
01212 inline octave_value \
01213 operator op (const octave_value& a1, const octave_value& a2) \
01214 { \
01215 return name (a1, a2); \
01216 }
01217
01218 #define OV_BINOP_FN_OP(name, op) \
01219 OV_BINOP_FN (name) \
01220 OV_BINOP_OP (name, op)
01221
01222 OV_BINOP_FN_OP (op_add, +)
01223 OV_BINOP_FN_OP (op_sub, -)
01224 OV_BINOP_FN_OP (op_mul, *)
01225 OV_BINOP_FN_OP (op_div, /)
01226
01227 OV_BINOP_FN (op_pow)
01228 OV_BINOP_FN (op_ldiv)
01229 OV_BINOP_FN (op_lshift)
01230 OV_BINOP_FN (op_rshift)
01231
01232 OV_BINOP_FN_OP (op_lt, <)
01233 OV_BINOP_FN_OP (op_le, <=)
01234 OV_BINOP_FN_OP (op_eq, ==)
01235 OV_BINOP_FN_OP (op_ge, >=)
01236 OV_BINOP_FN_OP (op_gt, >)
01237 OV_BINOP_FN_OP (op_ne, !=)
01238
01239 OV_BINOP_FN (op_el_mul)
01240 OV_BINOP_FN (op_el_div)
01241 OV_BINOP_FN (op_el_pow)
01242 OV_BINOP_FN (op_el_ldiv)
01243 OV_BINOP_FN (op_el_and)
01244 OV_BINOP_FN (op_el_or)
01245
01246 OV_BINOP_FN (op_struct_ref)
01247
01248 #define OV_COMP_BINOP_FN(name) \
01249 inline octave_value \
01250 name (const octave_value& a1, const octave_value& a2) \
01251 { \
01252 return do_binary_op (octave_value::name, a1, a2); \
01253 }
01254
01255 OV_COMP_BINOP_FN (op_trans_mul)
01256 OV_COMP_BINOP_FN (op_mul_trans)
01257 OV_COMP_BINOP_FN (op_herm_mul)
01258 OV_COMP_BINOP_FN (op_mul_herm)
01259
01260 extern OCTINTERP_API void install_types (void);
01261
01262
01263
01264
01265
01266 #define OV_REP_TYPE octave_base_value
01267
01268
01269 template<class Value>
01270 inline Value octave_value_extract (const octave_value&)
01271 { assert (false); }
01272
01273 #define DEF_VALUE_EXTRACTOR(VALUE,MPREFIX) \
01274 template<> \
01275 inline VALUE octave_value_extract<VALUE> (const octave_value& v) \
01276 { return v.MPREFIX ## _value (); }
01277
01278 DEF_VALUE_EXTRACTOR (double, scalar)
01279 DEF_VALUE_EXTRACTOR (float, float_scalar)
01280 DEF_VALUE_EXTRACTOR (Complex, complex)
01281 DEF_VALUE_EXTRACTOR (FloatComplex, float_complex)
01282 DEF_VALUE_EXTRACTOR (bool, bool)
01283
01284 DEF_VALUE_EXTRACTOR (octave_int8, int8_scalar)
01285 DEF_VALUE_EXTRACTOR (octave_int16, int16_scalar)
01286 DEF_VALUE_EXTRACTOR (octave_int32, int32_scalar)
01287 DEF_VALUE_EXTRACTOR (octave_int64, int64_scalar)
01288 DEF_VALUE_EXTRACTOR (octave_uint8, uint8_scalar)
01289 DEF_VALUE_EXTRACTOR (octave_uint16, uint16_scalar)
01290 DEF_VALUE_EXTRACTOR (octave_uint32, uint32_scalar)
01291 DEF_VALUE_EXTRACTOR (octave_uint64, uint64_scalar)
01292
01293
01294 DEF_VALUE_EXTRACTOR (NDArray, array)
01295 DEF_VALUE_EXTRACTOR (FloatNDArray, float_array)
01296 DEF_VALUE_EXTRACTOR (ComplexNDArray, complex_array)
01297 DEF_VALUE_EXTRACTOR (FloatComplexNDArray, float_complex_array)
01298 DEF_VALUE_EXTRACTOR (boolNDArray, bool_array)
01299
01300 DEF_VALUE_EXTRACTOR (charNDArray, char_array)
01301 DEF_VALUE_EXTRACTOR (int8NDArray, int8_array)
01302 DEF_VALUE_EXTRACTOR (int16NDArray, int16_array)
01303 DEF_VALUE_EXTRACTOR (int32NDArray, int32_array)
01304 DEF_VALUE_EXTRACTOR (int64NDArray, int64_array)
01305 DEF_VALUE_EXTRACTOR (uint8NDArray, uint8_array)
01306 DEF_VALUE_EXTRACTOR (uint16NDArray, uint16_array)
01307 DEF_VALUE_EXTRACTOR (uint32NDArray, uint32_array)
01308 DEF_VALUE_EXTRACTOR (uint64NDArray, uint64_array)
01309
01310 DEF_VALUE_EXTRACTOR (Matrix, matrix)
01311 DEF_VALUE_EXTRACTOR (FloatMatrix, float_matrix)
01312 DEF_VALUE_EXTRACTOR (ComplexMatrix, complex_matrix)
01313 DEF_VALUE_EXTRACTOR (FloatComplexMatrix, float_complex_matrix)
01314 DEF_VALUE_EXTRACTOR (boolMatrix, bool_matrix)
01315
01316 DEF_VALUE_EXTRACTOR (ColumnVector, column_vector)
01317 DEF_VALUE_EXTRACTOR (FloatColumnVector, float_column_vector)
01318 DEF_VALUE_EXTRACTOR (ComplexColumnVector, complex_column_vector)
01319 DEF_VALUE_EXTRACTOR (FloatComplexColumnVector, float_complex_column_vector)
01320
01321 DEF_VALUE_EXTRACTOR (RowVector, row_vector)
01322 DEF_VALUE_EXTRACTOR (FloatRowVector, float_row_vector)
01323 DEF_VALUE_EXTRACTOR (ComplexRowVector, complex_row_vector)
01324 DEF_VALUE_EXTRACTOR (FloatComplexRowVector, float_complex_row_vector)
01325
01326 DEF_VALUE_EXTRACTOR (DiagMatrix, diag_matrix)
01327 DEF_VALUE_EXTRACTOR (FloatDiagMatrix, float_diag_matrix)
01328 DEF_VALUE_EXTRACTOR (ComplexDiagMatrix, complex_diag_matrix)
01329 DEF_VALUE_EXTRACTOR (FloatComplexDiagMatrix, float_complex_diag_matrix)
01330 DEF_VALUE_EXTRACTOR (PermMatrix, perm_matrix)
01331
01332 #undef DEF_VALUE_EXTRACTOR
01333
01334 #endif
01335
01336
01337
01338
01339
01340