Mercurial > hg > octave-lyh
comparison libinterp/octave-value/ov-null-mat.cc @ 15195:2fc554ffbc28
split libinterp from src
* libinterp: New directory. Move all files from src directory here
except Makefile.am, main.cc, main-cli.cc, mkoctfile.in.cc,
mkoctfilr.in.sh, octave-config.in.cc, octave-config.in.sh.
* libinterp/Makefile.am: New file, extracted from src/Makefile.am.
* src/Makefile.am: Delete everything except targets and definitions
needed to build and link main and utility programs.
* Makefile.am (SUBDIRS): Include libinterp in the list.
* autogen.sh: Run config-module.sh in libinterp/dldfcn directory, not
src/dldfcn directory.
* configure.ac (AC_CONFIG_SRCDIR): Use libinterp/octave.cc, not
src/octave.cc.
(DL_LDFLAGS, LIBOCTINTERP): Use libinterp, not src.
(AC_CONFIG_FILES): Include libinterp/Makefile in the list.
* find-docstring-files.sh: Look in libinterp, not src.
* gui/src/Makefile.am (liboctgui_la_CPPFLAGS): Find header files in
libinterp, not src.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 18 Aug 2012 16:23:39 -0400 |
parents | src/octave-value/ov-null-mat.cc@46b19589b593 |
children |
comparison
equal
deleted
inserted
replaced
15194:0f0b795044c3 | 15195:2fc554ffbc28 |
---|---|
1 /* | |
2 | |
3 Copyright (C) 2008-2012 Jaroslav Hajek | |
4 | |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
9 Free Software Foundation; either version 3 of the License, or (at your | |
10 option) any later version. | |
11 | |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with Octave; see the file COPYING. If not, see | |
19 <http://www.gnu.org/licenses/>. | |
20 | |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include <config.h> | |
25 #endif | |
26 | |
27 #include "ov-null-mat.h" | |
28 #include "ops.h" | |
29 #include "defun.h" | |
30 | |
31 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_null_matrix, "null_matrix", "double"); | |
32 | |
33 const octave_value octave_null_matrix::instance (new octave_null_matrix ()); | |
34 | |
35 static octave_base_value * | |
36 default_null_matrix_numeric_conversion_function (const octave_base_value& a) | |
37 { | |
38 // The cast is not necessary? | |
39 // CAST_CONV_ARG (const octave_null_matrix&); | |
40 | |
41 return a.empty_clone (); | |
42 } | |
43 | |
44 octave_base_value::type_conv_info | |
45 octave_null_matrix::numeric_conversion_function (void) const | |
46 { | |
47 return octave_base_value::type_conv_info (default_null_matrix_numeric_conversion_function, | |
48 octave_matrix::static_type_id ()); | |
49 } | |
50 | |
51 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_null_str, "null_string", "char"); | |
52 | |
53 const octave_value octave_null_str::instance (new octave_null_str ()); | |
54 | |
55 static octave_base_value * | |
56 default_null_str_numeric_conversion_function (const octave_base_value& a) | |
57 { | |
58 // The cast is not necessary? | |
59 // CAST_CONV_ARG (const octave_null_str&); | |
60 | |
61 return a.empty_clone (); | |
62 } | |
63 | |
64 octave_base_value::type_conv_info | |
65 octave_null_str::numeric_conversion_function (void) const | |
66 { | |
67 return octave_base_value::type_conv_info (default_null_str_numeric_conversion_function, | |
68 octave_char_matrix_str::static_type_id ()); | |
69 } | |
70 | |
71 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_null_sq_str, "null_sq_string", "char"); | |
72 | |
73 const octave_value octave_null_sq_str::instance (new octave_null_sq_str ()); | |
74 | |
75 static octave_base_value * | |
76 default_null_sq_str_numeric_conversion_function (const octave_base_value& a) | |
77 { | |
78 // The cast is not necessary? | |
79 // CAST_CONV_ARG (const octave_null_sq_str&); | |
80 | |
81 return a.empty_clone (); | |
82 } | |
83 | |
84 octave_base_value::type_conv_info | |
85 octave_null_sq_str::numeric_conversion_function (void) const | |
86 { | |
87 return octave_base_value::type_conv_info (default_null_sq_str_numeric_conversion_function, | |
88 octave_char_matrix_sq_str::static_type_id ()); | |
89 } | |
90 | |
91 DEFUN (isnull, args, , | |
92 "-*- texinfo -*-\n\ | |
93 @deftypefn {Built-in Function} {} isnull (@var{x})\n\ | |
94 Return true if @var{x} is a special null matrix, string, or single quoted\n\ | |
95 string. Indexed assignment with such a value on the right-hand side should\n\ | |
96 delete array elements. This function should be used when overloading\n\ | |
97 indexed assignment for user-defined classes instead of @code{isempty}, to\n\ | |
98 distinguish the cases:\n\ | |
99 \n\ | |
100 @table @asis\n\ | |
101 @item @code{A(I) = []}\n\ | |
102 This should delete elements if @code{I} is nonempty.\n\ | |
103 \n\ | |
104 @item @code{X = []; A(I) = X}\n\ | |
105 This should give an error if @code{I} is nonempty.\n\ | |
106 @end table\n\ | |
107 @seealso{isempty, isindex}\n\ | |
108 @end deftypefn") | |
109 { | |
110 octave_value retval; | |
111 | |
112 int nargin = args.length (); | |
113 | |
114 if (nargin == 1 && args(0).is_defined ()) | |
115 retval = args(0).is_null_value (); | |
116 else | |
117 print_usage (); | |
118 | |
119 return retval; | |
120 } | |
121 | |
122 /* | |
123 %!assert (isnull ([]), true) | |
124 %!assert (isnull ([1]), false) | |
125 %!assert (isnull (zeros (0,3)), false) | |
126 %!assert (isnull (""), true) | |
127 %!assert (isnull ("A"), false) | |
128 %!assert (isnull (''), true) | |
129 %!assert (isnull ('A'), false) | |
130 %!test | |
131 %! x = []; | |
132 %! assert (isnull (x), false); | |
133 */ |