GNU Octave  4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ov-null-mat.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2008-2015 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 
32  "double");
33 
35 
36 static octave_base_value *
38 {
39  // The cast is not necessary?
40  // CAST_CONV_ARG (const octave_null_matrix&);
41 
42  return a.empty_clone ();
43 }
44 
47 {
51 }
52 
54 
56 
57 static octave_base_value *
59 {
60  // The cast is not necessary?
61  // CAST_CONV_ARG (const octave_null_str&);
62 
63  return a.empty_clone ();
64 }
65 
68 {
72 }
73 
75  "char");
76 
78 
79 static octave_base_value *
81 {
82  // The cast is not necessary?
83  // CAST_CONV_ARG (const octave_null_sq_str&);
84 
85  return a.empty_clone ();
86 }
87 
90 {
94 }
95 
96 DEFUN (isnull, args, ,
97  "-*- texinfo -*-\n\
98 @deftypefn {Built-in Function} {} isnull (@var{x})\n\
99 Return true if @var{x} is a special null matrix, string, or single quoted\n\
100 string.\n\
101 \n\
102 Indexed assignment with such a value on the right-hand side should delete\n\
103 array elements. This function should be used when overloading indexed\n\
104 assignment for user-defined classes instead of @code{isempty}, to\n\
105 distinguish the cases:\n\
106 \n\
107 @table @asis\n\
108 @item @code{A(I) = []}\n\
109 This should delete elements if @code{I} is nonempty.\n\
110 \n\
111 @item @code{X = []; A(I) = X}\n\
112 This should give an error if @code{I} is nonempty.\n\
113 @end table\n\
114 @seealso{isempty, isindex}\n\
115 @end deftypefn")
116 {
117  octave_value retval;
118 
119  int nargin = args.length ();
120 
121  if (nargin == 1 && args(0).is_defined ())
122  retval = args(0).is_null_value ();
123  else
124  print_usage ();
125 
126  return retval;
127 }
128 
129 /*
130 %!assert (isnull ([]), true)
131 %!assert (isnull ([1]), false)
132 %!assert (isnull (zeros (0,3)), false)
133 %!assert (isnull (""), true)
134 %!assert (isnull ("A"), false)
135 %!assert (isnull (''), true)
136 %!assert (isnull ('A'), false)
137 %!test
138 %! x = [];
139 %! assert (isnull (x), false);
140 */
static octave_base_value * default_null_sq_str_numeric_conversion_function(const octave_base_value &a)
Definition: ov-null-mat.cc:80
static const octave_value instance
Definition: ov-null-mat.h:68
OCTINTERP_API void print_usage(void)
Definition: defun.cc:51
#define DEFUN(name, args_name, nargout_name, doc)
Definition: defun.h:44
static int static_type_id(void)
Definition: ov-str-mat.h:173
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
Definition: ov-base.h:164
static octave_base_value * default_null_str_numeric_conversion_function(const octave_base_value &a)
Definition: ov-null-mat.cc:58
static const octave_value instance
Definition: ov-null-mat.h:90
type_conv_info numeric_conversion_function(void) const
Definition: ov-null-mat.cc:67
bool is_null_value(void) const
Definition: ov.h:592
static const octave_value instance
Definition: ov-null-mat.h:47
static int static_type_id(void)
Definition: ov-re-mat.h:235
virtual octave_base_value * empty_clone(void) const
Definition: ov-base.cc:121
octave_idx_type length(void) const
Definition: ov.cc:1525
type_conv_info numeric_conversion_function(void) const
Definition: ov-null-mat.cc:46
static int static_type_id(void)
Definition: ov-str-mat.h:256
type_conv_info numeric_conversion_function(void) const
Definition: ov-null-mat.cc:89
static octave_base_value * default_null_matrix_numeric_conversion_function(const octave_base_value &a)
Definition: ov-null-mat.cc:37