annotate libinterp/octave-value/ov.cc @ 19437:03067dab10ca

Use stricter input validation when looking for a string as input (bug #42651). * data.cc (get_sort_mode_option, Fissorted): Use is_string() to check string input. * debug.cc (Fdbstep): use "string" rather than "character string" in error messages. * error.cc (Flasterr, Flastwarn): use "string" rather than "character string" in error messages. * file-io.cc (do_stream_open, do_fread, do_fwrite, Fpopen, Ftempname, Fmkstemp): Use is_string() to check string input. * graphics.cc (Fgraphics_toolkit): Use is_string() to check string input. Rephrase error message. * help.cc (F__list_functions): Use is_string() to check string input. * input.cc (Fyes_or_no): Use is_string() to check string input. Rephrase error message. * input.cc (Fadd_input_event_hook): Rephrase error message. * load-path.cc (Fgenpath, Faddpath): Rephrase error message. * matrix_type.cc (Fmatrix_type): Use is_string() to check string input. * qz.cc (Fqz): Follow Octave coding convention for space after '!'. * regexp.cc (parse_options): Use is_string() to check string input. Rephrase error message. * schur.cc (Fschur): Use is_string() to check string input. * strfns.cc (Flist_in_columns): Use is_string() to check string input. Rephrase error message. * symtab.cc (Fignore_function_time_stamp): Use is_string() to check string input. Rephrase error message. * syscalls.cc (Fexec, Fpopen2, Fcanonicalize_file_name): Use is_string() to check string input. Rephrase error message. * sysdep.cc (Fsetenv): Use is_string() to check string input. * time.cc (Fstrftime, Fstrptime): Use is_string() to check string input. * toplev.cc (Fsystem, Fatexit): Use is_string() to check string input. * urlwrite.cc (Furlwrite, Furlread): Rephrase error message. * utils.cc (Ffile_in_path): Use is_string() to check string input. Rephrase error message. * variables.cc (extract_function): Add FIXME about potentially using is_string. * variables.cc (do_isglobal, Fmunlock, Fmislocked): Use is_string() to check string input. * variables.cc (set_internal_variable): Rephrase error message. * ov-base.cc (make_idx_args): Rephrase error message. * ov-class.cc (octave_class::all_strings, Fclass): Rephrase error message. * ov-fcn-handle.cc (Fstr2func): Use is_string() to check string input * ov-java.cc (FjavaObject, FjavaMethod, F__java_get__, F__java_set__): Use is_string() to check string input. * ov.cc (Fdecode_subscripts): Use is_string() to check string input. Rephrase error message. * pt-idx.cc (tree_index_expression::get_struct_index): Rephrase error message. * io.tst: Change %!warning test to %!error test to match stricter checking. * system.tst: Change %!warning test for setenv to %!error test to match stricter checking.
author Rik <rik@octave.org>
date Tue, 16 Dec 2014 09:21:29 -0800
parents 9e5b64b3c1fe
children 76478d2da117
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1 /*
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
2
17744
d63878346099 maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents: 16323
diff changeset
3 Copyright (C) 1996-2013 John W. Eaton
11523
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 10871
diff changeset
4 Copyright (C) 2009-2010 VZLU Prague
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
5
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
6 This file is part of Octave.
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
7
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6867
diff changeset
10 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6867
diff changeset
11 option) any later version.
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
12
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
16 for more details.
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
17
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6867
diff changeset
19 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6867
diff changeset
20 <http://www.gnu.org/licenses/>.
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
21
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
22 */
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
23
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
24 #ifdef HAVE_CONFIG_H
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
25 #include <config.h>
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
26 #endif
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
27
4970
25c2664861bc [project @ 2004-09-08 05:02:32 by jwe]
jwe
parents: 4966
diff changeset
28 #include "data-conv.h"
25c2664861bc [project @ 2004-09-08 05:02:32 by jwe]
jwe
parents: 4966
diff changeset
29 #include "quit.h"
2942
026f342c2019 [project @ 1997-05-08 02:20:57 by jwe]
jwe
parents: 2909
diff changeset
30 #include "str-vec.h"
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
31
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents: 2963
diff changeset
32 #include "oct-obj.h"
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4933
diff changeset
33 #include "oct-stream.h"
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
34 #include "ov.h"
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
35 #include "ov-base.h"
2825
60ae49e1284f [project @ 1997-03-25 23:17:36 by jwe]
jwe
parents: 2800
diff changeset
36 #include "ov-bool.h"
60ae49e1284f [project @ 1997-03-25 23:17:36 by jwe]
jwe
parents: 2800
diff changeset
37 #include "ov-bool-mat.h"
3351
8623649c967c [project @ 1999-11-15 16:17:01 by jwe]
jwe
parents: 3340
diff changeset
38 #include "ov-cell.h"
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
39 #include "ov-scalar.h"
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
40 #include "ov-float.h"
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
41 #include "ov-re-mat.h"
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
42 #include "ov-flt-re-mat.h"
8366
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8346
diff changeset
43 #include "ov-re-diag.h"
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8346
diff changeset
44 #include "ov-flt-re-diag.h"
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
45 #include "ov-perm.h"
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5147
diff changeset
46 #include "ov-bool-sparse.h"
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5147
diff changeset
47 #include "ov-cx-sparse.h"
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5147
diff changeset
48 #include "ov-re-sparse.h"
4901
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
49 #include "ov-int8.h"
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
50 #include "ov-int16.h"
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
51 #include "ov-int32.h"
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
52 #include "ov-int64.h"
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
53 #include "ov-uint8.h"
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
54 #include "ov-uint16.h"
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
55 #include "ov-uint32.h"
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
56 #include "ov-uint64.h"
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
57 #include "ov-complex.h"
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
58 #include "ov-flt-complex.h"
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
59 #include "ov-cx-mat.h"
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
60 #include "ov-flt-cx-mat.h"
8366
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8346
diff changeset
61 #include "ov-cx-diag.h"
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8346
diff changeset
62 #include "ov-flt-cx-diag.h"
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
63 #include "ov-ch-mat.h"
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
64 #include "ov-str-mat.h"
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
65 #include "ov-range.h"
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
66 #include "ov-struct.h"
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
67 #include "ov-class.h"
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14861
diff changeset
68 #include "ov-classdef.h"
14015
77adde2e79ac fix include file name
John W. Eaton <jwe@octave.org>
parents: 14013
diff changeset
69 #include "ov-oncleanup.h"
3977
95663a3a2682 [project @ 2002-07-05 17:43:37 by jwe]
jwe
parents: 3961
diff changeset
70 #include "ov-cs-list.h"
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
71 #include "ov-colon.h"
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents: 2963
diff changeset
72 #include "ov-builtin.h"
4649
f7ce581b27fb [project @ 2003-11-23 21:46:44 by jwe]
jwe
parents: 4645
diff changeset
73 #include "ov-dld-fcn.h"
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents: 2963
diff changeset
74 #include "ov-usr-fcn.h"
4342
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4276
diff changeset
75 #include "ov-fcn-handle.h"
4966
91b61d27b9b4 [project @ 2004-09-07 02:01:22 by jwe]
jwe
parents: 4965
diff changeset
76 #include "ov-fcn-inline.h"
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
77 #include "ov-typeinfo.h"
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8039
diff changeset
78 #include "ov-null-mat.h"
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
79 #include "ov-lazy-idx.h"
15767
e665645fb402 only register java type if using java
John W. Eaton <jwe@octave.org>
parents: 15754
diff changeset
80 #ifdef HAVE_JAVA
15754
bf77f7f66bdf register octave_java type at Octave startup
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
81 #include "ov-java.h"
15767
e665645fb402 only register java type if using java
John W. Eaton <jwe@octave.org>
parents: 15754
diff changeset
82 #endif
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
83
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
84 #include "defun.h"
2880
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
85 #include "error.h"
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
86 #include "gripes.h"
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
87 #include "pager.h"
4005
fc000ebb19df [project @ 2002-07-25 21:01:16 by jwe]
jwe
parents: 3977
diff changeset
88 #include "parse.h"
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
89 #include "pr-output.h"
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
90 #include "symtab.h"
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
91 #include "utils.h"
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
92 #include "variables.h"
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
93
2477
3d905d3820a4 [project @ 1996-11-07 16:46:11 by jwe]
jwe
parents: 2475
diff changeset
94 // We are likely to have a lot of octave_value objects to allocate, so
3d905d3820a4 [project @ 1996-11-07 16:46:11 by jwe]
jwe
parents: 2475
diff changeset
95 // make the grow_size large.
3219
30770ba4457a [project @ 1998-11-13 03:44:31 by jwe]
jwe
parents: 3205
diff changeset
96 DEFINE_OCTAVE_ALLOCATOR2(octave_value, 1024);
2477
3d905d3820a4 [project @ 1996-11-07 16:46:11 by jwe]
jwe
parents: 2475
diff changeset
97
19425
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
98 // If TRUE, don't create special diagonal matrix objects.
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
99
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
100 static bool Vdisable_diagonal_matrix = false;
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
101
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
102 // If TRUE, don't create special permutation matrix objects.
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
103
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
104 static bool Vdisable_permutation_matrix = false;
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
105
19428
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
106 // If TRUE, don't create special range objects.
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
107
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
108 static bool Vdisable_range = false;
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
109
5775
ace8d8d26933 [project @ 2006-04-24 19:13:06 by jwe]
jwe
parents: 5759
diff changeset
110 // FIXME
2880
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
111
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
112 // Octave's value type.
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
113
3536
e8fbc8c3d6d9 [project @ 2000-02-02 12:01:00 by jwe]
jwe
parents: 3534
diff changeset
114 std::string
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
115 octave_value::unary_op_as_string (unary_op op)
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
116 {
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3465
diff changeset
117 std::string retval;
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
118
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
119 switch (op)
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
120 {
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
121 case op_not:
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
122 retval = "!";
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
123 break;
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
124
4965
c0d8e8afa82f [project @ 2004-09-06 20:19:57 by jwe]
jwe
parents: 4944
diff changeset
125 case op_uplus:
c0d8e8afa82f [project @ 2004-09-06 20:19:57 by jwe]
jwe
parents: 4944
diff changeset
126 retval = "+";
c0d8e8afa82f [project @ 2004-09-06 20:19:57 by jwe]
jwe
parents: 4944
diff changeset
127 break;
c0d8e8afa82f [project @ 2004-09-06 20:19:57 by jwe]
jwe
parents: 4944
diff changeset
128
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
129 case op_uminus:
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
130 retval = "-";
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
131 break;
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
132
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
133 case op_transpose:
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
134 retval = ".'";
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
135 break;
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
136
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
137 case op_hermitian:
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
138 retval = "'";
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
139 break;
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
140
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
141 case op_incr:
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
142 retval = "++";
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
143 break;
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
144
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
145 case op_decr:
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
146 retval = "--";
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
147 break;
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
148
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
149 default:
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
150 retval = "<unknown>";
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
151 }
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
152
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
153 return retval;
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
154 }
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
155
3536
e8fbc8c3d6d9 [project @ 2000-02-02 12:01:00 by jwe]
jwe
parents: 3534
diff changeset
156 std::string
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
157 octave_value::unary_op_fcn_name (unary_op op)
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
158 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
159 std::string retval;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
160
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
161 switch (op)
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
162 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
163 case op_not:
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
164 retval = "not";
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
165 break;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
166
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
167 case op_uplus:
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
168 retval = "uplus";
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
169 break;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
170
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
171 case op_uminus:
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
172 retval = "uminus";
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
173 break;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
174
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
175 case op_transpose:
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
176 retval = "transpose";
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
177 break;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
178
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
179 case op_hermitian:
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
180 retval = "ctranspose";
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
181 break;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
182
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
183 default:
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
184 break;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
185 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
186
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
187 return retval;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
188 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
189
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
190 std::string
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
191 octave_value::binary_op_as_string (binary_op op)
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
192 {
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3465
diff changeset
193 std::string retval;
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
194
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
195 switch (op)
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
196 {
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
197 case op_add:
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
198 retval = "+";
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
199 break;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
200
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
201 case op_sub:
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
202 retval = "-";
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
203 break;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
204
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
205 case op_mul:
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
206 retval = "*";
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
207 break;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
208
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
209 case op_div:
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
210 retval = "/";
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
211 break;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
212
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
213 case op_pow:
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
214 retval = "^";
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
215 break;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
216
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
217 case op_ldiv:
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
218 retval = "\\";
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
219 break;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
220
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
221 case op_lshift:
2903
facd9d10e5c1 [project @ 1997-04-30 03:53:07 by jwe]
jwe
parents: 2891
diff changeset
222 retval = "<<";
facd9d10e5c1 [project @ 1997-04-30 03:53:07 by jwe]
jwe
parents: 2891
diff changeset
223 break;
facd9d10e5c1 [project @ 1997-04-30 03:53:07 by jwe]
jwe
parents: 2891
diff changeset
224
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
225 case op_rshift:
2903
facd9d10e5c1 [project @ 1997-04-30 03:53:07 by jwe]
jwe
parents: 2891
diff changeset
226 retval = ">>";
facd9d10e5c1 [project @ 1997-04-30 03:53:07 by jwe]
jwe
parents: 2891
diff changeset
227 break;
facd9d10e5c1 [project @ 1997-04-30 03:53:07 by jwe]
jwe
parents: 2891
diff changeset
228
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
229 case op_lt:
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
230 retval = "<";
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
231 break;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
232
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
233 case op_le:
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
234 retval = "<=";
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
235 break;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
236
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
237 case op_eq:
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
238 retval = "==";
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
239 break;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
240
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
241 case op_ge:
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
242 retval = ">=";
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
243 break;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
244
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
245 case op_gt:
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
246 retval = ">";
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
247 break;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
248
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
249 case op_ne:
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
250 retval = "!=";
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
251 break;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
252
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
253 case op_el_mul:
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
254 retval = ".*";
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
255 break;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
256
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
257 case op_el_div:
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
258 retval = "./";
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
259 break;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
260
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
261 case op_el_pow:
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
262 retval = ".^";
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
263 break;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
264
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
265 case op_el_ldiv:
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
266 retval = ".\\";
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
267 break;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
268
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
269 case op_el_and:
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
270 retval = "&";
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
271 break;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
272
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
273 case op_el_or:
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
274 retval = "|";
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
275 break;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
276
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
277 case op_struct_ref:
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
278 retval = ".";
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
279 break;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
280
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
281 default:
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
282 retval = "<unknown>";
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
283 }
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
284
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
285 return retval;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
286 }
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
287
3536
e8fbc8c3d6d9 [project @ 2000-02-02 12:01:00 by jwe]
jwe
parents: 3534
diff changeset
288 std::string
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
289 octave_value::binary_op_fcn_name (binary_op op)
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
290 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
291 std::string retval;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
292
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
293 switch (op)
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
294 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
295 case op_add:
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
296 retval = "plus";
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
297 break;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
298
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
299 case op_sub:
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
300 retval = "minus";
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
301 break;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
302
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
303 case op_mul:
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
304 retval = "mtimes";
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
305 break;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
306
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
307 case op_div:
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
308 retval = "mrdivide";
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
309 break;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
310
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
311 case op_pow:
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
312 retval = "mpower";
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
313 break;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
314
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
315 case op_ldiv:
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
316 retval = "mldivide";
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
317 break;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
318
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
319 case op_lt:
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
320 retval = "lt";
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
321 break;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
322
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
323 case op_le:
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
324 retval = "le";
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
325 break;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
326
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
327 case op_eq:
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
328 retval = "eq";
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
329 break;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
330
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
331 case op_ge:
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
332 retval = "ge";
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
333 break;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
334
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
335 case op_gt:
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
336 retval = "gt";
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
337 break;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
338
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
339 case op_ne:
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
340 retval = "ne";
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
341 break;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
342
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
343 case op_el_mul:
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
344 retval = "times";
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
345 break;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
346
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
347 case op_el_div:
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
348 retval = "rdivide";
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
349 break;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
350
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
351 case op_el_pow:
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
352 retval = "power";
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
353 break;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
354
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
355 case op_el_ldiv:
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
356 retval = "ldivide";
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
357 break;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
358
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
359 case op_el_and:
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
360 retval = "and";
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
361 break;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
362
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
363 case op_el_or:
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
364 retval = "or";
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
365 break;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
366
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
367 default:
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
368 break;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
369 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
370
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
371 return retval;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
372 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
373
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
374 std::string
7800
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
375 octave_value::binary_op_fcn_name (compound_binary_op op)
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
376 {
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
377 std::string retval;
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
378
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
379 switch (op)
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
380 {
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
381 case op_trans_mul:
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
382 retval = "transtimes";
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
383 break;
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
384
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
385 case op_mul_trans:
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
386 retval = "timestrans";
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
387 break;
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
388
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
389 case op_herm_mul:
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
390 retval = "hermtimes";
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
391 break;
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
392
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
393 case op_mul_herm:
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
394 retval = "timesherm";
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
395 break;
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
396
9661
afcf852256d2 optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 9608
diff changeset
397 case op_trans_ldiv:
afcf852256d2 optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 9608
diff changeset
398 retval = "transldiv";
afcf852256d2 optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 9608
diff changeset
399 break;
afcf852256d2 optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 9608
diff changeset
400
afcf852256d2 optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 9608
diff changeset
401 case op_herm_ldiv:
afcf852256d2 optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 9608
diff changeset
402 retval = "hermldiv";
afcf852256d2 optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 9608
diff changeset
403 break;
afcf852256d2 optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 9608
diff changeset
404
8982
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
405 case op_el_and_not:
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
406 retval = "andnot";
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
407 break;
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
408
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
409 case op_el_or_not:
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
410 retval = "ornot";
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
411 break;
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
412
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
413 case op_el_not_and:
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
414 retval = "notand";
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
415 break;
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
416
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
417 case op_el_not_or:
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
418 retval = "notor";
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
419 break;
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
420
7800
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
421 default:
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
422 break;
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
423 }
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
424
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
425 return retval;
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
426 }
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
427
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
428 std::string
2880
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
429 octave_value::assign_op_as_string (assign_op op)
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
430 {
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3465
diff changeset
431 std::string retval;
2880
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
432
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
433 switch (op)
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
434 {
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
435 case op_asn_eq:
2880
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
436 retval = "=";
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
437 break;
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
438
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
439 case op_add_eq:
2880
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
440 retval = "+=";
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
441 break;
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
442
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
443 case op_sub_eq:
2880
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
444 retval = "-=";
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
445 break;
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
446
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
447 case op_mul_eq:
2880
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
448 retval = "*=";
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
449 break;
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
450
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
451 case op_div_eq:
2880
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
452 retval = "/=";
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
453 break;
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
454
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
455 case op_ldiv_eq:
3204
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
456 retval = "\\=";
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
457 break;
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
458
4018
a8621d87fbf5 [project @ 2002-08-05 03:17:25 by jwe]
jwe
parents: 4005
diff changeset
459 case op_pow_eq:
a8621d87fbf5 [project @ 2002-08-05 03:17:25 by jwe]
jwe
parents: 4005
diff changeset
460 retval = "^=";
a8621d87fbf5 [project @ 2002-08-05 03:17:25 by jwe]
jwe
parents: 4005
diff changeset
461 break;
a8621d87fbf5 [project @ 2002-08-05 03:17:25 by jwe]
jwe
parents: 4005
diff changeset
462
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
463 case op_lshift_eq:
2903
facd9d10e5c1 [project @ 1997-04-30 03:53:07 by jwe]
jwe
parents: 2891
diff changeset
464 retval = "<<=";
facd9d10e5c1 [project @ 1997-04-30 03:53:07 by jwe]
jwe
parents: 2891
diff changeset
465 break;
facd9d10e5c1 [project @ 1997-04-30 03:53:07 by jwe]
jwe
parents: 2891
diff changeset
466
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
467 case op_rshift_eq:
2903
facd9d10e5c1 [project @ 1997-04-30 03:53:07 by jwe]
jwe
parents: 2891
diff changeset
468 retval = ">>=";
facd9d10e5c1 [project @ 1997-04-30 03:53:07 by jwe]
jwe
parents: 2891
diff changeset
469 break;
facd9d10e5c1 [project @ 1997-04-30 03:53:07 by jwe]
jwe
parents: 2891
diff changeset
470
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
471 case op_el_mul_eq:
2880
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
472 retval = ".*=";
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
473 break;
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
474
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
475 case op_el_div_eq:
2880
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
476 retval = "./=";
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
477 break;
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
478
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
479 case op_el_ldiv_eq:
3204
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
480 retval = ".\\=";
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
481 break;
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
482
4018
a8621d87fbf5 [project @ 2002-08-05 03:17:25 by jwe]
jwe
parents: 4005
diff changeset
483 case op_el_pow_eq:
a8621d87fbf5 [project @ 2002-08-05 03:17:25 by jwe]
jwe
parents: 4005
diff changeset
484 retval = ".^=";
a8621d87fbf5 [project @ 2002-08-05 03:17:25 by jwe]
jwe
parents: 4005
diff changeset
485 break;
a8621d87fbf5 [project @ 2002-08-05 03:17:25 by jwe]
jwe
parents: 4005
diff changeset
486
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
487 case op_el_and_eq:
2880
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
488 retval = "&=";
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
489 break;
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
490
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
491 case op_el_or_eq:
2880
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
492 retval = "|=";
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
493 break;
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
494
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
495 default:
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
496 retval = "<unknown>";
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
497 }
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
498
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
499 return retval;
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
500 }
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
501
15140
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
502 octave_value::binary_op
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
503 octave_value::assign_op_to_binary_op (assign_op op)
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
504 {
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
505 switch (op)
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
506 {
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
507 case op_add_eq:
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
508 return op_add;
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
509 case op_sub_eq:
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
510 return op_sub;
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
511 case op_mul_eq:
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
512 return op_mul;
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
513 case op_div_eq:
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
514 return op_div;
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
515 case op_ldiv_eq:
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
516 return op_ldiv;
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
517 case op_pow_eq:
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
518 return op_pow;
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
519 case op_lshift_eq:
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
520 return op_lshift;
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
521 case op_rshift_eq:
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
522 return op_rshift;
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
523 case op_el_mul_eq:
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
524 return op_el_mul;
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
525 case op_el_div_eq:
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
526 return op_el_div;
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
527 case op_el_ldiv_eq:
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
528 return op_el_ldiv;
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
529 case op_el_pow_eq:
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
530 return op_el_pow;
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
531 case op_el_and_eq:
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
532 return op_el_and;
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
533 case op_el_or_eq:
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
534 return op_el_or;
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
535 default:
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
536 return unknown_binary_op;
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
537 }
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
538
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
539 }
6ea86e1d0f5f Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents: 15057
diff changeset
540
9607
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
541 octave_value::assign_op
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
542 octave_value::binary_op_to_assign_op (binary_op op)
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
543 {
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
544 assign_op retval;
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
545
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
546 switch (op)
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
547 {
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
548 case op_add:
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
549 retval = op_add_eq;
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
550 break;
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
551 case op_sub:
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
552 retval = op_sub_eq;
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
553 break;
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
554 case op_mul:
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
555 retval = op_mul_eq;
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
556 break;
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
557 case op_div:
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
558 retval = op_div_eq;
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
559 break;
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
560 case op_el_mul:
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
561 retval = op_el_mul_eq;
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
562 break;
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
563 case op_el_div:
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
564 retval = op_el_div_eq;
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
565 break;
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
566 case op_el_and:
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
567 retval = op_el_and_eq;
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
568 break;
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
569 case op_el_or:
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
570 retval = op_el_or_eq;
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
571 break;
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
572 default:
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
573 retval = unknown_assign_op;
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
574 }
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
575
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
576 return retval;
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
577 }
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
578
4254
df5f2e433a11 [project @ 2002-12-31 19:43:07 by jwe]
jwe
parents: 4247
diff changeset
579 octave_value::octave_value (short int i)
df5f2e433a11 [project @ 2002-12-31 19:43:07 by jwe]
jwe
parents: 4247
diff changeset
580 : rep (new octave_scalar (i))
df5f2e433a11 [project @ 2002-12-31 19:43:07 by jwe]
jwe
parents: 4247
diff changeset
581 {
df5f2e433a11 [project @ 2002-12-31 19:43:07 by jwe]
jwe
parents: 4247
diff changeset
582 }
df5f2e433a11 [project @ 2002-12-31 19:43:07 by jwe]
jwe
parents: 4247
diff changeset
583
df5f2e433a11 [project @ 2002-12-31 19:43:07 by jwe]
jwe
parents: 4247
diff changeset
584 octave_value::octave_value (unsigned short int i)
df5f2e433a11 [project @ 2002-12-31 19:43:07 by jwe]
jwe
parents: 4247
diff changeset
585 : rep (new octave_scalar (i))
df5f2e433a11 [project @ 2002-12-31 19:43:07 by jwe]
jwe
parents: 4247
diff changeset
586 {
df5f2e433a11 [project @ 2002-12-31 19:43:07 by jwe]
jwe
parents: 4247
diff changeset
587 }
df5f2e433a11 [project @ 2002-12-31 19:43:07 by jwe]
jwe
parents: 4247
diff changeset
588
4233
ccfdb55c8156 [project @ 2002-12-20 22:43:54 by jwe]
jwe
parents: 4219
diff changeset
589 octave_value::octave_value (int i)
ccfdb55c8156 [project @ 2002-12-20 22:43:54 by jwe]
jwe
parents: 4219
diff changeset
590 : rep (new octave_scalar (i))
ccfdb55c8156 [project @ 2002-12-20 22:43:54 by jwe]
jwe
parents: 4219
diff changeset
591 {
ccfdb55c8156 [project @ 2002-12-20 22:43:54 by jwe]
jwe
parents: 4219
diff changeset
592 }
ccfdb55c8156 [project @ 2002-12-20 22:43:54 by jwe]
jwe
parents: 4219
diff changeset
593
4254
df5f2e433a11 [project @ 2002-12-31 19:43:07 by jwe]
jwe
parents: 4247
diff changeset
594 octave_value::octave_value (unsigned int i)
df5f2e433a11 [project @ 2002-12-31 19:43:07 by jwe]
jwe
parents: 4247
diff changeset
595 : rep (new octave_scalar (i))
df5f2e433a11 [project @ 2002-12-31 19:43:07 by jwe]
jwe
parents: 4247
diff changeset
596 {
df5f2e433a11 [project @ 2002-12-31 19:43:07 by jwe]
jwe
parents: 4247
diff changeset
597 }
df5f2e433a11 [project @ 2002-12-31 19:43:07 by jwe]
jwe
parents: 4247
diff changeset
598
df5f2e433a11 [project @ 2002-12-31 19:43:07 by jwe]
jwe
parents: 4247
diff changeset
599 octave_value::octave_value (long int i)
df5f2e433a11 [project @ 2002-12-31 19:43:07 by jwe]
jwe
parents: 4247
diff changeset
600 : rep (new octave_scalar (i))
df5f2e433a11 [project @ 2002-12-31 19:43:07 by jwe]
jwe
parents: 4247
diff changeset
601 {
df5f2e433a11 [project @ 2002-12-31 19:43:07 by jwe]
jwe
parents: 4247
diff changeset
602 }
df5f2e433a11 [project @ 2002-12-31 19:43:07 by jwe]
jwe
parents: 4247
diff changeset
603
df5f2e433a11 [project @ 2002-12-31 19:43:07 by jwe]
jwe
parents: 4247
diff changeset
604 octave_value::octave_value (unsigned long int i)
df5f2e433a11 [project @ 2002-12-31 19:43:07 by jwe]
jwe
parents: 4247
diff changeset
605 : rep (new octave_scalar (i))
df5f2e433a11 [project @ 2002-12-31 19:43:07 by jwe]
jwe
parents: 4247
diff changeset
606 {
df5f2e433a11 [project @ 2002-12-31 19:43:07 by jwe]
jwe
parents: 4247
diff changeset
607 }
df5f2e433a11 [project @ 2002-12-31 19:43:07 by jwe]
jwe
parents: 4247
diff changeset
608
4353
ea4b8c35ac9d [project @ 2003-02-21 21:04:41 by jwe]
jwe
parents: 4346
diff changeset
609 #if defined (HAVE_LONG_LONG_INT)
ea4b8c35ac9d [project @ 2003-02-21 21:04:41 by jwe]
jwe
parents: 4346
diff changeset
610 octave_value::octave_value (long long int i)
ea4b8c35ac9d [project @ 2003-02-21 21:04:41 by jwe]
jwe
parents: 4346
diff changeset
611 : rep (new octave_scalar (i))
ea4b8c35ac9d [project @ 2003-02-21 21:04:41 by jwe]
jwe
parents: 4346
diff changeset
612 {
ea4b8c35ac9d [project @ 2003-02-21 21:04:41 by jwe]
jwe
parents: 4346
diff changeset
613 }
ea4b8c35ac9d [project @ 2003-02-21 21:04:41 by jwe]
jwe
parents: 4346
diff changeset
614 #endif
ea4b8c35ac9d [project @ 2003-02-21 21:04:41 by jwe]
jwe
parents: 4346
diff changeset
615
4355
6fa0c2306ef6 [project @ 2003-02-22 00:37:10 by jwe]
jwe
parents: 4353
diff changeset
616 #if defined (HAVE_UNSIGNED_LONG_LONG_INT)
4353
ea4b8c35ac9d [project @ 2003-02-21 21:04:41 by jwe]
jwe
parents: 4346
diff changeset
617 octave_value::octave_value (unsigned long long int i)
ea4b8c35ac9d [project @ 2003-02-21 21:04:41 by jwe]
jwe
parents: 4346
diff changeset
618 : rep (new octave_scalar (i))
ea4b8c35ac9d [project @ 2003-02-21 21:04:41 by jwe]
jwe
parents: 4346
diff changeset
619 {
ea4b8c35ac9d [project @ 2003-02-21 21:04:41 by jwe]
jwe
parents: 4346
diff changeset
620 }
ea4b8c35ac9d [project @ 2003-02-21 21:04:41 by jwe]
jwe
parents: 4346
diff changeset
621 #endif
ea4b8c35ac9d [project @ 2003-02-21 21:04:41 by jwe]
jwe
parents: 4346
diff changeset
622
4254
df5f2e433a11 [project @ 2002-12-31 19:43:07 by jwe]
jwe
parents: 4247
diff changeset
623 octave_value::octave_value (octave_time t)
7065
97db94ae2cf0 [project @ 2007-10-25 05:50:55 by jwe]
jwe
parents: 7064
diff changeset
624 : rep (new octave_scalar (t.double_value ()))
4254
df5f2e433a11 [project @ 2002-12-31 19:43:07 by jwe]
jwe
parents: 4247
diff changeset
625 {
df5f2e433a11 [project @ 2002-12-31 19:43:07 by jwe]
jwe
parents: 4247
diff changeset
626 }
df5f2e433a11 [project @ 2002-12-31 19:43:07 by jwe]
jwe
parents: 4247
diff changeset
627
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
628 octave_value::octave_value (double d)
2825
60ae49e1284f [project @ 1997-03-25 23:17:36 by jwe]
jwe
parents: 2800
diff changeset
629 : rep (new octave_scalar (d))
60ae49e1284f [project @ 1997-03-25 23:17:36 by jwe]
jwe
parents: 2800
diff changeset
630 {
60ae49e1284f [project @ 1997-03-25 23:17:36 by jwe]
jwe
parents: 2800
diff changeset
631 }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
632
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
633 octave_value::octave_value (float d)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
634 : rep (new octave_float_scalar (d))
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
635 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
636 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
637
4587
7b957b442818 [project @ 2003-11-10 15:50:39 by jwe]
jwe
parents: 4584
diff changeset
638 octave_value::octave_value (const Cell& c, bool is_csl)
5477
9e59c91ddc99 [project @ 2005-09-30 05:26:38 by jwe]
jwe
parents: 5354
diff changeset
639 : rep (is_csl
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
640 ? dynamic_cast<octave_base_value *> (new octave_cs_list (c))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
641 : dynamic_cast<octave_base_value *> (new octave_cell (c)))
3351
8623649c967c [project @ 1999-11-15 16:17:01 by jwe]
jwe
parents: 3340
diff changeset
642 {
8623649c967c [project @ 1999-11-15 16:17:01 by jwe]
jwe
parents: 3340
diff changeset
643 }
8623649c967c [project @ 1999-11-15 16:17:01 by jwe]
jwe
parents: 3340
diff changeset
644
9732
b4fdfee405b5 remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9728
diff changeset
645 octave_value::octave_value (const Array<octave_value>& a, bool is_csl)
5477
9e59c91ddc99 [project @ 2005-09-30 05:26:38 by jwe]
jwe
parents: 5354
diff changeset
646 : rep (is_csl
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
647 ? dynamic_cast<octave_base_value *> (new octave_cs_list (Cell (a)))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
648 : dynamic_cast<octave_base_value *> (new octave_cell (Cell (a))))
5147
47e4c91e5799 [project @ 2005-02-16 21:06:19 by jwe]
jwe
parents: 5146
diff changeset
649 {
47e4c91e5799 [project @ 2005-02-16 21:06:19 by jwe]
jwe
parents: 5146
diff changeset
650 }
47e4c91e5799 [project @ 2005-02-16 21:06:19 by jwe]
jwe
parents: 5146
diff changeset
651
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5781
diff changeset
652 octave_value::octave_value (const Matrix& m, const MatrixType& t)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5781
diff changeset
653 : rep (new octave_matrix (m, t))
2423
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
654 {
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
655 maybe_mutate ();
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
656 }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
657
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
658 octave_value::octave_value (const FloatMatrix& m, const MatrixType& t)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
659 : rep (new octave_float_matrix (m, t))
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
660 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
661 maybe_mutate ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
662 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
663
4507
65f47f8a92a2 [project @ 2003-09-10 15:48:02 by jwe]
jwe
parents: 4505
diff changeset
664 octave_value::octave_value (const NDArray& a)
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4507
diff changeset
665 : rep (new octave_matrix (a))
4478
7afd4bf05aa8 [project @ 2003-07-30 19:15:31 by jwe]
jwe
parents: 4461
diff changeset
666 {
7afd4bf05aa8 [project @ 2003-07-30 19:15:31 by jwe]
jwe
parents: 4461
diff changeset
667 maybe_mutate ();
7afd4bf05aa8 [project @ 2003-07-30 19:15:31 by jwe]
jwe
parents: 4461
diff changeset
668 }
7afd4bf05aa8 [project @ 2003-07-30 19:15:31 by jwe]
jwe
parents: 4461
diff changeset
669
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
670 octave_value::octave_value (const FloatNDArray& a)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
671 : rep (new octave_float_matrix (a))
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
672 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
673 maybe_mutate ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
674 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
675
9732
b4fdfee405b5 remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9728
diff changeset
676 octave_value::octave_value (const Array<double>& a)
4911
14027e0bafa4 [project @ 2004-07-22 19:58:06 by jwe]
jwe
parents: 4901
diff changeset
677 : rep (new octave_matrix (a))
14027e0bafa4 [project @ 2004-07-22 19:58:06 by jwe]
jwe
parents: 4901
diff changeset
678 {
14027e0bafa4 [project @ 2004-07-22 19:58:06 by jwe]
jwe
parents: 4901
diff changeset
679 maybe_mutate ();
14027e0bafa4 [project @ 2004-07-22 19:58:06 by jwe]
jwe
parents: 4901
diff changeset
680 }
14027e0bafa4 [project @ 2004-07-22 19:58:06 by jwe]
jwe
parents: 4901
diff changeset
681
9732
b4fdfee405b5 remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9728
diff changeset
682 octave_value::octave_value (const Array<float>& a)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
683 : rep (new octave_float_matrix (a))
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
684 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
685 maybe_mutate ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
686 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
687
15428
fd5c0159b588 Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
688 octave_value::octave_value (const DiagArray2<double>& d)
19425
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
689 : rep (Vdisable_diagonal_matrix
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
690 ? dynamic_cast<octave_base_value *> (new octave_matrix (Matrix (d)))
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
691 : dynamic_cast<octave_base_value *> (new octave_diag_matrix (d)))
15428
fd5c0159b588 Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
692 {
fd5c0159b588 Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
693 maybe_mutate ();
fd5c0159b588 Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
694 }
fd5c0159b588 Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
695
fd5c0159b588 Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
696 octave_value::octave_value (const DiagArray2<float>& d)
19425
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
697 : rep (Vdisable_diagonal_matrix
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
698 ? dynamic_cast<octave_base_value *> (new octave_float_matrix (FloatMatrix (d)))
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
699 : dynamic_cast<octave_base_value *> (new octave_float_diag_matrix (d)))
15428
fd5c0159b588 Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
700 {
fd5c0159b588 Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
701 maybe_mutate ();
fd5c0159b588 Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
702 }
fd5c0159b588 Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
703
fd5c0159b588 Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
704 octave_value::octave_value (const DiagArray2<Complex>& d)
19425
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
705 : rep (Vdisable_diagonal_matrix
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
706 ? dynamic_cast<octave_base_value *> (new octave_complex_matrix (ComplexMatrix (d)))
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
707 : dynamic_cast<octave_base_value *> (new octave_complex_diag_matrix (d)))
15428
fd5c0159b588 Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
708 {
fd5c0159b588 Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
709 maybe_mutate ();
fd5c0159b588 Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
710 }
fd5c0159b588 Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
711
fd5c0159b588 Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
712 octave_value::octave_value (const DiagArray2<FloatComplex>& d)
19425
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
713 : rep (Vdisable_diagonal_matrix
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
714 ? dynamic_cast<octave_base_value *> (new octave_float_complex_matrix (FloatComplexMatrix (d)))
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
715 : dynamic_cast<octave_base_value *> (new octave_float_complex_diag_matrix (d)))
15428
fd5c0159b588 Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
716 {
fd5c0159b588 Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
717 maybe_mutate ();
fd5c0159b588 Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
718 }
fd5c0159b588 Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
719
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
720 octave_value::octave_value (const DiagMatrix& d)
19425
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
721 : rep (Vdisable_diagonal_matrix
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
722 ? dynamic_cast<octave_base_value *> (new octave_matrix (Matrix (d)))
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
723 : dynamic_cast<octave_base_value *> (new octave_diag_matrix (d)))
2423
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
724 {
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
725 maybe_mutate ();
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
726 }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
727
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
728 octave_value::octave_value (const FloatDiagMatrix& d)
19425
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
729 : rep (Vdisable_diagonal_matrix
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
730 ? dynamic_cast<octave_base_value *> (new octave_float_matrix (FloatMatrix (d)))
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
731 : dynamic_cast<octave_base_value *> (new octave_float_diag_matrix (d)))
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
732 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
733 maybe_mutate ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
734 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
735
3418
ca92c9d3f882 [project @ 2000-01-12 03:07:47 by jwe]
jwe
parents: 3373
diff changeset
736 octave_value::octave_value (const RowVector& v)
ca92c9d3f882 [project @ 2000-01-12 03:07:47 by jwe]
jwe
parents: 3373
diff changeset
737 : rep (new octave_matrix (v))
2423
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
738 {
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
739 maybe_mutate ();
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
740 }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
741
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
742 octave_value::octave_value (const FloatRowVector& v)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
743 : rep (new octave_float_matrix (v))
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
744 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
745 maybe_mutate ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
746 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
747
3418
ca92c9d3f882 [project @ 2000-01-12 03:07:47 by jwe]
jwe
parents: 3373
diff changeset
748 octave_value::octave_value (const ColumnVector& v)
ca92c9d3f882 [project @ 2000-01-12 03:07:47 by jwe]
jwe
parents: 3373
diff changeset
749 : rep (new octave_matrix (v))
2423
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
750 {
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
751 maybe_mutate ();
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
752 }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
753
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
754 octave_value::octave_value (const FloatColumnVector& v)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
755 : rep (new octave_float_matrix (v))
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
756 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
757 maybe_mutate ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
758 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
759
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
760 octave_value::octave_value (const Complex& C)
2423
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
761 : rep (new octave_complex (C))
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
762 {
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
763 maybe_mutate ();
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
764 }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
765
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
766 octave_value::octave_value (const FloatComplex& C)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
767 : rep (new octave_float_complex (C))
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
768 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
769 maybe_mutate ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
770 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
771
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5781
diff changeset
772 octave_value::octave_value (const ComplexMatrix& m, const MatrixType& t)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5781
diff changeset
773 : rep (new octave_complex_matrix (m, t))
2423
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
774 {
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
775 maybe_mutate ();
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
776 }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
777
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
778 octave_value::octave_value (const FloatComplexMatrix& m, const MatrixType& t)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
779 : rep (new octave_float_complex_matrix (m, t))
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
780 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
781 maybe_mutate ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
782 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
783
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4507
diff changeset
784 octave_value::octave_value (const ComplexNDArray& a)
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4507
diff changeset
785 : rep (new octave_complex_matrix (a))
4478
7afd4bf05aa8 [project @ 2003-07-30 19:15:31 by jwe]
jwe
parents: 4461
diff changeset
786 {
7afd4bf05aa8 [project @ 2003-07-30 19:15:31 by jwe]
jwe
parents: 4461
diff changeset
787 maybe_mutate ();
7afd4bf05aa8 [project @ 2003-07-30 19:15:31 by jwe]
jwe
parents: 4461
diff changeset
788 }
7afd4bf05aa8 [project @ 2003-07-30 19:15:31 by jwe]
jwe
parents: 4461
diff changeset
789
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
790 octave_value::octave_value (const FloatComplexNDArray& a)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
791 : rep (new octave_float_complex_matrix (a))
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
792 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
793 maybe_mutate ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
794 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
795
9732
b4fdfee405b5 remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9728
diff changeset
796 octave_value::octave_value (const Array<Complex>& a)
4911
14027e0bafa4 [project @ 2004-07-22 19:58:06 by jwe]
jwe
parents: 4901
diff changeset
797 : rep (new octave_complex_matrix (a))
14027e0bafa4 [project @ 2004-07-22 19:58:06 by jwe]
jwe
parents: 4901
diff changeset
798 {
14027e0bafa4 [project @ 2004-07-22 19:58:06 by jwe]
jwe
parents: 4901
diff changeset
799 maybe_mutate ();
14027e0bafa4 [project @ 2004-07-22 19:58:06 by jwe]
jwe
parents: 4901
diff changeset
800 }
14027e0bafa4 [project @ 2004-07-22 19:58:06 by jwe]
jwe
parents: 4901
diff changeset
801
9732
b4fdfee405b5 remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9728
diff changeset
802 octave_value::octave_value (const Array<FloatComplex>& a)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
803 : rep (new octave_float_complex_matrix (a))
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
804 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
805 maybe_mutate ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
806 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
807
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
808 octave_value::octave_value (const ComplexDiagMatrix& d)
19425
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
809 : rep (Vdisable_diagonal_matrix
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
810 ? dynamic_cast<octave_base_value *> (new octave_complex_matrix (ComplexMatrix (d)))
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
811 : dynamic_cast<octave_base_value *> (new octave_complex_diag_matrix (d)))
2423
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
812 {
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
813 maybe_mutate ();
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
814 }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
815
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
816 octave_value::octave_value (const FloatComplexDiagMatrix& d)
19425
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
817 : rep (Vdisable_diagonal_matrix
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
818 ? dynamic_cast<octave_base_value *> (new octave_float_complex_matrix (FloatComplexMatrix (d)))
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
819 : dynamic_cast<octave_base_value *> (new octave_float_complex_diag_matrix (d)))
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
820 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
821 maybe_mutate ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
822 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
823
3418
ca92c9d3f882 [project @ 2000-01-12 03:07:47 by jwe]
jwe
parents: 3373
diff changeset
824 octave_value::octave_value (const ComplexRowVector& v)
ca92c9d3f882 [project @ 2000-01-12 03:07:47 by jwe]
jwe
parents: 3373
diff changeset
825 : rep (new octave_complex_matrix (v))
2423
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
826 {
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
827 maybe_mutate ();
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
828 }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
829
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
830 octave_value::octave_value (const FloatComplexRowVector& v)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
831 : rep (new octave_float_complex_matrix (v))
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
832 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
833 maybe_mutate ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
834 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
835
3418
ca92c9d3f882 [project @ 2000-01-12 03:07:47 by jwe]
jwe
parents: 3373
diff changeset
836 octave_value::octave_value (const ComplexColumnVector& v)
ca92c9d3f882 [project @ 2000-01-12 03:07:47 by jwe]
jwe
parents: 3373
diff changeset
837 : rep (new octave_complex_matrix (v))
2423
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
838 {
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
839 maybe_mutate ();
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
840 }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
841
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
842 octave_value::octave_value (const FloatComplexColumnVector& v)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
843 : rep (new octave_float_complex_matrix (v))
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
844 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
845 maybe_mutate ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
846 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
847
8960
93f18f166aba remove float perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
848 octave_value::octave_value (const PermMatrix& p)
19425
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
849 : rep (Vdisable_permutation_matrix
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
850 ? dynamic_cast<octave_base_value *> (new octave_matrix (Matrix (p)))
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
851 : dynamic_cast<octave_base_value *> (new octave_perm_matrix (p)))
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
852 {
8960
93f18f166aba remove float perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
853 maybe_mutate ();
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
854 }
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
855
2825
60ae49e1284f [project @ 1997-03-25 23:17:36 by jwe]
jwe
parents: 2800
diff changeset
856 octave_value::octave_value (bool b)
60ae49e1284f [project @ 1997-03-25 23:17:36 by jwe]
jwe
parents: 2800
diff changeset
857 : rep (new octave_bool (b))
60ae49e1284f [project @ 1997-03-25 23:17:36 by jwe]
jwe
parents: 2800
diff changeset
858 {
60ae49e1284f [project @ 1997-03-25 23:17:36 by jwe]
jwe
parents: 2800
diff changeset
859 }
60ae49e1284f [project @ 1997-03-25 23:17:36 by jwe]
jwe
parents: 2800
diff changeset
860
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5781
diff changeset
861 octave_value::octave_value (const boolMatrix& bm, const MatrixType& t)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5781
diff changeset
862 : rep (new octave_bool_matrix (bm, t))
2825
60ae49e1284f [project @ 1997-03-25 23:17:36 by jwe]
jwe
parents: 2800
diff changeset
863 {
60ae49e1284f [project @ 1997-03-25 23:17:36 by jwe]
jwe
parents: 2800
diff changeset
864 maybe_mutate ();
60ae49e1284f [project @ 1997-03-25 23:17:36 by jwe]
jwe
parents: 2800
diff changeset
865 }
60ae49e1284f [project @ 1997-03-25 23:17:36 by jwe]
jwe
parents: 2800
diff changeset
866
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4507
diff changeset
867 octave_value::octave_value (const boolNDArray& bnda)
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4507
diff changeset
868 : rep (new octave_bool_matrix (bnda))
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4507
diff changeset
869 {
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4507
diff changeset
870 maybe_mutate ();
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4507
diff changeset
871 }
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4507
diff changeset
872
9732
b4fdfee405b5 remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9728
diff changeset
873 octave_value::octave_value (const Array<bool>& bnda)
7433
402168152bb9 [project @ 2008-01-31 18:59:09 by dbateman]
dbateman
parents: 7336
diff changeset
874 : rep (new octave_bool_matrix (bnda))
402168152bb9 [project @ 2008-01-31 18:59:09 by dbateman]
dbateman
parents: 7336
diff changeset
875 {
402168152bb9 [project @ 2008-01-31 18:59:09 by dbateman]
dbateman
parents: 7336
diff changeset
876 maybe_mutate ();
402168152bb9 [project @ 2008-01-31 18:59:09 by dbateman]
dbateman
parents: 7336
diff changeset
877 }
402168152bb9 [project @ 2008-01-31 18:59:09 by dbateman]
dbateman
parents: 7336
diff changeset
878
5279
bd32f770c09a [project @ 2005-04-12 21:55:31 by jwe]
jwe
parents: 5275
diff changeset
879 octave_value::octave_value (char c, char type)
bd32f770c09a [project @ 2005-04-12 21:55:31 by jwe]
jwe
parents: 5275
diff changeset
880 : rep (type == '"'
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
881 ? new octave_char_matrix_dq_str (c)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
882 : new octave_char_matrix_sq_str (c))
3189
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3018
diff changeset
883 {
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3018
diff changeset
884 maybe_mutate ();
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3018
diff changeset
885 }
bef7b73c0724 [project @ 1998-10-16 18:05:26 by jwe]
jwe
parents: 3018
diff changeset
886
5279
bd32f770c09a [project @ 2005-04-12 21:55:31 by jwe]
jwe
parents: 5275
diff changeset
887 octave_value::octave_value (const char *s, char type)
bd32f770c09a [project @ 2005-04-12 21:55:31 by jwe]
jwe
parents: 5275
diff changeset
888 : rep (type == '"'
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
889 ? new octave_char_matrix_dq_str (s)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
890 : new octave_char_matrix_sq_str (s))
2423
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
891 {
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
892 maybe_mutate ();
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
893 }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
894
5279
bd32f770c09a [project @ 2005-04-12 21:55:31 by jwe]
jwe
parents: 5275
diff changeset
895 octave_value::octave_value (const std::string& s, char type)
bd32f770c09a [project @ 2005-04-12 21:55:31 by jwe]
jwe
parents: 5275
diff changeset
896 : rep (type == '"'
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
897 ? new octave_char_matrix_dq_str (s)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
898 : new octave_char_matrix_sq_str (s))
2423
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
899 {
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
900 maybe_mutate ();
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
901 }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
902
5279
bd32f770c09a [project @ 2005-04-12 21:55:31 by jwe]
jwe
parents: 5275
diff changeset
903 octave_value::octave_value (const string_vector& s, char type)
bd32f770c09a [project @ 2005-04-12 21:55:31 by jwe]
jwe
parents: 5275
diff changeset
904 : rep (type == '"'
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
905 ? new octave_char_matrix_dq_str (s)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
906 : new octave_char_matrix_sq_str (s))
2423
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
907 {
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
908 maybe_mutate ();
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
909 }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
910
9689
34d6f005db4b eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents: 9661
diff changeset
911 octave_value::octave_value (const charMatrix& chm, char type)
34d6f005db4b eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents: 9661
diff changeset
912 : rep (type == '"'
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
913 ? new octave_char_matrix_dq_str (chm)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
914 : new octave_char_matrix_sq_str (chm))
9689
34d6f005db4b eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents: 9661
diff changeset
915 {
34d6f005db4b eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents: 9661
diff changeset
916 maybe_mutate ();
34d6f005db4b eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents: 9661
diff changeset
917 }
34d6f005db4b eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents: 9661
diff changeset
918
34d6f005db4b eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents: 9661
diff changeset
919 octave_value::octave_value (const charNDArray& chm, char type)
34d6f005db4b eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents: 9661
diff changeset
920 : rep (type == '"'
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
921 ? new octave_char_matrix_dq_str (chm)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
922 : new octave_char_matrix_sq_str (chm))
2409
47e5f57fb4bd [project @ 1996-10-15 16:44:26 by jwe]
jwe
parents: 2376
diff changeset
923 {
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4507
diff changeset
924 maybe_mutate ();
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4507
diff changeset
925 }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
926
9732
b4fdfee405b5 remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9728
diff changeset
927 octave_value::octave_value (const Array<char>& chm, char type)
9689
34d6f005db4b eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents: 9661
diff changeset
928 : rep (type == '"'
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
929 ? new octave_char_matrix_dq_str (chm)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
930 : new octave_char_matrix_sq_str (chm))
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4507
diff changeset
931 {
2423
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
932 maybe_mutate ();
2409
47e5f57fb4bd [project @ 1996-10-15 16:44:26 by jwe]
jwe
parents: 2376
diff changeset
933 }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
934
9689
34d6f005db4b eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents: 9661
diff changeset
935 octave_value::octave_value (const charMatrix& chm, bool, char type)
34d6f005db4b eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents: 9661
diff changeset
936 : rep (type == '"'
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
937 ? new octave_char_matrix_dq_str (chm)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
938 : new octave_char_matrix_sq_str (chm))
9689
34d6f005db4b eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents: 9661
diff changeset
939 {
34d6f005db4b eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents: 9661
diff changeset
940 maybe_mutate ();
34d6f005db4b eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents: 9661
diff changeset
941 }
34d6f005db4b eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents: 9661
diff changeset
942
34d6f005db4b eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents: 9661
diff changeset
943 octave_value::octave_value (const charNDArray& chm, bool, char type)
34d6f005db4b eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents: 9661
diff changeset
944 : rep (type == '"'
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
945 ? new octave_char_matrix_dq_str (chm)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
946 : new octave_char_matrix_sq_str (chm))
9689
34d6f005db4b eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents: 9661
diff changeset
947 {
34d6f005db4b eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents: 9661
diff changeset
948 maybe_mutate ();
34d6f005db4b eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents: 9661
diff changeset
949 }
34d6f005db4b eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents: 9661
diff changeset
950
9732
b4fdfee405b5 remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9728
diff changeset
951 octave_value::octave_value (const Array<char>& chm, bool, char type)
9689
34d6f005db4b eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents: 9661
diff changeset
952 : rep (type == '"'
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
953 ? new octave_char_matrix_dq_str (chm)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
954 : new octave_char_matrix_sq_str (chm))
4997
d117a9fb83be [project @ 2004-09-15 20:49:21 by jwe]
jwe
parents: 4994
diff changeset
955 {
d117a9fb83be [project @ 2004-09-15 20:49:21 by jwe]
jwe
parents: 4994
diff changeset
956 maybe_mutate ();
d117a9fb83be [project @ 2004-09-15 20:49:21 by jwe]
jwe
parents: 4994
diff changeset
957 }
d117a9fb83be [project @ 2004-09-15 20:49:21 by jwe]
jwe
parents: 4994
diff changeset
958
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5781
diff changeset
959 octave_value::octave_value (const SparseMatrix& m, const MatrixType &t)
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5147
diff changeset
960 : rep (new octave_sparse_matrix (m, t))
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5147
diff changeset
961 {
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5147
diff changeset
962 maybe_mutate ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5147
diff changeset
963 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5147
diff changeset
964
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents: 6639
diff changeset
965 octave_value::octave_value (const Sparse<double>& m, const MatrixType &t)
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents: 6639
diff changeset
966 : rep (new octave_sparse_matrix (m, t))
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents: 6639
diff changeset
967 {
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents: 6639
diff changeset
968 maybe_mutate ();
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents: 6639
diff changeset
969 }
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents: 6639
diff changeset
970
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5781
diff changeset
971 octave_value::octave_value (const SparseComplexMatrix& m, const MatrixType &t)
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5147
diff changeset
972 : rep (new octave_sparse_complex_matrix (m, t))
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5147
diff changeset
973 {
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5147
diff changeset
974 maybe_mutate ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5147
diff changeset
975 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5147
diff changeset
976
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents: 6639
diff changeset
977 octave_value::octave_value (const Sparse<Complex>& m, const MatrixType &t)
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents: 6639
diff changeset
978 : rep (new octave_sparse_complex_matrix (m, t))
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents: 6639
diff changeset
979 {
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents: 6639
diff changeset
980 maybe_mutate ();
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents: 6639
diff changeset
981 }
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents: 6639
diff changeset
982
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5781
diff changeset
983 octave_value::octave_value (const SparseBoolMatrix& bm, const MatrixType &t)
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5147
diff changeset
984 : rep (new octave_sparse_bool_matrix (bm, t))
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5147
diff changeset
985 {
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5147
diff changeset
986 maybe_mutate ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5147
diff changeset
987 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5147
diff changeset
988
7433
402168152bb9 [project @ 2008-01-31 18:59:09 by dbateman]
dbateman
parents: 7336
diff changeset
989 octave_value::octave_value (const Sparse<bool>& bm, const MatrixType &t)
402168152bb9 [project @ 2008-01-31 18:59:09 by dbateman]
dbateman
parents: 7336
diff changeset
990 : rep (new octave_sparse_bool_matrix (bm, t))
402168152bb9 [project @ 2008-01-31 18:59:09 by dbateman]
dbateman
parents: 7336
diff changeset
991 {
402168152bb9 [project @ 2008-01-31 18:59:09 by dbateman]
dbateman
parents: 7336
diff changeset
992 maybe_mutate ();
402168152bb9 [project @ 2008-01-31 18:59:09 by dbateman]
dbateman
parents: 7336
diff changeset
993 }
402168152bb9 [project @ 2008-01-31 18:59:09 by dbateman]
dbateman
parents: 7336
diff changeset
994
4901
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
995 octave_value::octave_value (const octave_int8& i)
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
996 : rep (new octave_int8_scalar (i))
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
997 {
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
998 maybe_mutate ();
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
999 }
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1000
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1001 octave_value::octave_value (const octave_uint8& i)
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1002 : rep (new octave_uint8_scalar (i))
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1003 {
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1004 maybe_mutate ();
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1005 }
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1006
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1007 octave_value::octave_value (const octave_int16& i)
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1008 : rep (new octave_int16_scalar (i))
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1009 {
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1010 maybe_mutate ();
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1011 }
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1012
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1013 octave_value::octave_value (const octave_uint16& i)
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1014 : rep (new octave_uint16_scalar (i))
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1015 {
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1016 maybe_mutate ();
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1017 }
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1018
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1019 octave_value::octave_value (const octave_int32& i)
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1020 : rep (new octave_int32_scalar (i))
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1021 {
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1022 maybe_mutate ();
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1023 }
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1024
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1025 octave_value::octave_value (const octave_uint32& i)
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1026 : rep (new octave_uint32_scalar (i))
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1027 {
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1028 maybe_mutate ();
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1029 }
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1030
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1031 octave_value::octave_value (const octave_int64& i)
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1032 : rep (new octave_int64_scalar (i))
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1033 {
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1034 maybe_mutate ();
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1035 }
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1036
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1037 octave_value::octave_value (const octave_uint64& i)
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1038 : rep (new octave_uint64_scalar (i))
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1039 {
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1040 maybe_mutate ();
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1041 }
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1042
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1043 octave_value::octave_value (const int8NDArray& inda)
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1044 : rep (new octave_int8_matrix (inda))
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1045 {
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1046 maybe_mutate ();
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1047 }
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1048
9732
b4fdfee405b5 remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9728
diff changeset
1049 octave_value::octave_value (const Array<octave_int8>& inda)
7064
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1050 : rep (new octave_int8_matrix (inda))
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1051 {
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1052 maybe_mutate ();
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1053 }
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1054
4901
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1055 octave_value::octave_value (const uint8NDArray& inda)
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1056 : rep (new octave_uint8_matrix (inda))
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1057 {
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1058 maybe_mutate ();
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1059 }
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1060
9732
b4fdfee405b5 remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9728
diff changeset
1061 octave_value::octave_value (const Array<octave_uint8>& inda)
7064
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1062 : rep (new octave_uint8_matrix (inda))
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1063 {
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1064 maybe_mutate ();
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1065 }
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1066
4901
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1067 octave_value::octave_value (const int16NDArray& inda)
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1068 : rep (new octave_int16_matrix (inda))
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1069 {
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1070 maybe_mutate ();
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1071 }
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1072
9732
b4fdfee405b5 remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9728
diff changeset
1073 octave_value::octave_value (const Array<octave_int16>& inda)
7064
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1074 : rep (new octave_int16_matrix (inda))
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1075 {
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1076 maybe_mutate ();
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1077 }
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1078
4901
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1079 octave_value::octave_value (const uint16NDArray& inda)
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1080 : rep (new octave_uint16_matrix (inda))
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1081 {
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1082 maybe_mutate ();
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1083 }
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1084
9732
b4fdfee405b5 remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9728
diff changeset
1085 octave_value::octave_value (const Array<octave_uint16>& inda)
7064
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1086 : rep (new octave_uint16_matrix (inda))
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1087 {
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1088 maybe_mutate ();
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1089 }
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1090
4901
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1091 octave_value::octave_value (const int32NDArray& inda)
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1092 : rep (new octave_int32_matrix (inda))
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1093 {
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1094 maybe_mutate ();
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1095 }
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1096
9732
b4fdfee405b5 remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9728
diff changeset
1097 octave_value::octave_value (const Array<octave_int32>& inda)
7064
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1098 : rep (new octave_int32_matrix (inda))
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1099 {
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1100 maybe_mutate ();
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1101 }
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1102
4901
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1103 octave_value::octave_value (const uint32NDArray& inda)
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1104 : rep (new octave_uint32_matrix (inda))
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1105 {
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1106 maybe_mutate ();
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1107 }
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1108
9732
b4fdfee405b5 remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9728
diff changeset
1109 octave_value::octave_value (const Array<octave_uint32>& inda)
7064
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1110 : rep (new octave_uint32_matrix (inda))
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1111 {
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1112 maybe_mutate ();
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1113 }
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1114
4901
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1115 octave_value::octave_value (const int64NDArray& inda)
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1116 : rep (new octave_int64_matrix (inda))
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1117 {
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1118 maybe_mutate ();
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1119 }
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1120
9732
b4fdfee405b5 remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9728
diff changeset
1121 octave_value::octave_value (const Array<octave_int64>& inda)
7064
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1122 : rep (new octave_int64_matrix (inda))
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1123 {
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1124 maybe_mutate ();
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1125 }
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1126
4901
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1127 octave_value::octave_value (const uint64NDArray& inda)
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1128 : rep (new octave_uint64_matrix (inda))
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1129 {
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1130 maybe_mutate ();
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1131 }
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
1132
9732
b4fdfee405b5 remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9728
diff changeset
1133 octave_value::octave_value (const Array<octave_uint64>& inda)
7064
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1134 : rep (new octave_uint64_matrix (inda))
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1135 {
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1136 maybe_mutate ();
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1137 }
faff87ff9d5a [project @ 2007-10-24 21:09:43 by dbateman]
dbateman
parents: 7017
diff changeset
1138
9351
e2344f4af0cb autocache indices returned from find et al.
Jaroslav Hajek <highegg@gmail.com>
parents: 9329
diff changeset
1139 octave_value::octave_value (const Array<octave_idx_type>& inda, bool zero_based,
e2344f4af0cb autocache indices returned from find et al.
Jaroslav Hajek <highegg@gmail.com>
parents: 9329
diff changeset
1140 bool cache_index)
e2344f4af0cb autocache indices returned from find et al.
Jaroslav Hajek <highegg@gmail.com>
parents: 9329
diff changeset
1141 : rep (new octave_matrix (inda, zero_based, cache_index))
e2344f4af0cb autocache indices returned from find et al.
Jaroslav Hajek <highegg@gmail.com>
parents: 9329
diff changeset
1142 {
e2344f4af0cb autocache indices returned from find et al.
Jaroslav Hajek <highegg@gmail.com>
parents: 9329
diff changeset
1143 maybe_mutate ();
e2344f4af0cb autocache indices returned from find et al.
Jaroslav Hajek <highegg@gmail.com>
parents: 9329
diff changeset
1144 }
e2344f4af0cb autocache indices returned from find et al.
Jaroslav Hajek <highegg@gmail.com>
parents: 9329
diff changeset
1145
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
1146 octave_value::octave_value (const idx_vector& idx, bool lazy)
9479
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 9368
diff changeset
1147 : rep ()
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 9368
diff changeset
1148 {
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 9368
diff changeset
1149 double scalar;
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 9368
diff changeset
1150 Range range;
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 9368
diff changeset
1151 NDArray array;
9894
83bd7f34f9da improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 9879
diff changeset
1152 boolNDArray mask;
9479
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 9368
diff changeset
1153 idx_vector::idx_class_type idx_class;
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 9368
diff changeset
1154
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
1155 if (lazy)
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
1156 {
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
1157 // Only make lazy indices out of ranges and index vectors.
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
1158 switch (idx.idx_class ())
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
1159 {
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
1160 case idx_vector::class_range:
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
1161 case idx_vector::class_vector:
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
1162 rep = new octave_lazy_index (idx);
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
1163 maybe_mutate ();
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
1164 return;
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
1165 default:
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
1166 break;
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
1167 }
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
1168 }
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
1169
9894
83bd7f34f9da improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 9879
diff changeset
1170 idx.unconvert (idx_class, scalar, range, array, mask);
9479
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 9368
diff changeset
1171
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 9368
diff changeset
1172 switch (idx_class)
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 9368
diff changeset
1173 {
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 9368
diff changeset
1174 case idx_vector::class_colon:
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 9368
diff changeset
1175 rep = new octave_magic_colon ();
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 9368
diff changeset
1176 break;
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 9368
diff changeset
1177 case idx_vector::class_range:
9894
83bd7f34f9da improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 9879
diff changeset
1178 rep = new octave_range (range, idx);
9479
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 9368
diff changeset
1179 break;
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 9368
diff changeset
1180 case idx_vector::class_scalar:
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 9368
diff changeset
1181 rep = new octave_scalar (scalar);
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 9368
diff changeset
1182 break;
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 9368
diff changeset
1183 case idx_vector::class_vector:
9894
83bd7f34f9da improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 9879
diff changeset
1184 rep = new octave_matrix (array, idx);
83bd7f34f9da improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 9879
diff changeset
1185 break;
83bd7f34f9da improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 9879
diff changeset
1186 case idx_vector::class_mask:
83bd7f34f9da improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 9879
diff changeset
1187 rep = new octave_bool_matrix (mask, idx);
9479
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 9368
diff changeset
1188 break;
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 9368
diff changeset
1189 default:
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 9368
diff changeset
1190 assert (false);
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 9368
diff changeset
1191 break;
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 9368
diff changeset
1192 }
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 9368
diff changeset
1193
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 9368
diff changeset
1194 // FIXME: needed?
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 9368
diff changeset
1195 maybe_mutate ();
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 9368
diff changeset
1196 }
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 9368
diff changeset
1197
9725
aea3a3a950e1 implement nth_element
Jaroslav Hajek <highegg@gmail.com>
parents: 9693
diff changeset
1198 octave_value::octave_value (const Array<std::string>& cellstr)
aea3a3a950e1 implement nth_element
Jaroslav Hajek <highegg@gmail.com>
parents: 9693
diff changeset
1199 : rep (new octave_cell (cellstr))
aea3a3a950e1 implement nth_element
Jaroslav Hajek <highegg@gmail.com>
parents: 9693
diff changeset
1200 {
aea3a3a950e1 implement nth_element
Jaroslav Hajek <highegg@gmail.com>
parents: 9693
diff changeset
1201 maybe_mutate ();
aea3a3a950e1 implement nth_element
Jaroslav Hajek <highegg@gmail.com>
parents: 9693
diff changeset
1202 }
aea3a3a950e1 implement nth_element
Jaroslav Hajek <highegg@gmail.com>
parents: 9693
diff changeset
1203
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1204 octave_value::octave_value (double base, double limit, double inc)
2423
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
1205 : rep (new octave_range (base, limit, inc))
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
1206 {
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
1207 maybe_mutate ();
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
1208 }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1209
19428
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
1210 octave_value::octave_value (const Range& r, bool force_range)
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
1211 : rep (force_range || ! Vdisable_range
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
1212 ? dynamic_cast<octave_base_value *> (new octave_range (r))
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
1213 : dynamic_cast<octave_base_value *> (new octave_matrix (r.matrix_value ())))
2423
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
1214 {
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
1215 maybe_mutate ();
de430cdd9234 [project @ 1996-10-18 20:39:41 by jwe]
jwe
parents: 2413
diff changeset
1216 }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1217
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10687
diff changeset
1218 octave_value::octave_value (const octave_map& m)
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10687
diff changeset
1219 : rep (new octave_struct (m))
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10687
diff changeset
1220 {
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10687
diff changeset
1221 maybe_mutate ();
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10687
diff changeset
1222 }
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10687
diff changeset
1223
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10687
diff changeset
1224 octave_value::octave_value (const octave_scalar_map& m)
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10687
diff changeset
1225 : rep (new octave_scalar_struct (m))
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10687
diff changeset
1226 {
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10687
diff changeset
1227 }
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10687
diff changeset
1228
18402
4c064d3d2750 Remove Octave_map class deprecated in 3.8.
Rik <rik@octave.org>
parents: 18306
diff changeset
1229 octave_value::octave_value (const octave_map& m, const std::string& id,
4c064d3d2750 Remove Octave_map class deprecated in 3.8.
Rik <rik@octave.org>
parents: 18306
diff changeset
1230 const std::list<std::string>& plist)
4c064d3d2750 Remove Octave_map class deprecated in 3.8.
Rik <rik@octave.org>
parents: 18306
diff changeset
1231 : rep (new octave_class (m, id, plist))
2825
60ae49e1284f [project @ 1997-03-25 23:17:36 by jwe]
jwe
parents: 2800
diff changeset
1232 {
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10687
diff changeset
1233 maybe_mutate ();
2880
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
1234 }
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
1235
18402
4c064d3d2750 Remove Octave_map class deprecated in 3.8.
Rik <rik@octave.org>
parents: 18306
diff changeset
1236 octave_value::octave_value (const octave_scalar_map& m, const std::string& id,
13294
7dce7e110511 make concatenation of class objects work
John W. Eaton <jwe@octave.org>
parents: 13101
diff changeset
1237 const std::list<std::string>& plist)
7dce7e110511 make concatenation of class objects work
John W. Eaton <jwe@octave.org>
parents: 13101
diff changeset
1238 : rep (new octave_class (m, id, plist))
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
1239 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
1240 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
1241
10232
0efd486813fe remove deprecated list datatype
Jaroslav Hajek <highegg@gmail.com>
parents: 10160
diff changeset
1242 octave_value::octave_value (const octave_value_list& l, bool)
0efd486813fe remove deprecated list datatype
Jaroslav Hajek <highegg@gmail.com>
parents: 10160
diff changeset
1243 : rep (new octave_cs_list (l))
2880
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
1244 {
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
1245 }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1246
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1247 octave_value::octave_value (octave_value::magic_colon)
2825
60ae49e1284f [project @ 1997-03-25 23:17:36 by jwe]
jwe
parents: 2800
diff changeset
1248 : rep (new octave_magic_colon ())
60ae49e1284f [project @ 1997-03-25 23:17:36 by jwe]
jwe
parents: 2800
diff changeset
1249 {
60ae49e1284f [project @ 1997-03-25 23:17:36 by jwe]
jwe
parents: 2800
diff changeset
1250 }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1251
9728
70925b11ba46 again allow the obsolete syntax for cellfun
Jaroslav Hajek <highegg@gmail.com>
parents: 9725
diff changeset
1252 octave_value::octave_value (octave_base_value *new_rep, bool borrow)
2825
60ae49e1284f [project @ 1997-03-25 23:17:36 by jwe]
jwe
parents: 2800
diff changeset
1253 : rep (new_rep)
60ae49e1284f [project @ 1997-03-25 23:17:36 by jwe]
jwe
parents: 2800
diff changeset
1254 {
9728
70925b11ba46 again allow the obsolete syntax for cellfun
Jaroslav Hajek <highegg@gmail.com>
parents: 9725
diff changeset
1255 if (borrow)
70925b11ba46 again allow the obsolete syntax for cellfun
Jaroslav Hajek <highegg@gmail.com>
parents: 9725
diff changeset
1256 rep->count++;
2825
60ae49e1284f [project @ 1997-03-25 23:17:36 by jwe]
jwe
parents: 2800
diff changeset
1257 }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1258
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
1259 octave_value::octave_value (octave_base_value *new_rep, int xcount)
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
1260 : rep (new_rep)
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
1261 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
1262 rep->count = xcount;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
1263 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
1264
5759
ce79d238f142 [project @ 2006-04-13 13:04:32 by jwe]
jwe
parents: 5758
diff changeset
1265 octave_base_value *
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1266 octave_value::clone (void) const
2880
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
1267 {
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
1268 return rep->clone ();
2880
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
1269 }
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
1270
2409
47e5f57fb4bd [project @ 1996-10-15 16:44:26 by jwe]
jwe
parents: 2376
diff changeset
1271 void
47e5f57fb4bd [project @ 1996-10-15 16:44:26 by jwe]
jwe
parents: 2376
diff changeset
1272 octave_value::maybe_mutate (void)
47e5f57fb4bd [project @ 1996-10-15 16:44:26 by jwe]
jwe
parents: 2376
diff changeset
1273 {
5759
ce79d238f142 [project @ 2006-04-13 13:04:32 by jwe]
jwe
parents: 5758
diff changeset
1274 octave_base_value *tmp = rep->try_narrowing_conversion ();
2409
47e5f57fb4bd [project @ 1996-10-15 16:44:26 by jwe]
jwe
parents: 2376
diff changeset
1275
47e5f57fb4bd [project @ 1996-10-15 16:44:26 by jwe]
jwe
parents: 2376
diff changeset
1276 if (tmp && tmp != rep)
47e5f57fb4bd [project @ 1996-10-15 16:44:26 by jwe]
jwe
parents: 2376
diff changeset
1277 {
47e5f57fb4bd [project @ 1996-10-15 16:44:26 by jwe]
jwe
parents: 2376
diff changeset
1278 if (--rep->count == 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1279 delete rep;
2409
47e5f57fb4bd [project @ 1996-10-15 16:44:26 by jwe]
jwe
parents: 2376
diff changeset
1280
47e5f57fb4bd [project @ 1996-10-15 16:44:26 by jwe]
jwe
parents: 2376
diff changeset
1281 rep = tmp;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1282 }
2409
47e5f57fb4bd [project @ 1996-10-15 16:44:26 by jwe]
jwe
parents: 2376
diff changeset
1283 }
47e5f57fb4bd [project @ 1996-10-15 16:44:26 by jwe]
jwe
parents: 2376
diff changeset
1284
4247
fc9a075d10fb [project @ 2002-12-30 23:05:27 by jwe]
jwe
parents: 4233
diff changeset
1285 octave_value
4271
be631c1720ea [project @ 2003-01-03 19:36:04 by jwe]
jwe
parents: 4257
diff changeset
1286 octave_value::single_subsref (const std::string& type,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1287 const octave_value_list& idx)
4247
fc9a075d10fb [project @ 2002-12-30 23:05:27 by jwe]
jwe
parents: 4233
diff changeset
1288 {
fc9a075d10fb [project @ 2002-12-30 23:05:27 by jwe]
jwe
parents: 4233
diff changeset
1289 std::list<octave_value_list> i;
fc9a075d10fb [project @ 2002-12-30 23:05:27 by jwe]
jwe
parents: 4233
diff changeset
1290
fc9a075d10fb [project @ 2002-12-30 23:05:27 by jwe]
jwe
parents: 4233
diff changeset
1291 i.push_back (idx);
fc9a075d10fb [project @ 2002-12-30 23:05:27 by jwe]
jwe
parents: 4233
diff changeset
1292
fc9a075d10fb [project @ 2002-12-30 23:05:27 by jwe]
jwe
parents: 4233
diff changeset
1293 return rep->subsref (type, i);
fc9a075d10fb [project @ 2002-12-30 23:05:27 by jwe]
jwe
parents: 4233
diff changeset
1294 }
fc9a075d10fb [project @ 2002-12-30 23:05:27 by jwe]
jwe
parents: 4233
diff changeset
1295
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents: 2963
diff changeset
1296 octave_value_list
4247
fc9a075d10fb [project @ 2002-12-30 23:05:27 by jwe]
jwe
parents: 4233
diff changeset
1297 octave_value::subsref (const std::string& type,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1298 const std::list<octave_value_list>& idx, int nargout)
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1299 {
7651
443a8f5a50fd require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents: 7503
diff changeset
1300 if (nargout == 1)
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1301 return rep->subsref (type, idx);
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1302 else
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1303 return rep->subsref (type, idx, nargout);
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1304 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1305
10832
1b2fcd122c6a allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents: 10768
diff changeset
1306 octave_value_list
1b2fcd122c6a allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents: 10768
diff changeset
1307 octave_value::subsref (const std::string& type,
1b2fcd122c6a allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents: 10768
diff changeset
1308 const std::list<octave_value_list>& idx, int nargout,
1b2fcd122c6a allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents: 10768
diff changeset
1309 const std::list<octave_lvalue> *lvalue_list)
1b2fcd122c6a allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents: 10768
diff changeset
1310 {
1b2fcd122c6a allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents: 10768
diff changeset
1311 if (lvalue_list)
1b2fcd122c6a allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents: 10768
diff changeset
1312 return rep->subsref (type, idx, nargout, lvalue_list);
1b2fcd122c6a allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents: 10768
diff changeset
1313 else
1b2fcd122c6a allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents: 10768
diff changeset
1314 return subsref (type, idx, nargout);
1b2fcd122c6a allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents: 10768
diff changeset
1315 }
1b2fcd122c6a allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents: 10768
diff changeset
1316
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1317 octave_value
4247
fc9a075d10fb [project @ 2002-12-30 23:05:27 by jwe]
jwe
parents: 4233
diff changeset
1318 octave_value::next_subsref (const std::string& type,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1319 const std::list<octave_value_list>& idx,
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1320 size_t skip)
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1321 {
4582
db5a24d54915 [project @ 2003-10-31 15:11:45 by jwe]
jwe
parents: 4567
diff changeset
1322 if (! error_state && idx.size () > skip)
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1323 {
4219
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
1324 std::list<octave_value_list> new_idx (idx);
4233
ccfdb55c8156 [project @ 2002-12-20 22:43:54 by jwe]
jwe
parents: 4219
diff changeset
1325 for (size_t i = 0; i < skip; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1326 new_idx.erase (new_idx.begin ());
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1327 return subsref (type.substr (skip), new_idx);
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1328 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1329 else
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1330 return *this;
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1331 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1332
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1333 octave_value_list
4994
48d0defe9445 [project @ 2004-09-15 20:31:31 by jwe]
jwe
parents: 4970
diff changeset
1334 octave_value::next_subsref (int nargout, const std::string& type,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1335 const std::list<octave_value_list>& idx,
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1336 size_t skip)
4994
48d0defe9445 [project @ 2004-09-15 20:31:31 by jwe]
jwe
parents: 4970
diff changeset
1337 {
48d0defe9445 [project @ 2004-09-15 20:31:31 by jwe]
jwe
parents: 4970
diff changeset
1338 if (! error_state && idx.size () > skip)
48d0defe9445 [project @ 2004-09-15 20:31:31 by jwe]
jwe
parents: 4970
diff changeset
1339 {
48d0defe9445 [project @ 2004-09-15 20:31:31 by jwe]
jwe
parents: 4970
diff changeset
1340 std::list<octave_value_list> new_idx (idx);
48d0defe9445 [project @ 2004-09-15 20:31:31 by jwe]
jwe
parents: 4970
diff changeset
1341 for (size_t i = 0; i < skip; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1342 new_idx.erase (new_idx.begin ());
4994
48d0defe9445 [project @ 2004-09-15 20:31:31 by jwe]
jwe
parents: 4970
diff changeset
1343 return subsref (type.substr (skip), new_idx, nargout);
48d0defe9445 [project @ 2004-09-15 20:31:31 by jwe]
jwe
parents: 4970
diff changeset
1344 }
48d0defe9445 [project @ 2004-09-15 20:31:31 by jwe]
jwe
parents: 4970
diff changeset
1345 else
48d0defe9445 [project @ 2004-09-15 20:31:31 by jwe]
jwe
parents: 4970
diff changeset
1346 return *this;
48d0defe9445 [project @ 2004-09-15 20:31:31 by jwe]
jwe
parents: 4970
diff changeset
1347 }
48d0defe9445 [project @ 2004-09-15 20:31:31 by jwe]
jwe
parents: 4970
diff changeset
1348
16091
1785493171ac pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents: 15767
diff changeset
1349 octave_value_list
1785493171ac pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents: 15767
diff changeset
1350 octave_value::next_subsref (int nargout, const std::string& type,
1785493171ac pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents: 15767
diff changeset
1351 const std::list<octave_value_list>& idx,
1785493171ac pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents: 15767
diff changeset
1352 const std::list<octave_lvalue> *lvalue_list,
1785493171ac pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents: 15767
diff changeset
1353 size_t skip)
1785493171ac pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents: 15767
diff changeset
1354 {
1785493171ac pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents: 15767
diff changeset
1355 if (! error_state && idx.size () > skip)
1785493171ac pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents: 15767
diff changeset
1356 {
1785493171ac pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents: 15767
diff changeset
1357 std::list<octave_value_list> new_idx (idx);
1785493171ac pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents: 15767
diff changeset
1358 for (size_t i = 0; i < skip; i++)
1785493171ac pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents: 15767
diff changeset
1359 new_idx.erase (new_idx.begin ());
1785493171ac pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents: 15767
diff changeset
1360 return subsref (type.substr (skip), new_idx, nargout, lvalue_list);
1785493171ac pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents: 15767
diff changeset
1361 }
1785493171ac pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents: 15767
diff changeset
1362 else
1785493171ac pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents: 15767
diff changeset
1363 return *this;
1785493171ac pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents: 15767
diff changeset
1364 }
1785493171ac pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents: 15767
diff changeset
1365
8551
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8531
diff changeset
1366 octave_value
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8531
diff changeset
1367 octave_value::next_subsref (bool auto_add, const std::string& type,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1368 const std::list<octave_value_list>& idx,
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1369 size_t skip)
8551
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8531
diff changeset
1370 {
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8531
diff changeset
1371 if (! error_state && idx.size () > skip)
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8531
diff changeset
1372 {
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8531
diff changeset
1373 std::list<octave_value_list> new_idx (idx);
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8531
diff changeset
1374 for (size_t i = 0; i < skip; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1375 new_idx.erase (new_idx.begin ());
8551
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8531
diff changeset
1376 return subsref (type.substr (skip), new_idx, auto_add);
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8531
diff changeset
1377 }
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8531
diff changeset
1378 else
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8531
diff changeset
1379 return *this;
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8531
diff changeset
1380 }
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8531
diff changeset
1381
4994
48d0defe9445 [project @ 2004-09-15 20:31:31 by jwe]
jwe
parents: 4970
diff changeset
1382 octave_value_list
3544
71bd2d124119 [project @ 2000-02-02 21:02:31 by jwe]
jwe
parents: 3536
diff changeset
1383 octave_value::do_multi_index_op (int nargout, const octave_value_list& idx)
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents: 2963
diff changeset
1384 {
3544
71bd2d124119 [project @ 2000-02-02 21:02:31 by jwe]
jwe
parents: 3536
diff changeset
1385 return rep->do_multi_index_op (nargout, idx);
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents: 2963
diff changeset
1386 }
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents: 2963
diff changeset
1387
10832
1b2fcd122c6a allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents: 10768
diff changeset
1388 octave_value_list
1b2fcd122c6a allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents: 10768
diff changeset
1389 octave_value::do_multi_index_op (int nargout, const octave_value_list& idx,
1b2fcd122c6a allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents: 10768
diff changeset
1390 const std::list<octave_lvalue> *lvalue_list)
1b2fcd122c6a allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents: 10768
diff changeset
1391 {
1b2fcd122c6a allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents: 10768
diff changeset
1392 return rep->do_multi_index_op (nargout, idx, lvalue_list);
1b2fcd122c6a allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents: 10768
diff changeset
1393 }
1b2fcd122c6a allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents: 10768
diff changeset
1394
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1395 #if 0
3204
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
1396 static void
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1397 gripe_assign_failed (const std::string& on, const std::string& tn1,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1398 const std::string& tn2)
3204
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
1399 {
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 15428
diff changeset
1400 error ("assignment failed for '%s %s %s'",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1401 tn1.c_str (), on.c_str (), tn2.c_str ());
3204
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
1402 }
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1403 #endif
3204
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
1404
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
1405 static void
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1406 gripe_assign_failed_or_no_method (const std::string& on,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1407 const std::string& tn1,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1408 const std::string& tn2)
3204
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
1409 {
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 15428
diff changeset
1410 error ("assignment failed, or no method for '%s %s %s'",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1411 tn1.c_str (), on.c_str (), tn2.c_str ());
3204
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
1412 }
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
1413
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1414 octave_value
4247
fc9a075d10fb [project @ 2002-12-30 23:05:27 by jwe]
jwe
parents: 4233
diff changeset
1415 octave_value::subsasgn (const std::string& type,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1416 const std::list<octave_value_list>& idx,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1417 const octave_value& rhs)
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1418 {
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1419 return rep->subsasgn (type, idx, rhs);
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1420 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1421
12171
d08901c05c1b fix bug in class assignment to undefined object with index
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1422 octave_value
d08901c05c1b fix bug in class assignment to undefined object with index
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1423 octave_value::undef_subsasgn (const std::string& type,
d08901c05c1b fix bug in class assignment to undefined object with index
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1424 const std::list<octave_value_list>& idx,
d08901c05c1b fix bug in class assignment to undefined object with index
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1425 const octave_value& rhs)
d08901c05c1b fix bug in class assignment to undefined object with index
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1426 {
d08901c05c1b fix bug in class assignment to undefined object with index
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1427 return rep->undef_subsasgn (type, idx, rhs);
d08901c05c1b fix bug in class assignment to undefined object with index
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1428 }
d08901c05c1b fix bug in class assignment to undefined object with index
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1429
10544
9961fc022d9d fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
1430 octave_value&
4247
fc9a075d10fb [project @ 2002-12-30 23:05:27 by jwe]
jwe
parents: 4233
diff changeset
1431 octave_value::assign (assign_op op, const std::string& type,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1432 const std::list<octave_value_list>& idx,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1433 const octave_value& rhs)
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1434 {
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1435 octave_value retval;
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1436
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1437 make_unique ();
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1438
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1439 octave_value t_rhs = rhs;
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1440
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1441 if (op != op_asn_eq)
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1442 {
10544
9961fc022d9d fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
1443 if (is_defined ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1444 {
10544
9961fc022d9d fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
1445 octave_value t = subsref (type, idx);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1446
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1447 if (! error_state)
10544
9961fc022d9d fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
1448 {
9961fc022d9d fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
1449 binary_op binop = op_eq_to_binary_op (op);
9961fc022d9d fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
1450
9961fc022d9d fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
1451 if (! error_state)
9961fc022d9d fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
1452 t_rhs = do_binary_op (binop, t, rhs);
9961fc022d9d fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
1453 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1454 }
10544
9961fc022d9d fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
1455 else
9961fc022d9d fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
1456 error ("in computed assignment A(index) OP= X, A must be defined first");
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1457 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1458
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1459 if (! error_state)
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1460 {
10871
333bf09e3b6e only allow struct assignments to non-struct values for empty arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 10832
diff changeset
1461 octave_value tmp = subsasgn (type, idx, t_rhs);
9693
1c19877799d3 improve error reports for computed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 9690
diff changeset
1462
1c19877799d3 improve error reports for computed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 9690
diff changeset
1463 if (error_state)
1c19877799d3 improve error reports for computed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 9690
diff changeset
1464 gripe_assign_failed_or_no_method (assign_op_as_string (op_asn_eq),
1c19877799d3 improve error reports for computed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 9690
diff changeset
1465 type_name (), rhs.type_name ());
10871
333bf09e3b6e only allow struct assignments to non-struct values for empty arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 10832
diff changeset
1466 else
333bf09e3b6e only allow struct assignments to non-struct values for empty arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 10832
diff changeset
1467 *this = tmp;
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1468 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1469
10544
9961fc022d9d fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
1470 return *this;
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1471 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1472
10544
9961fc022d9d fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
1473 octave_value&
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
1474 octave_value::assign (assign_op op, const octave_value& rhs)
2880
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
1475 {
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
1476 if (op == op_asn_eq)
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8039
diff changeset
1477 // Regularize a null matrix if stored into a variable.
8523
ad3afaaa19c1 implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8367
diff changeset
1478 operator = (rhs.storable_value ());
10544
9961fc022d9d fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
1479 else if (is_defined ())
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
1480 {
9546
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9479
diff changeset
1481 octave_value_typeinfo::assign_op_fcn f = 0;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1482
9546
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9479
diff changeset
1483 // Only attempt to operate in-place if this variable is unshared.
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9479
diff changeset
1484 if (rep->count == 1)
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9479
diff changeset
1485 {
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9479
diff changeset
1486 int tthis = this->type_id ();
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9479
diff changeset
1487 int trhs = rhs.type_id ();
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9479
diff changeset
1488
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1489 f = octave_value_typeinfo::lookup_assign_op (op, tthis, trhs);
9546
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9479
diff changeset
1490 }
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9479
diff changeset
1491
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9479
diff changeset
1492 if (f)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1493 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1494 try
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1495 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1496 f (*rep, octave_value_list (), *rhs.rep);
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1497 // Usually unnecessary, but may be needed (complex arrays).
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1498 maybe_mutate ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1499 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1500 catch (octave_execution_exception)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1501 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1502 gripe_library_execution_error ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1503 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1504 }
9546
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9479
diff changeset
1505 else
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9479
diff changeset
1506 {
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9479
diff changeset
1507
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9479
diff changeset
1508 binary_op binop = op_eq_to_binary_op (op);
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9479
diff changeset
1509
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9479
diff changeset
1510 if (! error_state)
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9479
diff changeset
1511 {
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9479
diff changeset
1512 octave_value t = do_binary_op (binop, *this, rhs);
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9479
diff changeset
1513
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9479
diff changeset
1514 if (! error_state)
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9479
diff changeset
1515 operator = (t);
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9479
diff changeset
1516 }
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9479
diff changeset
1517 }
3204
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
1518 }
10544
9961fc022d9d fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
1519 else
9961fc022d9d fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
1520 error ("in computed assignment A OP= X, A must be defined first");
3204
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
1521
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1522 return *this;
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1523 }
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1524
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
1525 octave_idx_type
4563
742993a501b9 [project @ 2003-10-29 06:25:12 by jwe]
jwe
parents: 4532
diff changeset
1526 octave_value::length (void) const
742993a501b9 [project @ 2003-10-29 06:25:12 by jwe]
jwe
parents: 4532
diff changeset
1527 {
10654
984b8b6bee02 simplify octave_value::length
Jaroslav Hajek <highegg@gmail.com>
parents: 10614
diff changeset
1528 octave_idx_type retval = 0;
984b8b6bee02 simplify octave_value::length
Jaroslav Hajek <highegg@gmail.com>
parents: 10614
diff changeset
1529
984b8b6bee02 simplify octave_value::length
Jaroslav Hajek <highegg@gmail.com>
parents: 10614
diff changeset
1530 const dim_vector dv = dims ();
4584
f7697d703481 [project @ 2003-10-31 19:47:35 by jwe]
jwe
parents: 4582
diff changeset
1531
4563
742993a501b9 [project @ 2003-10-29 06:25:12 by jwe]
jwe
parents: 4532
diff changeset
1532 for (int i = 0; i < dv.length (); i++)
742993a501b9 [project @ 2003-10-29 06:25:12 by jwe]
jwe
parents: 4532
diff changeset
1533 {
4584
f7697d703481 [project @ 2003-10-31 19:47:35 by jwe]
jwe
parents: 4582
diff changeset
1534 if (dv(i) == 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1535 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1536 retval = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1537 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1538 }
4584
f7697d703481 [project @ 2003-10-31 19:47:35 by jwe]
jwe
parents: 4582
diff changeset
1539
4563
742993a501b9 [project @ 2003-10-29 06:25:12 by jwe]
jwe
parents: 4532
diff changeset
1540 if (dv(i) > retval)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1541 retval = dv(i);
4563
742993a501b9 [project @ 2003-10-29 06:25:12 by jwe]
jwe
parents: 4532
diff changeset
1542 }
742993a501b9 [project @ 2003-10-29 06:25:12 by jwe]
jwe
parents: 4532
diff changeset
1543
742993a501b9 [project @ 2003-10-29 06:25:12 by jwe]
jwe
parents: 4532
diff changeset
1544 return retval;
742993a501b9 [project @ 2003-10-29 06:25:12 by jwe]
jwe
parents: 4532
diff changeset
1545 }
742993a501b9 [project @ 2003-10-29 06:25:12 by jwe]
jwe
parents: 4532
diff changeset
1546
8346
8302788f09db fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
1547 bool
8302788f09db fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
1548 octave_value::is_equal (const octave_value& test) const
8302788f09db fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
1549 {
8302788f09db fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
1550 bool retval = false;
8302788f09db fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
1551
8302788f09db fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
1552 // If there is no op_eq for these types, we can't compare values.
8302788f09db fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
1553
8302788f09db fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
1554 if (rows () == test.rows () && columns () == test.columns ())
8302788f09db fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
1555 {
8302788f09db fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
1556 octave_value tmp = do_binary_op (octave_value::op_eq, *this, test);
8302788f09db fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
1557
8302788f09db fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
1558 // Empty array also means a match.
8302788f09db fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
1559 if (! error_state && tmp.is_defined ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1560 retval = tmp.is_true () || tmp.is_empty ();
8346
8302788f09db fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
1561 }
8302788f09db fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
1562
8302788f09db fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
1563 return retval;
8302788f09db fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
1564 }
8302788f09db fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
1565
3351
8623649c967c [project @ 1999-11-15 16:17:01 by jwe]
jwe
parents: 3340
diff changeset
1566 Cell
8623649c967c [project @ 1999-11-15 16:17:01 by jwe]
jwe
parents: 3340
diff changeset
1567 octave_value::cell_value (void) const
8623649c967c [project @ 1999-11-15 16:17:01 by jwe]
jwe
parents: 3340
diff changeset
1568 {
8623649c967c [project @ 1999-11-15 16:17:01 by jwe]
jwe
parents: 3340
diff changeset
1569 return rep->cell_value ();
8623649c967c [project @ 1999-11-15 16:17:01 by jwe]
jwe
parents: 3340
diff changeset
1570 }
8623649c967c [project @ 1999-11-15 16:17:01 by jwe]
jwe
parents: 3340
diff changeset
1571
8017
260294a5520f octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents: 8011
diff changeset
1572 // Define the idx_type_value function here instead of in ov.h to avoid
260294a5520f octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents: 8011
diff changeset
1573 // needing definitions for the SIZEOF_X macros in ov.h.
260294a5520f octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents: 8011
diff changeset
1574
260294a5520f octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents: 8011
diff changeset
1575 octave_idx_type
8024
dc36eb214129 ov.cc (octave_value::idx_type_value): don't include default argument value in definition
John W. Eaton <jwe@octave.org>
parents: 8017
diff changeset
1576 octave_value::idx_type_value (bool req_int, bool frc_str_conv) const
8017
260294a5520f octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents: 8011
diff changeset
1577 {
16323
e769440b39db provide int64 extractors for octave_value class
John W. Eaton <jwe@octave.org>
parents: 16091
diff changeset
1578 #if defined (USE_64_BIT_IDX_T)
e769440b39db provide int64 extractors for octave_value class
John W. Eaton <jwe@octave.org>
parents: 16091
diff changeset
1579 return int64_value (req_int, frc_str_conv);
e769440b39db provide int64 extractors for octave_value class
John W. Eaton <jwe@octave.org>
parents: 16091
diff changeset
1580 #else
8017
260294a5520f octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents: 8011
diff changeset
1581 return int_value (req_int, frc_str_conv);
260294a5520f octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents: 8011
diff changeset
1582 #endif
260294a5520f octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents: 8011
diff changeset
1583 }
260294a5520f octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents: 8011
diff changeset
1584
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10687
diff changeset
1585 octave_map
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1586 octave_value::map_value (void) const
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1587 {
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1588 return rep->map_value ();
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1589 }
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1590
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10687
diff changeset
1591 octave_scalar_map
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10687
diff changeset
1592 octave_value::scalar_map_value (void) const
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10687
diff changeset
1593 {
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10687
diff changeset
1594 return rep->scalar_map_value ();
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10687
diff changeset
1595 }
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10687
diff changeset
1596
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents: 2963
diff changeset
1597 octave_function *
7761
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
1598 octave_value::function_value (bool silent) const
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
1599 {
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
1600 return rep->function_value (silent);
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
1601 }
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
1602
4700
ca3a1d687bba [project @ 2004-01-21 03:28:31 by jwe]
jwe
parents: 4661
diff changeset
1603 octave_user_function *
10075
84b0725f4b09 return class types by reference in const Array element access functions
Jaroslav Hajek <highegg@gmail.com>
parents: 10033
diff changeset
1604 octave_value::user_function_value (bool silent) const
4700
ca3a1d687bba [project @ 2004-01-21 03:28:31 by jwe]
jwe
parents: 4661
diff changeset
1605 {
ca3a1d687bba [project @ 2004-01-21 03:28:31 by jwe]
jwe
parents: 4661
diff changeset
1606 return rep->user_function_value (silent);
ca3a1d687bba [project @ 2004-01-21 03:28:31 by jwe]
jwe
parents: 4661
diff changeset
1607 }
ca3a1d687bba [project @ 2004-01-21 03:28:31 by jwe]
jwe
parents: 4661
diff changeset
1608
7719
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
1609 octave_user_script *
10075
84b0725f4b09 return class types by reference in const Array element access functions
Jaroslav Hajek <highegg@gmail.com>
parents: 10033
diff changeset
1610 octave_value::user_script_value (bool silent) const
7719
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
1611 {
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
1612 return rep->user_script_value (silent);
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
1613 }
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
1614
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
1615 octave_user_code *
10075
84b0725f4b09 return class types by reference in const Array element access functions
Jaroslav Hajek <highegg@gmail.com>
parents: 10033
diff changeset
1616 octave_value::user_code_value (bool silent) const
7719
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
1617 {
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
1618 return rep->user_code_value (silent);
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
1619 }
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
1620
4346
d39de791ef9c [project @ 2003-02-20 21:38:39 by jwe]
jwe
parents: 4343
diff changeset
1621 octave_fcn_handle *
10075
84b0725f4b09 return class types by reference in const Array element access functions
Jaroslav Hajek <highegg@gmail.com>
parents: 10033
diff changeset
1622 octave_value::fcn_handle_value (bool silent) const
4343
db5e0814277a [project @ 2003-02-20 16:44:16 by jwe]
jwe
parents: 4342
diff changeset
1623 {
db5e0814277a [project @ 2003-02-20 16:44:16 by jwe]
jwe
parents: 4342
diff changeset
1624 return rep->fcn_handle_value (silent);
db5e0814277a [project @ 2003-02-20 16:44:16 by jwe]
jwe
parents: 4342
diff changeset
1625 }
db5e0814277a [project @ 2003-02-20 16:44:16 by jwe]
jwe
parents: 4342
diff changeset
1626
4933
cd58733c326b [project @ 2004-08-05 16:08:28 by jwe]
jwe
parents: 4930
diff changeset
1627 octave_fcn_inline *
10075
84b0725f4b09 return class types by reference in const Array element access functions
Jaroslav Hajek <highegg@gmail.com>
parents: 10033
diff changeset
1628 octave_value::fcn_inline_value (bool silent) const
4933
cd58733c326b [project @ 2004-08-05 16:08:28 by jwe]
jwe
parents: 4930
diff changeset
1629 {
cd58733c326b [project @ 2004-08-05 16:08:28 by jwe]
jwe
parents: 4930
diff changeset
1630 return rep->fcn_inline_value (silent);
cd58733c326b [project @ 2004-08-05 16:08:28 by jwe]
jwe
parents: 4930
diff changeset
1631 }
cd58733c326b [project @ 2004-08-05 16:08:28 by jwe]
jwe
parents: 4930
diff changeset
1632
2880
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
1633 octave_value_list
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
1634 octave_value::list_value (void) const
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
1635 {
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
1636 return rep->list_value ();
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
1637 }
0a076230ca87 [project @ 1997-04-24 09:47:41 by jwe]
jwe
parents: 2847
diff changeset
1638
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1639 static dim_vector
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1640 make_vector_dims (const dim_vector& dv, bool force_vector_conversion,
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1641 const std::string& my_type, const std::string& wanted_type)
3419
e71b3d1dd327 [project @ 2000-01-12 05:23:34 by jwe]
jwe
parents: 3418
diff changeset
1642 {
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1643 dim_vector retval (dv);
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1644 retval.chop_trailing_singletons ();
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1645 octave_idx_type nel = dv.numel ();
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1646
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1647 if (retval.length () > 2 || (retval(0) != 1 && retval(1) != 1))
3419
e71b3d1dd327 [project @ 2000-01-12 05:23:34 by jwe]
jwe
parents: 3418
diff changeset
1648 {
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1649 if (!force_vector_conversion)
14469
29aabe9b37a2 Rename array-as-vector, array-as-scalar warning IDs to match documentation (bug #35838)
Rik <octave@nomad.inbox5.com>
parents: 14429
diff changeset
1650 gripe_implicit_conversion ("Octave:array-to-vector",
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1651 my_type.c_str (), wanted_type.c_str ());
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10325
diff changeset
1652 retval = dim_vector (nel, 1);
3419
e71b3d1dd327 [project @ 2000-01-12 05:23:34 by jwe]
jwe
parents: 3418
diff changeset
1653 }
e71b3d1dd327 [project @ 2000-01-12 05:23:34 by jwe]
jwe
parents: 3418
diff changeset
1654
e71b3d1dd327 [project @ 2000-01-12 05:23:34 by jwe]
jwe
parents: 3418
diff changeset
1655 return retval;
e71b3d1dd327 [project @ 2000-01-12 05:23:34 by jwe]
jwe
parents: 3418
diff changeset
1656 }
e71b3d1dd327 [project @ 2000-01-12 05:23:34 by jwe]
jwe
parents: 3418
diff changeset
1657
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1658 ColumnVector
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1659 octave_value::column_vector_value (bool force_string_conv,
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1660 bool frc_vec_conv) const
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1661 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1662 return ColumnVector (vector_value (force_string_conv,
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1663 frc_vec_conv));
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1664 }
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1665
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1666 ComplexColumnVector
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1667 octave_value::complex_column_vector_value (bool force_string_conv,
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1668 bool frc_vec_conv) const
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1669 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1670 return ComplexColumnVector (complex_vector_value (force_string_conv,
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1671 frc_vec_conv));
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1672 }
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1673
3419
e71b3d1dd327 [project @ 2000-01-12 05:23:34 by jwe]
jwe
parents: 3418
diff changeset
1674 RowVector
e71b3d1dd327 [project @ 2000-01-12 05:23:34 by jwe]
jwe
parents: 3418
diff changeset
1675 octave_value::row_vector_value (bool force_string_conv,
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1676 bool frc_vec_conv) const
3419
e71b3d1dd327 [project @ 2000-01-12 05:23:34 by jwe]
jwe
parents: 3418
diff changeset
1677 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1678 return RowVector (vector_value (force_string_conv,
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1679 frc_vec_conv));
3419
e71b3d1dd327 [project @ 2000-01-12 05:23:34 by jwe]
jwe
parents: 3418
diff changeset
1680 }
e71b3d1dd327 [project @ 2000-01-12 05:23:34 by jwe]
jwe
parents: 3418
diff changeset
1681
e71b3d1dd327 [project @ 2000-01-12 05:23:34 by jwe]
jwe
parents: 3418
diff changeset
1682 ComplexRowVector
e71b3d1dd327 [project @ 2000-01-12 05:23:34 by jwe]
jwe
parents: 3418
diff changeset
1683 octave_value::complex_row_vector_value (bool force_string_conv,
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1684 bool frc_vec_conv) const
3419
e71b3d1dd327 [project @ 2000-01-12 05:23:34 by jwe]
jwe
parents: 3418
diff changeset
1685 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1686 return ComplexRowVector (complex_vector_value (force_string_conv,
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1687 frc_vec_conv));
3419
e71b3d1dd327 [project @ 2000-01-12 05:23:34 by jwe]
jwe
parents: 3418
diff changeset
1688 }
e71b3d1dd327 [project @ 2000-01-12 05:23:34 by jwe]
jwe
parents: 3418
diff changeset
1689
e71b3d1dd327 [project @ 2000-01-12 05:23:34 by jwe]
jwe
parents: 3418
diff changeset
1690 Array<double>
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1691 octave_value::vector_value (bool force_string_conv,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1692 bool force_vector_conversion) const
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1693 {
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1694 Array<double> retval = array_value (force_string_conv);
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1695
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1696 if (error_state)
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1697 return retval;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1698 else
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1699 return retval.reshape (make_vector_dims (retval.dims (),
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1700 force_vector_conversion,
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1701 type_name (), "real vector"));
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1702 }
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1703
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7892
diff changeset
1704 template <class T>
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7892
diff changeset
1705 static Array<int>
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7892
diff changeset
1706 convert_to_int_array (const Array<octave_int<T> >& A)
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7892
diff changeset
1707 {
7999
f7f2d867c523 style fixes
John W. Eaton <jwe@octave.org>
parents: 7997
diff changeset
1708 Array<int> retval (A.dims ());
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7892
diff changeset
1709 octave_idx_type n = A.numel ();
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7892
diff changeset
1710
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7892
diff changeset
1711 for (octave_idx_type i = 0; i < n; i++)
7999
f7f2d867c523 style fixes
John W. Eaton <jwe@octave.org>
parents: 7997
diff changeset
1712 retval.xelem (i) = octave_int<int> (A.xelem (i));
8039
cd90e2842080 Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents: 8024
diff changeset
1713
7999
f7f2d867c523 style fixes
John W. Eaton <jwe@octave.org>
parents: 7997
diff changeset
1714 return retval;
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7892
diff changeset
1715 }
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7892
diff changeset
1716
4044
9678c5526190 [project @ 2002-08-15 16:54:55 by jwe]
jwe
parents: 4038
diff changeset
1717 Array<int>
9678c5526190 [project @ 2002-08-15 16:54:55 by jwe]
jwe
parents: 4038
diff changeset
1718 octave_value::int_vector_value (bool force_string_conv, bool require_int,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1719 bool force_vector_conversion) const
4044
9678c5526190 [project @ 2002-08-15 16:54:55 by jwe]
jwe
parents: 4038
diff changeset
1720 {
9678c5526190 [project @ 2002-08-15 16:54:55 by jwe]
jwe
parents: 4038
diff changeset
1721 Array<int> retval;
9678c5526190 [project @ 2002-08-15 16:54:55 by jwe]
jwe
parents: 4038
diff changeset
1722
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1723 if (is_integer_type ())
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1724 {
7997
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7892
diff changeset
1725 if (is_int32_type ())
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7892
diff changeset
1726 retval = convert_to_int_array (int32_array_value ());
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7892
diff changeset
1727 else if (is_int64_type ())
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7892
diff changeset
1728 retval = convert_to_int_array (int64_array_value ());
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7892
diff changeset
1729 else if (is_int16_type ())
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7892
diff changeset
1730 retval = convert_to_int_array (int16_array_value ());
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7892
diff changeset
1731 else if (is_int8_type ())
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7892
diff changeset
1732 retval = convert_to_int_array (int8_array_value ());
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7892
diff changeset
1733 else if (is_uint32_type ())
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7892
diff changeset
1734 retval = convert_to_int_array (uint32_array_value ());
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7892
diff changeset
1735 else if (is_uint64_type ())
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7892
diff changeset
1736 retval = convert_to_int_array (uint64_array_value ());
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7892
diff changeset
1737 else if (is_uint16_type ())
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7892
diff changeset
1738 retval = convert_to_int_array (uint16_array_value ());
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7892
diff changeset
1739 else if (is_uint8_type ())
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7892
diff changeset
1740 retval = convert_to_int_array (uint8_array_value ());
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7892
diff changeset
1741 else
2b8952e133c9 implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents: 7892
diff changeset
1742 retval = array_value (force_string_conv);
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1743 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1744 else
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1745 {
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1746 const NDArray a = array_value (force_string_conv);
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1747 if (! error_state)
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1748 {
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1749 if (require_int)
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1750 {
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1751 retval.resize (a.dims ());
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1752 for (octave_idx_type i = 0; i < a.numel (); i++)
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1753 {
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1754 double ai = a.elem (i);
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1755 int v = static_cast<int> (ai);
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1756 if (ai == v)
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1757 retval.xelem (i) = v;
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1758 else
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1759 {
9753
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
1760 error_with_cfn ("conversion to integer value failed");
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1761 break;
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1762 }
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1763 }
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1764 }
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1765 else
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1766 retval = Array<int> (a);
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1767 }
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1768 }
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1769
4044
9678c5526190 [project @ 2002-08-15 16:54:55 by jwe]
jwe
parents: 4038
diff changeset
1770
9678c5526190 [project @ 2002-08-15 16:54:55 by jwe]
jwe
parents: 4038
diff changeset
1771 if (error_state)
9678c5526190 [project @ 2002-08-15 16:54:55 by jwe]
jwe
parents: 4038
diff changeset
1772 return retval;
9678c5526190 [project @ 2002-08-15 16:54:55 by jwe]
jwe
parents: 4038
diff changeset
1773 else
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1774 return retval.reshape (make_vector_dims (retval.dims (),
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1775 force_vector_conversion,
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1776 type_name (), "integer vector"));
4044
9678c5526190 [project @ 2002-08-15 16:54:55 by jwe]
jwe
parents: 4038
diff changeset
1777 }
9678c5526190 [project @ 2002-08-15 16:54:55 by jwe]
jwe
parents: 4038
diff changeset
1778
8811
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1779 template <class T>
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1780 static Array<octave_idx_type>
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1781 convert_to_octave_idx_type_array (const Array<octave_int<T> >& A)
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1782 {
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1783 Array<octave_idx_type> retval (A.dims ());
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1784 octave_idx_type n = A.numel ();
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1785
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1786 for (octave_idx_type i = 0; i < n; i++)
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1787 retval.xelem (i) = octave_int<octave_idx_type> (A.xelem (i));
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1788
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1789 return retval;
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1790 }
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1791
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1792 Array<octave_idx_type>
9479
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 9368
diff changeset
1793 octave_value::octave_idx_type_vector_value (bool require_int,
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 9368
diff changeset
1794 bool force_string_conv,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1795 bool force_vector_conversion) const
8811
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1796 {
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1797 Array<octave_idx_type> retval;
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1798
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1799 if (is_integer_type ())
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1800 {
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1801 if (is_int32_type ())
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1802 retval = convert_to_octave_idx_type_array (int32_array_value ());
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1803 else if (is_int64_type ())
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1804 retval = convert_to_octave_idx_type_array (int64_array_value ());
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1805 else if (is_int16_type ())
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1806 retval = convert_to_octave_idx_type_array (int16_array_value ());
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1807 else if (is_int8_type ())
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1808 retval = convert_to_octave_idx_type_array (int8_array_value ());
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1809 else if (is_uint32_type ())
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1810 retval = convert_to_octave_idx_type_array (uint32_array_value ());
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1811 else if (is_uint64_type ())
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1812 retval = convert_to_octave_idx_type_array (uint64_array_value ());
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1813 else if (is_uint16_type ())
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1814 retval = convert_to_octave_idx_type_array (uint16_array_value ());
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1815 else if (is_uint8_type ())
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1816 retval = convert_to_octave_idx_type_array (uint8_array_value ());
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1817 else
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1818 retval = array_value (force_string_conv);
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1819 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1820 else
8811
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1821 {
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1822 const NDArray a = array_value (force_string_conv);
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1823 if (! error_state)
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1824 {
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1825 if (require_int)
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1826 {
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1827 retval.resize (a.dims ());
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1828 for (octave_idx_type i = 0; i < a.numel (); i++)
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1829 {
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1830 double ai = a.elem (i);
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1831 octave_idx_type v = static_cast<octave_idx_type> (ai);
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1832 if (ai == v)
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1833 retval.xelem (i) = v;
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1834 else
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1835 {
9753
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
1836 error_with_cfn ("conversion to integer value failed");
8811
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1837 break;
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1838 }
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1839 }
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1840 }
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1841 else
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1842 retval = Array<octave_idx_type> (a);
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1843 }
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1844 }
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1845
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1846
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1847 if (error_state)
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1848 return retval;
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1849 else
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1850 return retval.reshape (make_vector_dims (retval.dims (),
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1851 force_vector_conversion,
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1852 type_name (), "integer vector"));
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1853 }
20dfb885f877 int -> octave_idx fixes
John W. Eaton <jwe@octave.org>
parents: 8551
diff changeset
1854
3419
e71b3d1dd327 [project @ 2000-01-12 05:23:34 by jwe]
jwe
parents: 3418
diff changeset
1855 Array<Complex>
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1856 octave_value::complex_vector_value (bool force_string_conv,
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1857 bool force_vector_conversion) const
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1858 {
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1859 Array<Complex> retval = complex_array_value (force_string_conv);
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1860
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1861 if (error_state)
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1862 return retval;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1863 else
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1864 return retval.reshape (make_vector_dims (retval.dims (),
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1865 force_vector_conversion,
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1866 type_name (), "complex vector"));
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1867 }
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1868
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1869 FloatColumnVector
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1870 octave_value::float_column_vector_value (bool force_string_conv,
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1871 bool frc_vec_conv) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1872 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1873 return FloatColumnVector (float_vector_value (force_string_conv,
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1874 frc_vec_conv));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1875 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1876
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1877 FloatComplexColumnVector
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1878 octave_value::float_complex_column_vector_value (bool force_string_conv,
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1879 bool frc_vec_conv) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1880 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1881 return
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1882 FloatComplexColumnVector (float_complex_vector_value (force_string_conv,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1883 frc_vec_conv));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1884 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1885
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1886 FloatRowVector
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1887 octave_value::float_row_vector_value (bool force_string_conv,
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1888 bool frc_vec_conv) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1889 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1890 return FloatRowVector (float_vector_value (force_string_conv,
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1891 frc_vec_conv));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1892 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1893
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1894 FloatComplexRowVector
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1895 octave_value::float_complex_row_vector_value (bool force_string_conv,
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1896 bool frc_vec_conv) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1897 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1898 return FloatComplexRowVector (float_complex_vector_value (force_string_conv,
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1899 frc_vec_conv));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1900 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1901
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1902 Array<float>
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1903 octave_value::float_vector_value (bool force_string_conv,
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1904 bool force_vector_conversion) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1905 {
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1906 Array<float> retval = float_array_value (force_string_conv);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1907
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1908 if (error_state)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1909 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1910 else
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1911 return retval.reshape (make_vector_dims (retval.dims (),
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1912 force_vector_conversion,
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1913 type_name (), "real vector"));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1914 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1915
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1916 Array<FloatComplex>
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1917 octave_value::float_complex_vector_value (bool force_string_conv,
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1918 bool force_vector_conversion) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1919 {
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1920 Array<FloatComplex> retval = float_complex_array_value (force_string_conv);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1921
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1922 if (error_state)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1923 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1924 else
7892
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1925 return retval.reshape (make_vector_dims (retval.dims (),
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1926 force_vector_conversion,
7ca2735d74c2 simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7885
diff changeset
1927 type_name (), "complex vector"));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1928 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
1929
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1930 octave_value
8523
ad3afaaa19c1 implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8367
diff changeset
1931 octave_value::storable_value (void) const
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8039
diff changeset
1932 {
8523
ad3afaaa19c1 implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8367
diff changeset
1933 octave_value retval = *this;
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8039
diff changeset
1934 if (is_null_value ())
8523
ad3afaaa19c1 implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8367
diff changeset
1935 retval = octave_value (rep->empty_clone ());
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8039
diff changeset
1936 else
8523
ad3afaaa19c1 implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8367
diff changeset
1937 retval.maybe_economize ();
ad3afaaa19c1 implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8367
diff changeset
1938
ad3afaaa19c1 implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8367
diff changeset
1939 return retval;
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8039
diff changeset
1940 }
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8039
diff changeset
1941
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1942 void
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1943 octave_value::make_storable_value (void)
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8039
diff changeset
1944 {
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8039
diff changeset
1945 if (is_null_value ())
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8039
diff changeset
1946 {
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8039
diff changeset
1947 octave_base_value *rc = rep->empty_clone ();
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8039
diff changeset
1948 if (--rep->count == 0)
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8039
diff changeset
1949 delete rep;
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8039
diff changeset
1950 rep = rc;
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8039
diff changeset
1951 }
8523
ad3afaaa19c1 implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8367
diff changeset
1952 else
ad3afaaa19c1 implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8367
diff changeset
1953 maybe_economize ();
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8039
diff changeset
1954 }
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8039
diff changeset
1955
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4933
diff changeset
1956 int
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4933
diff changeset
1957 octave_value::write (octave_stream& os, int block_size,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1958 oct_data_conv::data_type output_type, int skip,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1959 oct_mach_info::float_format flt_fmt) const
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4933
diff changeset
1960 {
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4933
diff changeset
1961 return rep->write (os, block_size, output_type, skip, flt_fmt);
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4933
diff changeset
1962 }
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4933
diff changeset
1963
2413
44753e0cadf2 [project @ 1996-10-15 17:02:26 by jwe]
jwe
parents: 2410
diff changeset
1964 static void
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1965 gripe_binary_op (const std::string& on, const std::string& tn1,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1966 const std::string& tn2)
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1967 {
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 15428
diff changeset
1968 error ("binary operator '%s' not implemented for '%s' by '%s' operations",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1969 on.c_str (), tn1.c_str (), tn2.c_str ());
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1970 }
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1971
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
1972 static void
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3465
diff changeset
1973 gripe_binary_op_conv (const std::string& on)
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
1974 {
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 15428
diff changeset
1975 error ("type conversion failed for binary operator '%s'", on.c_str ());
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
1976 }
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
1977
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1978 octave_value
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
1979 do_binary_op (octave_value::binary_op op,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1980 const octave_value& v1, const octave_value& v2)
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1981 {
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1982 octave_value retval;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1983
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1984 int t1 = v1.type_id ();
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1985 int t2 = v2.type_id ();
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1986
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
1987 if (t1 == octave_class::static_type_id ()
18306
122239398a03 Partial support for operator overload in classdef.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17856
diff changeset
1988 || t2 == octave_class::static_type_id ()
122239398a03 Partial support for operator overload in classdef.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17856
diff changeset
1989 || t1 == octave_classdef::static_type_id ()
122239398a03 Partial support for operator overload in classdef.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17856
diff changeset
1990 || t2 == octave_classdef::static_type_id ())
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
1991 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
1992 octave_value_typeinfo::binary_class_op_fcn f
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1993 = octave_value_typeinfo::lookup_binary_class_op (op);
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1994
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
1995 if (f)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1996 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1997 try
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1998 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1999 retval = f (v1, v2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2000 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2001 catch (octave_execution_exception)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2002 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2003 gripe_library_execution_error ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2004 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
2005 }
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
2006 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2007 gripe_binary_op (octave_value::binary_op_as_string (op),
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2008 v1.class_name (), v2.class_name ());
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
2009 }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
2010 else
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
2011 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2012 // FIXME: we need to handle overloading operators for built-in
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
2013 // classes (double, char, int8, etc.)
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
2014
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
2015 octave_value_typeinfo::binary_op_fcn f
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2016 = octave_value_typeinfo::lookup_binary_op (op, t1, t2);
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
2017
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
2018 if (f)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2019 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2020 try
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2021 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2022 retval = f (*v1.rep, *v2.rep);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2023 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2024 catch (octave_execution_exception)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2025 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2026 gripe_library_execution_error ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2027 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2028 }
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
2029 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2030 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2031 octave_value tv1;
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2032 octave_base_value::type_conv_info cf1 =
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2033 v1.numeric_conversion_function ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2034
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2035 octave_value tv2;
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2036 octave_base_value::type_conv_info cf2 =
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2037 v2.numeric_conversion_function ();
8345
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 8150
diff changeset
2038
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 8150
diff changeset
2039 // Try biased (one-sided) conversions first.
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 8150
diff changeset
2040 if (cf2.type_id () >= 0 &&
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 8150
diff changeset
2041 octave_value_typeinfo::lookup_binary_op (op, t1, cf2.type_id ()))
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 8150
diff changeset
2042 cf1 = 0;
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2043 else if (cf1.type_id () >= 0
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2044 && octave_value_typeinfo::lookup_binary_op (op,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2045 cf1.type_id (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2046 t2))
8345
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 8150
diff changeset
2047 cf2 = 0;
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
2048
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2049 if (cf1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2050 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2051 octave_base_value *tmp = cf1 (*v1.rep);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2052
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2053 if (tmp)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2054 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2055 tv1 = octave_value (tmp);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2056 t1 = tv1.type_id ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2057 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2058 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2059 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2060 gripe_binary_op_conv (octave_value::binary_op_as_string (op));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2061 return retval;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2062 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2063 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2064 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2065 tv1 = v1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2066
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2067 if (cf2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2068 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2069 octave_base_value *tmp = cf2 (*v2.rep);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2070
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2071 if (tmp)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2072 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2073 tv2 = octave_value (tmp);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2074 t2 = tv2.type_id ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2075 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2076 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2077 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2078 gripe_binary_op_conv (octave_value::binary_op_as_string (op));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2079 return retval;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2080 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2081 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2082 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2083 tv2 = v2;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2084
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2085 if (cf1 || cf2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2086 {
8345
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 8150
diff changeset
2087 retval = do_binary_op (op, tv1, tv2);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2088 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2089 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2090 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2091 //demote double -> single and try again
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2092 cf1 = tv1.numeric_demotion_function ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2093
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2094 cf2 = tv2.numeric_demotion_function ();
8345
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 8150
diff changeset
2095
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 8150
diff changeset
2096 // Try biased (one-sided) conversions first.
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 8150
diff changeset
2097 if (cf2.type_id () >= 0
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2098 && octave_value_typeinfo::lookup_binary_op (op, t1,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2099 cf2.type_id ()))
8345
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 8150
diff changeset
2100 cf1 = 0;
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2101 else if (cf1.type_id () >= 0 &&
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2102 octave_value_typeinfo::lookup_binary_op (op,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2103 cf1.type_id (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2104 t2))
8345
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 8150
diff changeset
2105 cf2 = 0;
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 8150
diff changeset
2106
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2107 if (cf1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2108 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2109 octave_base_value *tmp = cf1 (*tv1.rep);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2110
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2111 if (tmp)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2112 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2113 tv1 = octave_value (tmp);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2114 t1 = tv1.type_id ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2115 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2116 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2117 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2118 gripe_binary_op_conv
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2119 (octave_value::binary_op_as_string (op));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2120 return retval;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2121 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2122 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2123
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2124 if (cf2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2125 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2126 octave_base_value *tmp = cf2 (*tv2.rep);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2127
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2128 if (tmp)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2129 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2130 tv2 = octave_value (tmp);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2131 t2 = tv2.type_id ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2132 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2133 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2134 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2135 gripe_binary_op_conv
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2136 (octave_value::binary_op_as_string (op));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2137 return retval;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2138 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2139 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2140
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2141 if (cf1 || cf2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2142 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2143 f = octave_value_typeinfo::lookup_binary_op (op, t1, t2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2144
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2145 if (f)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2146 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2147 try
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2148 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2149 retval = f (*tv1.rep, *tv2.rep);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2150 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2151 catch (octave_execution_exception)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2152 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2153 gripe_library_execution_error ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2154 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2155 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2156 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2157 gripe_binary_op (octave_value::binary_op_as_string (op),
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2158 v1.type_name (), v2.type_name ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2159 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2160 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2161 gripe_binary_op (octave_value::binary_op_as_string (op),
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2162 v1.type_name (), v2.type_name ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2163 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2164 }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
2165 }
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
2166
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
2167 return retval;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
2168 }
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
2169
7800
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2170 static octave_value
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2171 decompose_binary_op (octave_value::compound_binary_op op,
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2172 const octave_value& v1, const octave_value& v2)
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2173 {
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2174 octave_value retval;
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2175
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2176 switch (op)
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2177 {
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2178 case octave_value::op_trans_mul:
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2179 retval = do_binary_op (octave_value::op_mul,
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2180 do_unary_op (octave_value::op_transpose, v1),
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2181 v2);
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2182 break;
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2183 case octave_value::op_mul_trans:
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2184 retval = do_binary_op (octave_value::op_mul,
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2185 v1,
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2186 do_unary_op (octave_value::op_transpose, v2));
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2187 break;
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2188 case octave_value::op_herm_mul:
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2189 retval = do_binary_op (octave_value::op_mul,
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2190 do_unary_op (octave_value::op_hermitian, v1),
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2191 v2);
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2192 break;
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2193 case octave_value::op_mul_herm:
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2194 retval = do_binary_op (octave_value::op_mul,
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2195 v1,
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2196 do_unary_op (octave_value::op_hermitian, v2));
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2197 break;
9661
afcf852256d2 optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 9608
diff changeset
2198 case octave_value::op_trans_ldiv:
afcf852256d2 optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 9608
diff changeset
2199 retval = do_binary_op (octave_value::op_ldiv,
afcf852256d2 optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 9608
diff changeset
2200 do_unary_op (octave_value::op_transpose, v1),
afcf852256d2 optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 9608
diff changeset
2201 v2);
afcf852256d2 optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 9608
diff changeset
2202 break;
afcf852256d2 optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 9608
diff changeset
2203 case octave_value::op_herm_ldiv:
afcf852256d2 optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 9608
diff changeset
2204 retval = do_binary_op (octave_value::op_ldiv,
afcf852256d2 optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 9608
diff changeset
2205 do_unary_op (octave_value::op_hermitian, v1),
afcf852256d2 optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 9608
diff changeset
2206 v2);
afcf852256d2 optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 9608
diff changeset
2207 break;
8982
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
2208 case octave_value::op_el_not_and:
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
2209 retval = do_binary_op (octave_value::op_el_and,
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
2210 do_unary_op (octave_value::op_not, v1),
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
2211 v2);
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
2212 break;
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
2213 case octave_value::op_el_not_or:
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
2214 retval = do_binary_op (octave_value::op_el_or,
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
2215 do_unary_op (octave_value::op_not, v1),
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
2216 v2);
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
2217 break;
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
2218 case octave_value::op_el_and_not:
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
2219 retval = do_binary_op (octave_value::op_el_and,
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
2220 v1,
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
2221 do_unary_op (octave_value::op_not, v2));
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
2222 break;
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
2223 case octave_value::op_el_or_not:
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
2224 retval = do_binary_op (octave_value::op_el_or,
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
2225 v1,
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
2226 do_unary_op (octave_value::op_not, v2));
dc6bda6f9994 implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8960
diff changeset
2227 break;
7800
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2228 default:
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2229 error ("invalid compound operator");
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2230 break;
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2231 }
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2232
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2233 return retval;
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2234 }
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2235
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2236 octave_value
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2237 do_binary_op (octave_value::compound_binary_op op,
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2238 const octave_value& v1, const octave_value& v2)
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2239 {
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2240 octave_value retval;
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2241
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2242 int t1 = v1.type_id ();
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2243 int t2 = v2.type_id ();
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2244
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2245 if (t1 == octave_class::static_type_id ()
18306
122239398a03 Partial support for operator overload in classdef.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17856
diff changeset
2246 || t2 == octave_class::static_type_id ()
122239398a03 Partial support for operator overload in classdef.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17856
diff changeset
2247 || t1 == octave_classdef::static_type_id ()
122239398a03 Partial support for operator overload in classdef.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17856
diff changeset
2248 || t2 == octave_classdef::static_type_id ())
7800
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2249 {
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2250 octave_value_typeinfo::binary_class_op_fcn f
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2251 = octave_value_typeinfo::lookup_binary_class_op (op);
7800
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2252
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2253 if (f)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2254 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2255 try
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2256 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2257 retval = f (v1, v2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2258 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2259 catch (octave_execution_exception)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2260 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2261 gripe_library_execution_error ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2262 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
2263 }
7800
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2264 else
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2265 retval = decompose_binary_op (op, v1, v2);
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2266 }
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2267 else
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2268 {
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2269 octave_value_typeinfo::binary_op_fcn f
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2270 = octave_value_typeinfo::lookup_binary_op (op, t1, t2);
7800
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2271
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2272 if (f)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2273 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2274 try
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2275 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2276 retval = f (*v1.rep, *v2.rep);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2277 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2278 catch (octave_execution_exception)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2279 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2280 gripe_library_execution_error ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2281 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2282 }
7800
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2283 else
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2284 retval = decompose_binary_op (op, v1, v2);
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2285 }
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2286
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2287 return retval;
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2288 }
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
2289
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2290 static void
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2291 gripe_cat_op (const std::string& tn1, const std::string& tn2)
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2292 {
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 15428
diff changeset
2293 error ("concatenation operator not implemented for '%s' by '%s' operations",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2294 tn1.c_str (), tn2.c_str ());
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2295 }
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2296
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2297 static void
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2298 gripe_cat_op_conv (void)
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2299 {
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2300 error ("type conversion failed for concatenation operator");
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2301 }
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2302
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2303 octave_value
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
2304 do_cat_op (const octave_value& v1, const octave_value& v2,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2305 const Array<octave_idx_type>& ra_idx)
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2306 {
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2307 octave_value retval;
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2308
7814
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7800
diff changeset
2309 // Can't rapid return for concatenation with an empty object here as
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7800
diff changeset
2310 // something like cat(1,[],single([]) must return the correct type.
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5147
diff changeset
2311
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2312 int t1 = v1.type_id ();
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2313 int t2 = v2.type_id ();
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2314
5759
ce79d238f142 [project @ 2006-04-13 13:04:32 by jwe]
jwe
parents: 5758
diff changeset
2315 octave_value_typeinfo::cat_op_fcn f
ce79d238f142 [project @ 2006-04-13 13:04:32 by jwe]
jwe
parents: 5758
diff changeset
2316 = octave_value_typeinfo::lookup_cat_op (t1, t2);
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2317
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2318 if (f)
7487
1e01db14700b catch octave_execution_exception for built-in and mex functions
John W. Eaton <jwe@octave.org>
parents: 7433
diff changeset
2319 {
1e01db14700b catch octave_execution_exception for built-in and mex functions
John W. Eaton <jwe@octave.org>
parents: 7433
diff changeset
2320 try
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2321 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2322 retval = f (*v1.rep, *v2.rep, ra_idx);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2323 }
7487
1e01db14700b catch octave_execution_exception for built-in and mex functions
John W. Eaton <jwe@octave.org>
parents: 7433
diff changeset
2324 catch (octave_execution_exception)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2325 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2326 gripe_library_execution_error ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2327 }
7487
1e01db14700b catch octave_execution_exception for built-in and mex functions
John W. Eaton <jwe@octave.org>
parents: 7433
diff changeset
2328 }
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2329 else
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2330 {
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2331 octave_value tv1;
8345
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 8150
diff changeset
2332 octave_base_value::type_conv_info cf1 = v1.numeric_conversion_function ();
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 8150
diff changeset
2333
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 8150
diff changeset
2334 octave_value tv2;
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 8150
diff changeset
2335 octave_base_value::type_conv_info cf2 = v2.numeric_conversion_function ();
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 8150
diff changeset
2336
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 8150
diff changeset
2337 // Try biased (one-sided) conversions first.
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 8150
diff changeset
2338 if (cf2.type_id () >= 0
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 8150
diff changeset
2339 && octave_value_typeinfo::lookup_cat_op (t1, cf2.type_id ()))
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 8150
diff changeset
2340 cf1 = 0;
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 8150
diff changeset
2341 else if (cf1.type_id () >= 0
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 8150
diff changeset
2342 && octave_value_typeinfo::lookup_cat_op (cf1.type_id (), t2))
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 8150
diff changeset
2343 cf2 = 0;
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2344
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2345 if (cf1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2346 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2347 octave_base_value *tmp = cf1 (*v1.rep);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2348
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2349 if (tmp)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2350 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2351 tv1 = octave_value (tmp);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2352 t1 = tv1.type_id ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2353 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2354 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2355 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2356 gripe_cat_op_conv ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2357 return retval;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2358 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2359 }
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2360 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2361 tv1 = v1;
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2362
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2363 if (cf2)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2364 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2365 octave_base_value *tmp = cf2 (*v2.rep);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2366
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2367 if (tmp)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2368 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2369 tv2 = octave_value (tmp);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2370 t2 = tv2.type_id ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2371 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2372 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2373 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2374 gripe_cat_op_conv ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2375 return retval;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2376 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2377 }
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2378 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2379 tv2 = v2;
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2380
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2381 if (cf1 || cf2)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2382 {
8345
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 8150
diff changeset
2383 retval = do_cat_op (tv1, tv2, ra_idx);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2384 }
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2385 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2386 gripe_cat_op (v1.type_name (), v2.type_name ());
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2387 }
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2388
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2389 return retval;
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2390 }
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4911
diff changeset
2391
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2392 void
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2393 octave_value::print_info (std::ostream& os, const std::string& prefix) const
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2394 {
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2395 os << prefix << "type_name: " << type_name () << "\n"
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2396 << prefix << "count: " << get_count () << "\n"
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2397 << prefix << "rep info: ";
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2398
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2399 rep->print_info (os, prefix + " ");
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2400 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2401
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2402 static void
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3465
diff changeset
2403 gripe_unary_op (const std::string& on, const std::string& tn)
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2404 {
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 15428
diff changeset
2405 error ("unary operator '%s' not implemented for '%s' operands",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2406 on.c_str (), tn.c_str ());
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2407 }
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2408
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2409 static void
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3465
diff changeset
2410 gripe_unary_op_conv (const std::string& on)
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2411 {
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 15428
diff changeset
2412 error ("type conversion failed for unary operator '%s'", on.c_str ());
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2413 }
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2414
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2415 octave_value
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2416 do_unary_op (octave_value::unary_op op, const octave_value& v)
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2417 {
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2418 octave_value retval;
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2419
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2420 int t = v.type_id ();
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2421
18306
122239398a03 Partial support for operator overload in classdef.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17856
diff changeset
2422 if (t == octave_class::static_type_id ()
122239398a03 Partial support for operator overload in classdef.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17856
diff changeset
2423 || t == octave_classdef::static_type_id ())
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
2424 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
2425 octave_value_typeinfo::unary_class_op_fcn f
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2426 = octave_value_typeinfo::lookup_unary_class_op (op);
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2427
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
2428 if (f)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2429 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2430 try
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2431 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2432 retval = f (v);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2433 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2434 catch (octave_execution_exception)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2435 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2436 gripe_library_execution_error ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2437 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2438 }
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
2439 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2440 gripe_unary_op (octave_value::unary_op_as_string (op),
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2441 v.class_name ());
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
2442 }
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2443 else
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2444 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2445 // FIXME: we need to handle overloading operators for built-in
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
2446 // classes (double, char, int8, etc.)
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
2447
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
2448 octave_value_typeinfo::unary_op_fcn f
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2449 = octave_value_typeinfo::lookup_unary_op (op, t);
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2450
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
2451 if (f)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2452 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2453 try
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2454 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2455 retval = f (*v.rep);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2456 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2457 catch (octave_execution_exception)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2458 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2459 gripe_library_execution_error ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2460 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2461 }
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
2462 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2463 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2464 octave_value tv;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2465 octave_base_value::type_conv_fcn cf
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2466 = v.numeric_conversion_function ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2467
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2468 if (cf)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2469 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2470 octave_base_value *tmp = cf (*v.rep);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2471
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2472 if (tmp)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2473 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2474 tv = octave_value (tmp);
8345
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 8150
diff changeset
2475 retval = do_unary_op (op, tv);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2476 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2477 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2478 gripe_unary_op_conv (octave_value::unary_op_as_string (op));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2479 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2480 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2481 gripe_unary_op (octave_value::unary_op_as_string (op),
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2482 v.type_name ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2483 }
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2484 }
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2485
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2486 return retval;
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2487 }
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2488
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2489 static void
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2490 gripe_unary_op_conversion_failed (const std::string& op,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2491 const std::string& tn)
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2492 {
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 15428
diff changeset
2493 error ("operator %s: type conversion for '%s' failed",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2494 op.c_str (), tn.c_str ());
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2495 }
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2496
10614
d1194069e58c optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents: 10544
diff changeset
2497 octave_value&
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2498 octave_value::do_non_const_unary_op (unary_op op)
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2499 {
9607
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2500 if (op == op_incr || op == op_decr)
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2501 {
10614
d1194069e58c optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents: 10544
diff changeset
2502 // We want the gripe just here, because in the other branch this should
d1194069e58c optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents: 10544
diff changeset
2503 // not happen, and if it did anyway (internal error), the message would
d1194069e58c optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents: 10544
diff changeset
2504 // be confusing.
d1194069e58c optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents: 10544
diff changeset
2505 if (is_undefined ())
d1194069e58c optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents: 10544
diff changeset
2506 {
d1194069e58c optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents: 10544
diff changeset
2507 std::string op_str = unary_op_as_string (op);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
2508 error ("in x%s or %sx, x must be defined first",
10614
d1194069e58c optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents: 10544
diff changeset
2509 op_str.c_str (), op_str.c_str ());
d1194069e58c optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents: 10544
diff changeset
2510 return *this;
d1194069e58c optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents: 10544
diff changeset
2511 }
d1194069e58c optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents: 10544
diff changeset
2512
9607
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2513 // Genuine.
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2514 int t = type_id ();
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2515
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2516 octave_value_typeinfo::non_const_unary_op_fcn f
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2517 = octave_value_typeinfo::lookup_non_const_unary_op (op, t);
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2518
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2519 if (f)
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2520 {
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2521 make_unique ();
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2522
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2523 try
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2524 {
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2525 f (*rep);
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2526 }
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2527 catch (octave_execution_exception)
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2528 {
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2529 gripe_library_execution_error ();
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2530 }
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2531 }
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2532 else
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2533 {
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2534 octave_base_value::type_conv_fcn cf = numeric_conversion_function ();
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2535
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2536 if (cf)
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2537 {
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2538 octave_base_value *tmp = cf (*rep);
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2539
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2540 if (tmp)
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2541 {
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2542 octave_base_value *old_rep = rep;
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2543 rep = tmp;
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2544
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2545 t = type_id ();
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2546
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2547 f = octave_value_typeinfo::lookup_non_const_unary_op (op, t);
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2548
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2549 if (f)
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2550 {
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2551 try
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2552 {
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2553 f (*rep);
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2554 }
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2555 catch (octave_execution_exception)
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2556 {
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2557 gripe_library_execution_error ();
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2558 }
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2559
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2560 if (old_rep && --old_rep->count == 0)
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2561 delete old_rep;
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2562 }
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2563 else
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2564 {
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2565 if (old_rep)
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2566 {
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2567 if (--rep->count == 0)
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2568 delete rep;
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2569
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2570 rep = old_rep;
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2571 }
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2572
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2573 gripe_unary_op (octave_value::unary_op_as_string (op),
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2574 type_name ());
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2575 }
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2576 }
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2577 else
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2578 gripe_unary_op_conversion_failed
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2579 (octave_value::unary_op_as_string (op), type_name ());
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2580 }
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2581 else
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2582 gripe_unary_op (octave_value::unary_op_as_string (op),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2583 type_name ());
9607
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2584 }
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2585 }
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2586 else
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2587 {
9607
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2588 // Non-genuine.
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2589 int t = type_id ();
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2590
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2591 octave_value_typeinfo::non_const_unary_op_fcn f = 0;
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2592
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2593 // Only attempt to operate in-place if this variable is unshared.
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2594 if (rep->count == 1)
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2595 f = octave_value_typeinfo::lookup_non_const_unary_op (op, t);
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2596
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2597 if (f)
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2598 {
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2599 try
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2600 {
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2601 f (*rep);
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2602 }
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2603 catch (octave_execution_exception)
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2604 {
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2605 gripe_library_execution_error ();
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2606 }
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2607 }
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2608 else
9607
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
2609 *this = do_unary_op (op, *this);
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2610 }
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2611
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2612 return *this;
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2613 }
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3196
diff changeset
2614
10614
d1194069e58c optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents: 10544
diff changeset
2615 octave_value&
4247
fc9a075d10fb [project @ 2002-12-30 23:05:27 by jwe]
jwe
parents: 4233
diff changeset
2616 octave_value::do_non_const_unary_op (unary_op op, const std::string& type,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2617 const std::list<octave_value_list>& idx)
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2618 {
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2619 if (idx.empty ())
10614
d1194069e58c optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents: 10544
diff changeset
2620 do_non_const_unary_op (op);
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2621 else
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2622 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2623 // FIXME: only do the following stuff if we can't find a
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2624 // specific function to call to handle the op= operation for the
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2625 // types we have.
3205
549691faa638 [project @ 1998-10-31 04:20:15 by jwe]
jwe
parents: 3204
diff changeset
2626
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2627 assign_op assop = unary_op_to_assign_op (op);
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2628
10614
d1194069e58c optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents: 10544
diff changeset
2629 assign (assop, type, idx, 1.0);
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2630 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2631
10614
d1194069e58c optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents: 10544
diff changeset
2632 return *this;
3205
549691faa638 [project @ 1998-10-31 04:20:15 by jwe]
jwe
parents: 3204
diff changeset
2633 }
549691faa638 [project @ 1998-10-31 04:20:15 by jwe]
jwe
parents: 3204
diff changeset
2634
549691faa638 [project @ 1998-10-31 04:20:15 by jwe]
jwe
parents: 3204
diff changeset
2635 octave_value::assign_op
549691faa638 [project @ 1998-10-31 04:20:15 by jwe]
jwe
parents: 3204
diff changeset
2636 octave_value::unary_op_to_assign_op (unary_op op)
549691faa638 [project @ 1998-10-31 04:20:15 by jwe]
jwe
parents: 3204
diff changeset
2637 {
549691faa638 [project @ 1998-10-31 04:20:15 by jwe]
jwe
parents: 3204
diff changeset
2638 assign_op binop = unknown_assign_op;
549691faa638 [project @ 1998-10-31 04:20:15 by jwe]
jwe
parents: 3204
diff changeset
2639
549691faa638 [project @ 1998-10-31 04:20:15 by jwe]
jwe
parents: 3204
diff changeset
2640 switch (op)
549691faa638 [project @ 1998-10-31 04:20:15 by jwe]
jwe
parents: 3204
diff changeset
2641 {
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
2642 case op_incr:
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
2643 binop = op_add_eq;
3205
549691faa638 [project @ 1998-10-31 04:20:15 by jwe]
jwe
parents: 3204
diff changeset
2644 break;
549691faa638 [project @ 1998-10-31 04:20:15 by jwe]
jwe
parents: 3204
diff changeset
2645
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
2646 case op_decr:
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
2647 binop = op_sub_eq;
3205
549691faa638 [project @ 1998-10-31 04:20:15 by jwe]
jwe
parents: 3204
diff changeset
2648 break;
549691faa638 [project @ 1998-10-31 04:20:15 by jwe]
jwe
parents: 3204
diff changeset
2649
549691faa638 [project @ 1998-10-31 04:20:15 by jwe]
jwe
parents: 3204
diff changeset
2650 default:
549691faa638 [project @ 1998-10-31 04:20:15 by jwe]
jwe
parents: 3204
diff changeset
2651 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2652 std::string on = unary_op_as_string (op);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2653 error ("operator %s: no assign operator found", on.c_str ());
3205
549691faa638 [project @ 1998-10-31 04:20:15 by jwe]
jwe
parents: 3204
diff changeset
2654 }
549691faa638 [project @ 1998-10-31 04:20:15 by jwe]
jwe
parents: 3204
diff changeset
2655 }
549691faa638 [project @ 1998-10-31 04:20:15 by jwe]
jwe
parents: 3204
diff changeset
2656
549691faa638 [project @ 1998-10-31 04:20:15 by jwe]
jwe
parents: 3204
diff changeset
2657 return binop;
549691faa638 [project @ 1998-10-31 04:20:15 by jwe]
jwe
parents: 3204
diff changeset
2658 }
549691faa638 [project @ 1998-10-31 04:20:15 by jwe]
jwe
parents: 3204
diff changeset
2659
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
2660 octave_value::binary_op
3204
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2661 octave_value::op_eq_to_binary_op (assign_op op)
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2662 {
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2663 binary_op binop = unknown_binary_op;
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2664
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2665 switch (op)
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2666 {
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
2667 case op_add_eq:
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
2668 binop = op_add;
3204
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2669 break;
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2670
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
2671 case op_sub_eq:
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
2672 binop = op_sub;
3204
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2673 break;
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2674
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
2675 case op_mul_eq:
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
2676 binop = op_mul;
3204
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2677 break;
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2678
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
2679 case op_div_eq:
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
2680 binop = op_div;
3204
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2681 break;
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2682
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
2683 case op_ldiv_eq:
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
2684 binop = op_ldiv;
3204
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2685 break;
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2686
4018
a8621d87fbf5 [project @ 2002-08-05 03:17:25 by jwe]
jwe
parents: 4005
diff changeset
2687 case op_pow_eq:
a8621d87fbf5 [project @ 2002-08-05 03:17:25 by jwe]
jwe
parents: 4005
diff changeset
2688 binop = op_pow;
a8621d87fbf5 [project @ 2002-08-05 03:17:25 by jwe]
jwe
parents: 4005
diff changeset
2689 break;
a8621d87fbf5 [project @ 2002-08-05 03:17:25 by jwe]
jwe
parents: 4005
diff changeset
2690
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
2691 case op_lshift_eq:
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
2692 binop = op_lshift;
3204
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2693 break;
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2694
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
2695 case op_rshift_eq:
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
2696 binop = op_rshift;
3204
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2697 break;
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2698
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
2699 case op_el_mul_eq:
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
2700 binop = op_el_mul;
3204
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2701 break;
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2702
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
2703 case op_el_div_eq:
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
2704 binop = op_el_div;
3204
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2705 break;
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2706
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
2707 case op_el_ldiv_eq:
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
2708 binop = op_el_ldiv;
3204
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2709 break;
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2710
4018
a8621d87fbf5 [project @ 2002-08-05 03:17:25 by jwe]
jwe
parents: 4005
diff changeset
2711 case op_el_pow_eq:
a8621d87fbf5 [project @ 2002-08-05 03:17:25 by jwe]
jwe
parents: 4005
diff changeset
2712 binop = op_el_pow;
a8621d87fbf5 [project @ 2002-08-05 03:17:25 by jwe]
jwe
parents: 4005
diff changeset
2713 break;
a8621d87fbf5 [project @ 2002-08-05 03:17:25 by jwe]
jwe
parents: 4005
diff changeset
2714
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
2715 case op_el_and_eq:
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
2716 binop = op_el_and;
3204
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2717 break;
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2718
3533
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
2719 case op_el_or_eq:
a99cf9fc22fe [project @ 2000-02-02 11:45:24 by jwe]
jwe
parents: 3531
diff changeset
2720 binop = op_el_or;
3204
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2721 break;
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2722
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2723 default:
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2724 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2725 std::string on = assign_op_as_string (op);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2726 error ("operator %s: no binary operator found", on.c_str ());
3204
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2727 }
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2728 }
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2729
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2730 return binop;
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2731 }
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2732
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2733 octave_value
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2734 octave_value::empty_conv (const std::string& type, const octave_value& rhs)
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2735 {
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2736 octave_value retval;
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2737
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2738 if (type.length () > 0)
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2739 {
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2740 switch (type[0])
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2741 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2742 case '(':
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2743 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2744 if (type.length () > 1 && type[1] == '.')
10754
92eb5fb58ebc fix resize with structs
Jaroslav Hajek <highegg@gmail.com>
parents: 10753
diff changeset
2745 retval = octave_map ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2746 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2747 retval = octave_value (rhs.empty_clone ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2748 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2749 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2750
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2751 case '{':
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2752 retval = Cell ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2753 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2754
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2755 case '.':
10754
92eb5fb58ebc fix resize with structs
Jaroslav Hajek <highegg@gmail.com>
parents: 10753
diff changeset
2756 retval = octave_scalar_map ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2757 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2758
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2759 default:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2760 panic_impossible ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2761 }
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2762 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2763 else
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2764 retval = octave_value (rhs.empty_clone ());
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2765
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2766 return retval;
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2767 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
2768
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
2769 void
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
2770 install_types (void)
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
2771 {
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
2772 octave_base_value::register_type ();
3928
e8627dc4bdf2 [project @ 2002-05-03 19:56:01 by jwe]
jwe
parents: 3546
diff changeset
2773 octave_cell::register_type ();
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
2774 octave_scalar::register_type ();
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
2775 octave_complex::register_type ();
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
2776 octave_matrix::register_type ();
8366
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8346
diff changeset
2777 octave_diag_matrix::register_type ();
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
2778 octave_complex_matrix::register_type ();
8366
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8346
diff changeset
2779 octave_complex_diag_matrix::register_type ();
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
2780 octave_range::register_type ();
2825
60ae49e1284f [project @ 1997-03-25 23:17:36 by jwe]
jwe
parents: 2800
diff changeset
2781 octave_bool::register_type ();
60ae49e1284f [project @ 1997-03-25 23:17:36 by jwe]
jwe
parents: 2800
diff changeset
2782 octave_bool_matrix::register_type ();
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
2783 octave_char_matrix_str::register_type ();
5279
bd32f770c09a [project @ 2005-04-12 21:55:31 by jwe]
jwe
parents: 5275
diff changeset
2784 octave_char_matrix_sq_str::register_type ();
4901
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
2785 octave_int8_scalar::register_type ();
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
2786 octave_int16_scalar::register_type ();
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
2787 octave_int32_scalar::register_type ();
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
2788 octave_int64_scalar::register_type ();
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
2789 octave_uint8_scalar::register_type ();
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
2790 octave_uint16_scalar::register_type ();
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
2791 octave_uint32_scalar::register_type ();
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
2792 octave_uint64_scalar::register_type ();
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
2793 octave_int8_matrix::register_type ();
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
2794 octave_int16_matrix::register_type ();
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
2795 octave_int32_matrix::register_type ();
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
2796 octave_int64_matrix::register_type ();
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
2797 octave_uint8_matrix::register_type ();
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
2798 octave_uint16_matrix::register_type ();
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
2799 octave_uint32_matrix::register_type ();
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents: 4894
diff changeset
2800 octave_uint64_matrix::register_type ();
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5147
diff changeset
2801 octave_sparse_bool_matrix::register_type ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5147
diff changeset
2802 octave_sparse_matrix::register_type ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5147
diff changeset
2803 octave_sparse_complex_matrix::register_type ();
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
2804 octave_struct::register_type ();
10753
bee1b1a2e29a yield compatible dims from cell2struct + more fixes. build & tests OK
Jaroslav Hajek <highegg@gmail.com>
parents: 10742
diff changeset
2805 octave_scalar_struct::register_type ();
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7065
diff changeset
2806 octave_class::register_type ();
3977
95663a3a2682 [project @ 2002-07-05 17:43:37 by jwe]
jwe
parents: 3961
diff changeset
2807 octave_cs_list::register_type ();
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
2808 octave_magic_colon::register_type ();
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents: 2963
diff changeset
2809 octave_builtin::register_type ();
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents: 2963
diff changeset
2810 octave_user_function::register_type ();
4649
f7ce581b27fb [project @ 2003-11-23 21:46:44 by jwe]
jwe
parents: 4645
diff changeset
2811 octave_dld_function::register_type ();
4643
ef3a14fb6847 [project @ 2003-11-22 12:25:44 by jwe]
jwe
parents: 4591
diff changeset
2812 octave_fcn_handle::register_type ();
4966
91b61d27b9b4 [project @ 2004-09-07 02:01:22 by jwe]
jwe
parents: 4965
diff changeset
2813 octave_fcn_inline::register_type ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
2814 octave_float_scalar::register_type ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
2815 octave_float_complex::register_type ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
2816 octave_float_matrix::register_type ();
8366
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8346
diff changeset
2817 octave_float_diag_matrix::register_type ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7761
diff changeset
2818 octave_float_complex_matrix::register_type ();
8366
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8346
diff changeset
2819 octave_float_complex_diag_matrix::register_type ();
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
2820 octave_perm_matrix::register_type ();
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8039
diff changeset
2821 octave_null_matrix::register_type ();
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8039
diff changeset
2822 octave_null_str::register_type ();
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8039
diff changeset
2823 octave_null_sq_str::register_type ();
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
2824 octave_lazy_index::register_type ();
14013
1734ebe27134 move onCleanup function and class to liboctinterp
John W. Eaton <jwe@octave.org>
parents: 13932
diff changeset
2825 octave_oncleanup::register_type ();
15767
e665645fb402 only register java type if using java
John W. Eaton <jwe@octave.org>
parents: 15754
diff changeset
2826 #ifdef HAVE_JAVA
15754
bf77f7f66bdf register octave_java type at Octave startup
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
2827 octave_java::register_type ();
15767
e665645fb402 only register java type if using java
John W. Eaton <jwe@octave.org>
parents: 15754
diff changeset
2828 #endif
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
2829 }
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
2830
4791
62f2fb593455 [project @ 2004-02-20 18:02:59 by jwe]
jwe
parents: 4700
diff changeset
2831 DEFUN (sizeof, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2832 "-*- texinfo -*-\n\
4791
62f2fb593455 [project @ 2004-02-20 18:02:59 by jwe]
jwe
parents: 4700
diff changeset
2833 @deftypefn {Built-in Function} {} sizeof (@var{val})\n\
10687
a8ce6bdecce5 Improve documentation strings.
Rik <octave@nomad.inbox5.com>
parents: 10654
diff changeset
2834 Return the size of @var{val} in bytes.\n\
a8ce6bdecce5 Improve documentation strings.
Rik <octave@nomad.inbox5.com>
parents: 10654
diff changeset
2835 @seealso{whos}\n\
4791
62f2fb593455 [project @ 2004-02-20 18:02:59 by jwe]
jwe
parents: 4700
diff changeset
2836 @end deftypefn")
62f2fb593455 [project @ 2004-02-20 18:02:59 by jwe]
jwe
parents: 4700
diff changeset
2837 {
62f2fb593455 [project @ 2004-02-20 18:02:59 by jwe]
jwe
parents: 4700
diff changeset
2838 octave_value retval;
62f2fb593455 [project @ 2004-02-20 18:02:59 by jwe]
jwe
parents: 4700
diff changeset
2839
62f2fb593455 [project @ 2004-02-20 18:02:59 by jwe]
jwe
parents: 4700
diff changeset
2840 if (args.length () == 1)
62f2fb593455 [project @ 2004-02-20 18:02:59 by jwe]
jwe
parents: 4700
diff changeset
2841 retval = args(0).byte_size ();
62f2fb593455 [project @ 2004-02-20 18:02:59 by jwe]
jwe
parents: 4700
diff changeset
2842 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5785
diff changeset
2843 print_usage ();
4791
62f2fb593455 [project @ 2004-02-20 18:02:59 by jwe]
jwe
parents: 4700
diff changeset
2844
62f2fb593455 [project @ 2004-02-20 18:02:59 by jwe]
jwe
parents: 4700
diff changeset
2845 return retval;
62f2fb593455 [project @ 2004-02-20 18:02:59 by jwe]
jwe
parents: 4700
diff changeset
2846 }
62f2fb593455 [project @ 2004-02-20 18:02:59 by jwe]
jwe
parents: 4700
diff changeset
2847
13100
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
2848 /*
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
2849 %!assert (sizeof (uint64 (ones (3))), 72)
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
2850 %!assert (sizeof (double (zeros (2,4))), 64)
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
2851 %!assert (sizeof ({"foo", "bar", "baaz"}), 10)
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
2852 */
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
2853
13932
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2854 static void
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2855 decode_subscripts (const char* name, const octave_value& arg,
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2856 std::string& type_string,
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2857 std::list<octave_value_list>& idx)
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2858 {
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2859 const octave_map m = arg.map_value ();
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2860
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2861 if (! error_state
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2862 && m.nfields () == 2 && m.contains ("type") && m.contains ("subs"))
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2863 {
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2864 octave_idx_type nel = m.numel ();
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2865
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2866 type_string = std::string (nel, '\0');
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2867 idx = std::list<octave_value_list> ();
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2868
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2869 if (nel == 0)
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2870 return;
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2871
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2872 const Cell type = m.contents ("type");
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2873 const Cell subs = m.contents ("subs");
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2874
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2875 for (int k = 0; k < nel; k++)
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2876 {
19437
03067dab10ca Use stricter input validation when looking for a string as input (bug #42651).
Rik <rik@octave.org>
parents: 19432
diff changeset
2877 if (type(k).is_string ())
13932
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2878 {
19437
03067dab10ca Use stricter input validation when looking for a string as input (bug #42651).
Rik <rik@octave.org>
parents: 19432
diff changeset
2879 std::string item = type(k).string_value ();
13932
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2880 if (item == "{}")
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2881 type_string[k] = '{';
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2882 else if (item == "()")
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2883 type_string[k] = '(';
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2884 else if (item == ".")
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2885 type_string[k] = '.';
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2886 else
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2887 {
15467
049e8bbff782 maint: periodic merge of stable to default
John W. Eaton <jwe@octave.org>
parents: 15466 15429
diff changeset
2888 error ("%s: invalid indexing type '%s'", name, item.c_str ());
13932
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2889 return;
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2890 }
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2891 }
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2892 else
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2893 {
19437
03067dab10ca Use stricter input validation when looking for a string as input (bug #42651).
Rik <rik@octave.org>
parents: 19432
diff changeset
2894 error ("%s: type(%d) must be a string", name, k+1);
13932
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2895 return;
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2896 }
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2897
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2898 octave_value_list idx_item;
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2899
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2900 if (subs(k).is_string ())
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2901 idx_item(0) = subs(k);
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2902 else if (subs(k).is_cell ())
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2903 {
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2904 Cell subs_cell = subs(k).cell_value ();
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2905
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2906 for (int n = 0; n < subs_cell.length (); n++)
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2907 {
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2908 if (subs_cell(n).is_string ()
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2909 && subs_cell(n).string_value () == ":")
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2910 idx_item(n) = octave_value(octave_value::magic_colon_t);
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2911 else
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2912 idx_item(n) = subs_cell(n);
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2913 }
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2914 }
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2915 else
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2916 {
19437
03067dab10ca Use stricter input validation when looking for a string as input (bug #42651).
Rik <rik@octave.org>
parents: 19432
diff changeset
2917 error ("%s: subs(%d) must be a string or cell array", name, k+1);
13932
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2918 return;
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2919 }
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2920
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2921 idx.push_back (idx_item);
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2922 }
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2923 }
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2924 else
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2925 error ("%s: second argument must be a structure with fields 'type' and 'subs'",
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2926 name);
13932
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2927 }
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2928
6153
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2929 DEFUN (subsref, args, nargout,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2930 "-*- texinfo -*-\n\
6153
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2931 @deftypefn {Built-in Function} {} subsref (@var{val}, @var{idx})\n\
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2932 Perform the subscripted element selection operation according to\n\
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2933 the subscript specified by @var{idx}.\n\
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2934 \n\
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2935 The subscript @var{idx} is expected to be a structure array with\n\
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2936 fields @samp{type} and @samp{subs}. Valid values for @samp{type}\n\
6550
1b7a6061a05d [project @ 2007-04-20 07:40:26 by jwe]
jwe
parents: 6338
diff changeset
2937 are @samp{\"()\"}, @samp{\"@{@}\"}, and @samp{\".\"}.\n\
6153
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2938 The @samp{subs} field may be either @samp{\":\"} or a cell array\n\
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2939 of index values.\n\
6631
1b8daf8c0397 [project @ 2007-05-16 16:11:55 by jwe]
jwe
parents: 6550
diff changeset
2940 \n\
18533
ea0d4dea1a17 doc: Update documentation for functions in octave-value dir.
Rik <rik@octave.org>
parents: 17787
diff changeset
2941 The following example shows how to extract the first two columns of\n\
6631
1b8daf8c0397 [project @ 2007-05-16 16:11:55 by jwe]
jwe
parents: 6550
diff changeset
2942 a matrix\n\
1b8daf8c0397 [project @ 2007-05-16 16:11:55 by jwe]
jwe
parents: 6550
diff changeset
2943 \n\
1b8daf8c0397 [project @ 2007-05-16 16:11:55 by jwe]
jwe
parents: 6550
diff changeset
2944 @example\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8992
diff changeset
2945 @group\n\
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14528
diff changeset
2946 val = magic (3)\n\
14360
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
2947 @result{} val = [ 8 1 6\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
2948 3 5 7\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
2949 4 9 2 ]\n\
6631
1b8daf8c0397 [project @ 2007-05-16 16:11:55 by jwe]
jwe
parents: 6550
diff changeset
2950 idx.type = \"()\";\n\
1b8daf8c0397 [project @ 2007-05-16 16:11:55 by jwe]
jwe
parents: 6550
diff changeset
2951 idx.subs = @{\":\", 1:2@};\n\
14360
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
2952 subsref (val, idx)\n\
12642
f96b9b9f141b doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents: 12171
diff changeset
2953 @result{} [ 8 1\n\
f96b9b9f141b doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents: 12171
diff changeset
2954 3 5\n\
6631
1b8daf8c0397 [project @ 2007-05-16 16:11:55 by jwe]
jwe
parents: 6550
diff changeset
2955 4 9 ]\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8992
diff changeset
2956 @end group\n\
6631
1b8daf8c0397 [project @ 2007-05-16 16:11:55 by jwe]
jwe
parents: 6550
diff changeset
2957 @end example\n\
1b8daf8c0397 [project @ 2007-05-16 16:11:55 by jwe]
jwe
parents: 6550
diff changeset
2958 \n\
1b8daf8c0397 [project @ 2007-05-16 16:11:55 by jwe]
jwe
parents: 6550
diff changeset
2959 @noindent\n\
1b8daf8c0397 [project @ 2007-05-16 16:11:55 by jwe]
jwe
parents: 6550
diff changeset
2960 Note that this is the same as writing @code{val(:,1:2)}.\n\
13932
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2961 \n\
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2962 If @var{idx} is an empty structure array with fields @samp{type}\n\
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2963 and @samp{subs}, return @var{val}.\n\
6157
045038e0108a [project @ 2006-11-13 22:22:53 by jwe]
jwe
parents: 6153
diff changeset
2964 @seealso{subsasgn, substruct}\n\
6153
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2965 @end deftypefn")
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2966 {
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2967 octave_value_list retval;
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2968
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2969 if (args.length () == 2)
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2970 {
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2971 std::string type;
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2972 std::list<octave_value_list> idx;
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2973
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2974 decode_subscripts ("subsref", args(1), type, idx);
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2975
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2976 if (! error_state)
10075
84b0725f4b09 return class types by reference in const Array element access functions
Jaroslav Hajek <highegg@gmail.com>
parents: 10033
diff changeset
2977 {
13932
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2978 octave_value arg0 = args(0);
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2979
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2980 if (type.empty ())
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2981 retval = arg0;
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2982 else
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
2983 retval = arg0.subsref (type, idx, nargout);
10075
84b0725f4b09 return class types by reference in const Array element access functions
Jaroslav Hajek <highegg@gmail.com>
parents: 10033
diff changeset
2984 }
6153
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2985 }
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2986 else
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2987 print_usage ();
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2988
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2989 return retval;
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2990 }
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2991
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2992 DEFUN (subsasgn, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2993 "-*- texinfo -*-\n\
6153
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2994 @deftypefn {Built-in Function} {} subsasgn (@var{val}, @var{idx}, @var{rhs})\n\
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2995 Perform the subscripted assignment operation according to\n\
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2996 the subscript specified by @var{idx}.\n\
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2997 \n\
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2998 The subscript @var{idx} is expected to be a structure array with\n\
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
2999 fields @samp{type} and @samp{subs}. Valid values for @samp{type}\n\
6248
7fad1fad19e1 [project @ 2007-01-22 17:28:17 by jwe]
jwe
parents: 6157
diff changeset
3000 are @samp{\"()\"}, @samp{\"@{@}\"}, and @samp{\".\"}.\n\
6153
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
3001 The @samp{subs} field may be either @samp{\":\"} or a cell array\n\
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
3002 of index values.\n\
6631
1b8daf8c0397 [project @ 2007-05-16 16:11:55 by jwe]
jwe
parents: 6550
diff changeset
3003 \n\
1b8daf8c0397 [project @ 2007-05-16 16:11:55 by jwe]
jwe
parents: 6550
diff changeset
3004 The following example shows how to set the two first columns of a\n\
1b8daf8c0397 [project @ 2007-05-16 16:11:55 by jwe]
jwe
parents: 6550
diff changeset
3005 3-by-3 matrix to zero.\n\
1b8daf8c0397 [project @ 2007-05-16 16:11:55 by jwe]
jwe
parents: 6550
diff changeset
3006 \n\
1b8daf8c0397 [project @ 2007-05-16 16:11:55 by jwe]
jwe
parents: 6550
diff changeset
3007 @example\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8992
diff changeset
3008 @group\n\
14360
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
3009 val = magic (3);\n\
6631
1b8daf8c0397 [project @ 2007-05-16 16:11:55 by jwe]
jwe
parents: 6550
diff changeset
3010 idx.type = \"()\";\n\
1b8daf8c0397 [project @ 2007-05-16 16:11:55 by jwe]
jwe
parents: 6550
diff changeset
3011 idx.subs = @{\":\", 1:2@};\n\
1b8daf8c0397 [project @ 2007-05-16 16:11:55 by jwe]
jwe
parents: 6550
diff changeset
3012 subsasgn (val, idx, 0)\n\
14360
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
3013 @result{} [ 0 0 6\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
3014 0 0 7\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
3015 0 0 2 ]\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8992
diff changeset
3016 @end group\n\
6631
1b8daf8c0397 [project @ 2007-05-16 16:11:55 by jwe]
jwe
parents: 6550
diff changeset
3017 @end example\n\
1b8daf8c0397 [project @ 2007-05-16 16:11:55 by jwe]
jwe
parents: 6550
diff changeset
3018 \n\
1b8daf8c0397 [project @ 2007-05-16 16:11:55 by jwe]
jwe
parents: 6550
diff changeset
3019 Note that this is the same as writing @code{val(:,1:2) = 0}.\n\
13932
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3020 \n\
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3021 If @var{idx} is an empty structure array with fields @samp{type}\n\
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3022 and @samp{subs}, return @var{rhs}.\n\
6157
045038e0108a [project @ 2006-11-13 22:22:53 by jwe]
jwe
parents: 6153
diff changeset
3023 @seealso{subsref, substruct}\n\
6153
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
3024 @end deftypefn")
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
3025 {
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
3026 octave_value retval;
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
3027
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
3028 if (args.length () == 3)
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
3029 {
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
3030 std::string type;
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
3031 std::list<octave_value_list> idx;
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
3032
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
3033 decode_subscripts ("subsasgn", args(1), type, idx);
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
3034
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
3035 if (! error_state)
13932
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3036 {
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3037 if (type.empty ())
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3038 {
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3039 // Regularize a null matrix if stored into a variable.
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3040
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3041 retval = args(2).storable_value ();
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3042 }
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3043 else
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3044 {
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3045 octave_value arg0 = args(0);
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3046
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3047 arg0.make_unique ();
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3048
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3049 if (! error_state)
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3050 retval= arg0.subsasgn (type, idx, args(2));
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3051 }
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3052 }
6153
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
3053 }
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
3054 else
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
3055 print_usage ();
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
3056
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
3057 return retval;
e60688a1ea07 [project @ 2006-11-13 17:30:54 by jwe]
jwe
parents: 5851
diff changeset
3058 }
13100
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3059
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3060 /*
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3061 %!test
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3062 %! a = reshape ([1:25], 5,5);
13932
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3063 %! idx1 = substruct ("()", {3, 3});
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3064 %! idx2 = substruct ("()", {2:2:5, 2:2:5});
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3065 %! idx3 = substruct ("()", {":", [1,5]});
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3066 %! idx4 = struct ("type", {}, "subs", {});
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3067 %! assert (subsref (a, idx1), 13);
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3068 %! assert (subsref (a, idx2), [7 17; 9 19]);
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3069 %! assert (subsref (a, idx3), [1:5; 21:25]');
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3070 %! assert (subsref (a, idx4), a);
13100
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3071 %! a = subsasgn (a, idx1, 0);
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3072 %! a = subsasgn (a, idx2, 0);
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3073 %! a = subsasgn (a, idx3, 0);
13932
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3074 %!# a = subsasgn (a, idx4, 0);
13100
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3075 %! b = [0 6 11 16 0
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3076 %! 0 0 12 0 0
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3077 %! 0 8 0 18 0
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3078 %! 0 0 14 0 0
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3079 %! 0 10 15 20 0];
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
3080 %! assert (a, b);
13100
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3081
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3082 %!test
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3083 %! c = num2cell (reshape ([1:25],5,5));
13932
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3084 %! idx1 = substruct ("{}", {3, 3});
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3085 %! idx2 = substruct ("()", {2:2:5, 2:2:5});
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3086 %! idx3 = substruct ("()", {":", [1,5]});
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3087 %! idx2p = substruct ("{}", {2:2:5, 2:2:5});
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3088 %! idx3p = substruct ("{}", {":", [1,5]});
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3089 %! idx4 = struct ("type", {}, "subs", {});
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3090 %! assert ({ subsref(c, idx1) }, {13});
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3091 %! assert ({ subsref(c, idx2p) }, {7 9 17 19});
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3092 %! assert ({ subsref(c, idx3p) }, num2cell ([1:5, 21:25]));
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14528
diff changeset
3093 %! assert (subsref (c, idx4), c);
13100
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3094 %! c = subsasgn (c, idx1, 0);
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3095 %! c = subsasgn (c, idx2, 0);
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3096 %! c = subsasgn (c, idx3, 0);
13932
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3097 %!# c = subsasgn (c, idx4, 0);
13100
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3098 %! d = {0 6 11 16 0
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3099 %! 0 0 12 0 0
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3100 %! 0 8 0 18 0
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3101 %! 0 0 14 0 0
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3102 %! 0 10 15 20 0};
13932
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3103 %! assert (c, d);
13100
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3104
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3105 %!test
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3106 %! s.a = "ohai";
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3107 %! s.b = "dere";
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3108 %! s.c = 42;
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3109 %! idx1 = substruct (".", "a");
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3110 %! idx2 = substruct (".", "b");
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3111 %! idx3 = substruct (".", "c");
13932
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3112 %! idx4 = struct ("type", {}, "subs", {});
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3113 %! assert (subsref (s, idx1), "ohai");
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3114 %! assert (subsref (s, idx2), "dere");
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3115 %! assert (subsref (s, idx3), 42);
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3116 %! assert (subsref (s, idx4), s);
13100
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3117 %! s = subsasgn (s, idx1, "Hello");
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3118 %! s = subsasgn (s, idx2, "There");
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3119 %! s = subsasgn (s, idx3, 163);
13932
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3120 %!# s = subsasgn (s, idx4, 163);
13100
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3121 %! t.a = "Hello";
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3122 %! t.b = "There";
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3123 %! t.c = 163;
13932
6ead4dc1ca55 subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents: 13793
diff changeset
3124 %! assert (s, t);
13100
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3125 */
06bf445ee778 Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12642
diff changeset
3126
13712
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3127 DEFUN (is_sq_string, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3128 "-*- texinfo -*-\n\
13793
605729cc5bbf Add seealso links to docstrings for is_sq_string and is_dq_string
Rik <octave@nomad.inbox5.com>
parents: 13712
diff changeset
3129 @deftypefn {Built-in Function} {} is_sq_string (@var{x})\n\
605729cc5bbf Add seealso links to docstrings for is_sq_string and is_dq_string
Rik <octave@nomad.inbox5.com>
parents: 13712
diff changeset
3130 Return true if @var{x} is a single-quoted character string.\n\
605729cc5bbf Add seealso links to docstrings for is_sq_string and is_dq_string
Rik <octave@nomad.inbox5.com>
parents: 13712
diff changeset
3131 @seealso{is_dq_string, ischar}\n\
13712
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3132 @end deftypefn")
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3133 {
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3134 octave_value retval;
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3135
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3136 if (args.length () == 1)
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3137 retval = args(0).is_sq_string ();
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3138 else
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3139 print_usage ();
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3140
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3141 return retval;
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3142 }
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3143
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3144 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
3145 %!assert (is_sq_string ('foo'), true)
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
3146 %!assert (is_sq_string ("foo"), false)
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
3147 %!assert (is_sq_string (1.0), false)
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
3148 %!assert (is_sq_string ({2.0}), false)
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
3149
13712
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3150 %!error is_sq_string ()
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3151 %!error is_sq_string ('foo', 2)
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3152 */
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3153
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3154 DEFUN (is_dq_string, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3155 "-*- texinfo -*-\n\
13793
605729cc5bbf Add seealso links to docstrings for is_sq_string and is_dq_string
Rik <octave@nomad.inbox5.com>
parents: 13712
diff changeset
3156 @deftypefn {Built-in Function} {} is_dq_string (@var{x})\n\
605729cc5bbf Add seealso links to docstrings for is_sq_string and is_dq_string
Rik <octave@nomad.inbox5.com>
parents: 13712
diff changeset
3157 Return true if @var{x} is a double-quoted character string.\n\
605729cc5bbf Add seealso links to docstrings for is_sq_string and is_dq_string
Rik <octave@nomad.inbox5.com>
parents: 13712
diff changeset
3158 @seealso{is_sq_string, ischar}\n\
13712
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3159 @end deftypefn")
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3160 {
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3161 octave_value retval;
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3162
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3163 if (args.length () == 1)
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3164 retval = args(0).is_dq_string ();
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3165 else
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3166 print_usage ();
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3167
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3168 return retval;
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3169 }
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3170
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3171 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
3172 %!assert (is_dq_string ("foo"), true)
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
3173 %!assert (is_dq_string ('foo'), false)
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
3174 %!assert (is_dq_string (1.0), false)
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
3175 %!assert (is_dq_string ({2.0}), false)
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
3176
13712
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3177 %!error is_dq_string ()
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3178 %!error is_dq_string ("foo", 2)
f80473f24553 new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents: 13294
diff changeset
3179 */
19425
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3180
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3181 DEFUN (disable_permutation_matrix, args, nargout,
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3182 "-*- texinfo -*-\n\
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3183 @deftypefn {Built-in Function} {@var{val} =} disable_permutation_matrix ()\n\
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3184 @deftypefnx {Built-in Function} {@var{old_val} =} disable_permutation_matrix (@var{new_val})\n\
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3185 @deftypefnx {Built-in Function} {} disable_permutation_matrix (@var{new_val}, \"local\")\n\
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3186 Query or set the internal variable that controls whether permutation\n\
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3187 matrices are stored in a special space-efficient format. The default\n\
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3188 value is true. If this option is disabled Octave will store permutation\n\
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3189 matrices as full matrices.\n\
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3190 \n\
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3191 When called from inside a function with the @qcode{\"local\"} option, the\n\
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3192 variable is changed locally for the function and any subroutines it calls.\n\
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3193 The original variable value is restored when exiting the function.\n\
19432
9e5b64b3c1fe Fix up documentation for new disable_[range,diagonal_matrix,permutation_matrix] fcns.
Rik <rik@octave.org>
parents: 19428
diff changeset
3194 @seealso{disable_range, disable_diagonal_matrix}\n\
19425
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3195 @end deftypefn")
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3196 {
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3197 return SET_INTERNAL_VARIABLE (disable_permutation_matrix);
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3198 }
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3199
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3200 /*
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3201 %!function p = __test_dpm__ (dpm)
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3202 %! disable_permutation_matrix (dpm, "local");
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3203 %! [~, ~, p] = lu ([1,2;3,4]);
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3204 %!endfunction
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3205
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3206 %!assert (typeinfo (__test_dpm__ (false)), "permutation matrix");
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3207 %!assert (typeinfo (__test_dpm__ (true)), "matrix");
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3208 */
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3209
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3210 DEFUN (disable_diagonal_matrix, args, nargout,
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3211 "-*- texinfo -*-\n\
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3212 @deftypefn {Built-in Function} {@var{val} =} disable_diagonal_matrix ()\n\
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3213 @deftypefnx {Built-in Function} {@var{old_val} =} disable_diagonal_matrix (@var{new_val})\n\
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3214 @deftypefnx {Built-in Function} {} disable_diagonal_matrix (@var{new_val}, \"local\")\n\
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3215 Query or set the internal variable that controls whether diagonal\n\
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3216 matrices are stored in a special space-efficient format. The default\n\
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3217 value is true. If this option is disabled Octave will store diagonal\n\
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3218 matrices as full matrices.\n\
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3219 \n\
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3220 When called from inside a function with the @qcode{\"local\"} option, the\n\
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3221 variable is changed locally for the function and any subroutines it calls.\n\
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3222 The original variable value is restored when exiting the function.\n\
19432
9e5b64b3c1fe Fix up documentation for new disable_[range,diagonal_matrix,permutation_matrix] fcns.
Rik <rik@octave.org>
parents: 19428
diff changeset
3223 @seealso{disable_range, disable_permutation_matrix}\n\
19425
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3224 @end deftypefn")
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3225 {
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3226 return SET_INTERNAL_VARIABLE (disable_diagonal_matrix);
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3227 }
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3228
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3229 /*
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3230 %!function [x, xi, fx, fxi] = __test_ddm__ (ddm)
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3231 %! disable_diagonal_matrix (ddm, "local");
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3232 %! x = eye (2);
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3233 %! xi = x*i;
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3234 %! fx = single (x);
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3235 %! fxi = single (xi);
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3236 %!endfunction
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3237
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3238 %!shared x, xi, fx, fxi
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3239 %! [x, xi, fx, fxi] = __test_ddm__ (false);
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3240 %!assert (typeinfo (x), "diagonal matrix");
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3241 %!assert (typeinfo (xi), "complex diagonal matrix");
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3242 %!assert (typeinfo (fx), "float diagonal matrix");
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3243 %!assert (typeinfo (fxi), "float complex diagonal matrix");
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3244
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3245 %!shared x, xi, fx, fxi
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3246 %! [x, xi, fx, fxi] = __test_ddm__ (true);
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3247 %!assert (typeinfo (x), "matrix");
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3248 %!assert (typeinfo (xi), "complex matrix");
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3249 %!assert (typeinfo (fx), "float matrix");
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3250 %!assert (typeinfo (fxi), "float complex matrix");
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 18537
diff changeset
3251 */
19428
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
3252
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
3253 DEFUN (disable_range, args, nargout,
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
3254 "-*- texinfo -*-\n\
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
3255 @deftypefn {Built-in Function} {@var{val} =} disable_range ()\n\
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
3256 @deftypefnx {Built-in Function} {@var{old_val} =} disable_range (@var{new_val})\n\
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
3257 @deftypefnx {Built-in Function} {} disable_range (@var{new_val}, \"local\")\n\
19432
9e5b64b3c1fe Fix up documentation for new disable_[range,diagonal_matrix,permutation_matrix] fcns.
Rik <rik@octave.org>
parents: 19428
diff changeset
3258 Query or set the internal variable that controls whether ranges are stored\n\
9e5b64b3c1fe Fix up documentation for new disable_[range,diagonal_matrix,permutation_matrix] fcns.
Rik <rik@octave.org>
parents: 19428
diff changeset
3259 in a special space-efficient format. The default value is true. If this\n\
9e5b64b3c1fe Fix up documentation for new disable_[range,diagonal_matrix,permutation_matrix] fcns.
Rik <rik@octave.org>
parents: 19428
diff changeset
3260 option is disabled Octave will store ranges as full matrices.\n\
19428
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
3261 \n\
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
3262 When called from inside a function with the @qcode{\"local\"} option, the\n\
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
3263 variable is changed locally for the function and any subroutines it calls.\n\
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
3264 The original variable value is restored when exiting the function.\n\
19432
9e5b64b3c1fe Fix up documentation for new disable_[range,diagonal_matrix,permutation_matrix] fcns.
Rik <rik@octave.org>
parents: 19428
diff changeset
3265 @seealso{disable_diagonal_matrix, disable_permutation_matrix}\n\
19428
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
3266 @end deftypefn")
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
3267 {
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
3268 return SET_INTERNAL_VARIABLE (disable_range);
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
3269 }
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
3270
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
3271 /*
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
3272 %!function r = __test_dr__ (dr)
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
3273 %! disable_range (dr, "local");
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
3274 %! ## Constant folding will produce range for 1:13.
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
3275 %! base = 1;
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
3276 %! limit = 13;
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
3277 %! r = base:limit;
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
3278 %!endfunction
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
3279
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
3280 %!assert (typeinfo (__test_dr__ (false)), "range");
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
3281 %!assert (typeinfo (__test_dr__ (true)), "matrix");
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
3282 */
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19425
diff changeset
3283