GNU Octave  4.2.1
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-2017 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 #if defined (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  // const octave_null_matrix& v = dynamic_cast<const octave_null_matrix&> (a);
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  // const octave_null_str& v = dynamic_cast<const octave_null_str&> (a);
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  // const octave_null_sq_str& v = dynamic_cast<const octave_null_sq_str&> (a);
84 
85  return a.empty_clone ();
86 }
87 
90 {
94 }
95 
96 DEFUN (isnull, args, ,
97  doc: /* -*- texinfo -*-
98 @deftypefn {} {} isnull (@var{x})
99 Return true if @var{x} is a special null matrix, string, or single quoted
100 string.
101 
102 Indexed assignment with such a value on the right-hand side should delete
103 array elements. This function should be used when overloading indexed
104 assignment for user-defined classes instead of @code{isempty}, to
105 distinguish the cases:
106 
107 @table @asis
108 @item @code{A(I) = []}
109 This should delete elements if @code{I} is nonempty.
110 
111 @item @code{X = []; A(I) = X}
112 This should give an error if @code{I} is nonempty.
113 @end table
114 @seealso{isempty, isindex}
115 @end deftypefn */)
116 {
117  if (args.length () != 1)
118  print_usage ();
119 
120  return ovl (args(0).is_null_value ());
121 }
122 
123 /*
124 %!assert (isnull ([]), true)
125 %!assert (isnull ([1]), false)
126 %!assert (isnull (zeros (0,3)), false)
127 %!assert (isnull (""), true)
128 %!assert (isnull ("A"), false)
129 %!assert (isnull (''), true)
130 %!assert (isnull ('A'), false)
131 %!test
132 %! x = [];
133 %! assert (isnull (x), false);
134 */
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:70
OCTAVE_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).is_integer_type())
OCTINTERP_API void print_usage(void)
Definition: defun.cc:52
#define DEFUN(name, args_name, nargout_name, doc)
Definition: defun.h:46
static int static_type_id(void)
Definition: ov-str-mat.h:176
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
Definition: ov-base.h:169
static octave_base_value * default_null_str_numeric_conversion_function(const octave_base_value &a)
Definition: ov-null-mat.cc:58
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
Definition: cellfun.cc:398
JNIEnv void * args
Definition: ov-java.cc:67
static const octave_value instance
Definition: ov-null-mat.h:91
type_conv_info numeric_conversion_function(void) const
Definition: ov-null-mat.cc:67
static const octave_value instance
Definition: ov-null-mat.h:49
static int static_type_id(void)
Definition: ov-re-mat.h:250
virtual octave_base_value * empty_clone(void) const
Definition: ov-base.cc:122
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:257
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