GNU Octave 11.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
find.cc
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1996-2026 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26#if defined (HAVE_CONFIG_H)
27# include "config.h"
28#endif
29
30#include "quit.h"
31
32#include "defun.h"
33#include "error.h"
34#include "errwarn.h"
35#include "ovl.h"
36
38
39// Find at most N_TO_FIND nonzero elements in NDA. Search forward if
40// DIRECTION is 1, backward if it is -1. NARGOUT is the number of
41// output arguments. If N_TO_FIND is -1, find all nonzero elements.
42
43template <typename T>
45find_nonzero_elem_idx (const Array<T>& nda, int nargout,
46 octave_idx_type n_to_find, int direction)
47{
48 octave_value_list retval ((nargout == 0 ? 1 : nargout), Matrix ());
49
51 if (n_to_find >= 0)
52 idx = nda.find (n_to_find, direction == -1);
53 else
54 idx = nda.find ();
55
56 // The maximum element is always at the end.
57 octave_idx_type iext = (idx.isempty () ? 0
58 : idx.xelem (idx.numel () - 1) + 1);
59
60 switch (nargout)
61 {
62 default:
63 case 3:
64 retval(2) = Array<T> (nda.index (idx_vector (idx)));
65 OCTAVE_FALLTHROUGH;
66
67 case 2:
68 {
69 Array<octave_idx_type> jdx (idx.dims ());
70 octave_idx_type n = idx.numel ();
71 octave_idx_type nr = nda.rows ();
72 for (octave_idx_type i = 0; i < n; i++)
73 {
74 jdx.xelem (i) = idx.xelem (i) / nr;
75 idx.xelem (i) %= nr;
76 }
77 iext = -1;
78 retval(1) = idx_vector (jdx, -1);
79 }
80 OCTAVE_FALLTHROUGH;
81
82 case 1:
83 case 0:
84 retval(0) = idx_vector (idx, iext);
85 break;
86 }
87
88 return retval;
89}
90
91template <typename T>
93find_nonzero_elem_idx (const DiagArray2<T>& v, int nargout,
94 octave_idx_type n_to_find, int direction)
95{
96 octave_value_list retval ((nargout == 0 ? 1 : nargout), Matrix ());
97
98 // get array with relevant elements (i.e., the matrix diagonal)
99 Array<T> nda = v.extract_diag ();
100
102 if (n_to_find >= 0)
103 idx = nda.find (n_to_find, direction == -1);
104 else
105 idx = nda.find ();
106
107 // The maximum element is always at the end.
108 octave_idx_type iext = idx.isempty () ? 0 : idx.xelem (idx.numel () - 1) + 1;
109 switch (nargout)
110 {
111 default:
112 case 3:
113 retval(2) = Array<T> (nda.index (idx_vector (idx)));
114 OCTAVE_FALLTHROUGH;
115
116 case 2:
117 {
118 Array<octave_idx_type> jdx (idx.dims ());
119 octave_idx_type n = idx.numel ();
120 for (octave_idx_type i = 0; i < n; i++)
121 jdx.xelem(i) = idx.xelem(i);
122 iext = -1;
123 retval(1) = idx_vector (jdx, iext);
124 retval(0) = idx_vector (idx, iext);
125 break;
126 }
127
128 case 1:
129 case 0:
130 {
131 octave_idx_type n = idx.numel ();
132 octave_idx_type nr = v.rows ();
133 for (octave_idx_type i = 0; i < n; i++)
134 idx.xelem(i) = idx.xelem(i) * (nr + 1);
135 retval(0) = idx_vector (idx, iext);
136 break;
137 }
138 }
139
140 return retval;
141}
142
143template <typename T>
145find_nonzero_elem_idx (const Sparse<T>& v, int nargout,
146 octave_idx_type n_to_find, int direction)
147{
148 nargout = std::min (nargout, 5);
149 octave_value_list retval ((nargout == 0 ? 1 : nargout), Matrix ());
150
151 octave_idx_type nr = v.rows ();
152 octave_idx_type nc = v.cols ();
153 octave_idx_type nz = v.nnz ();
154
155 // Search in the default range.
156 octave_idx_type start_nc = -1;
157 octave_idx_type end_nc = -1;
158 octave_idx_type count;
159
160 // Search for the range to search
161 if (n_to_find < 0)
162 {
163 start_nc = 0;
164 end_nc = nc;
165 n_to_find = nz;
166 }
167 else if (direction > 0)
168 {
169 for (octave_idx_type j = 0; j < nc; j++)
170 {
171 octave_quit ();
172
173 if (v.cidx (j) == 0 && v.cidx (j+1) != 0)
174 start_nc = j;
175 if (v.cidx (j+1) >= n_to_find)
176 {
177 end_nc = j + 1;
178 break;
179 }
180 }
181 }
182 else
183 {
184 for (octave_idx_type j = nc; j > 0; j--)
185 {
186 octave_quit ();
187
188 if (v.cidx (j) == nz && v.cidx (j-1) != nz)
189 end_nc = j;
190 if (nz - v.cidx (j-1) >= n_to_find)
191 {
192 start_nc = j - 1;
193 break;
194 }
195 }
196 }
197
198 count = (n_to_find > v.cidx (end_nc) - v.cidx (start_nc) ?
199 v.cidx (end_nc) - v.cidx (start_nc) : n_to_find);
200
201 octave_idx_type result_nr;
202 octave_idx_type result_nc;
203
204 // Default case is to return a column vector, however, if the original
205 // argument was a row vector, then force return of a row vector.
206 if (nr == 1)
207 {
208 result_nr = 1;
209 result_nc = count;
210 }
211 else
212 {
213 result_nr = count;
214 result_nc = 1;
215 }
216
217 Matrix idx (result_nr, result_nc);
218
219 Matrix i_idx (result_nr, result_nc);
220 Matrix j_idx (result_nr, result_nc);
221
222 Array<T> val (dim_vector (result_nr, result_nc));
223
224 if (count > 0)
225 {
226 // Search for elements to return. Only search the region where there
227 // are elements to be found using the count that we want to find.
228 for (octave_idx_type j = start_nc, cx = 0; j < end_nc; j++)
229 for (octave_idx_type i = v.cidx (j); i < v.cidx (j+1); i++)
230 {
231 octave_quit ();
232
233 if (direction < 0 && i < nz - count)
234 continue;
235 i_idx(cx) = static_cast<double> (v.ridx (i) + 1);
236 j_idx(cx) = static_cast<double> (j + 1);
237 idx(cx) = j * nr + v.ridx (i) + 1;
238 val(cx) = v.data(i);
239 cx++;
240 if (cx == count)
241 break;
242 }
243 }
244 else
245 {
246 // No items found. Fixup return dimensions for Matlab compatibility.
247 // The behavior to match is documented in Array.cc (Array<T>::find).
248 if ((nr == 0 && nc == 0) || (nr == 1 && nc == 1))
249 {
250 idx.resize (0, 0);
251
252 i_idx.resize (0, 0);
253 j_idx.resize (0, 0);
254
255 val.resize (dim_vector (0, 0));
256 }
257 }
258
259 switch (nargout)
260 {
261 case 0:
262 case 1:
263 retval(0) = idx;
264 break;
265
266 case 5:
267 retval(4) = nc;
268 OCTAVE_FALLTHROUGH;
269
270 case 4:
271 retval(3) = nr;
272 OCTAVE_FALLTHROUGH;
273
274 case 3:
275 retval(2) = val;
276 OCTAVE_FALLTHROUGH;
277
278 case 2:
279 retval(1) = j_idx;
280 retval(0) = i_idx;
281 }
282
283 return retval;
284}
285
287find_nonzero_elem_idx (const PermMatrix& v, int nargout,
288 octave_idx_type n_to_find, int direction)
289{
290 // There are far fewer special cases to handle for a PermMatrix.
291 nargout = std::min (nargout, 5);
292 octave_value_list retval ((nargout == 0 ? 1 : nargout), Matrix ());
293
294 octave_idx_type nr = v.rows ();
295 octave_idx_type nc = v.cols ();
296 octave_idx_type start_nc, count;
297
298 // Determine the range to search.
299 if (n_to_find < 0 || n_to_find >= nc)
300 {
301 start_nc = 0;
302 count = nc;
303 }
304 else if (direction > 0)
305 {
306 start_nc = 0;
307 count = n_to_find;
308 }
309 else
310 {
311 start_nc = nc - n_to_find;
312 count = n_to_find;
313 }
314
315 Matrix idx (count, 1);
316 Matrix i_idx (count, 1);
317 Matrix j_idx (count, 1);
318 // Every value is 1.
319 Array<double> val (dim_vector (count, 1), 1.0);
320
321 if (count > 0)
322 {
323 const Array<octave_idx_type>& p = v.col_perm_vec ();
324 for (octave_idx_type k = 0; k < count; k++)
325 {
326 octave_quit ();
327
328 const octave_idx_type j = start_nc + k;
329 const octave_idx_type i = p(j);
330 i_idx(k) = static_cast<double> (1+i);
331 j_idx(k) = static_cast<double> (1+j);
332 idx(k) = j * nc + i + 1;
333 }
334 }
335 else
336 {
337 // FIXME: Is this case even possible? A scalar permutation matrix seems
338 // to devolve to a scalar full matrix, at least from the Octave command
339 // line. Perhaps this function could be called internally from C++ with
340 // such a matrix.
341 // No items found. Fixup return dimensions for Matlab compatibility.
342 // The behavior to match is documented in Array.cc (Array<T>::find).
343 if ((nr == 0 && nc == 0) || (nr == 1 && nc == 1))
344 {
345 idx.resize (0, 0);
346
347 i_idx.resize (0, 0);
348 j_idx.resize (0, 0);
349
350 val.resize (dim_vector (0, 0));
351 }
352 }
353
354 switch (nargout)
355 {
356 case 0:
357 case 1:
358 retval(0) = idx;
359 break;
360
361 case 5:
362 retval(4) = nc;
363 OCTAVE_FALLTHROUGH;
364
365 case 4:
366 retval(3) = nc;
367 OCTAVE_FALLTHROUGH;
368
369 case 3:
370 retval(2) = val;
371 OCTAVE_FALLTHROUGH;
372
373 case 2:
374 retval(1) = j_idx;
375 retval(0) = i_idx;
376 }
377
378 return retval;
379}
380
381DEFUN (find, args, nargout,
382 doc: /* -*- texinfo -*-
383@deftypefn {} {@var{idx} =} find (@var{x})
384@deftypefnx {} {@var{idx} =} find (@var{x}, @var{n})
385@deftypefnx {} {@var{idx} =} find (@var{x}, @var{n}, @var{direction})
386@deftypefnx {} {[i, j] =} find (@dots{})
387@deftypefnx {} {[i, j, v] =} find (@dots{})
388Return a vector of indices of nonzero elements of a matrix, as a row if
389@var{x} is a row vector or as a column otherwise.
390
391To obtain a single index for each matrix element, Octave pretends that the
392columns of a matrix form one long vector (like Fortran arrays are stored).
393For example:
394
395@example
396@group
397find (eye (2))
398 @xresult{} [ 1; 4 ]
399@end group
400@end example
401
402If two inputs are given, @var{n} indicates the maximum number of elements to
403find from the beginning of the matrix or vector.
404
405If three inputs are given, @var{direction} should be one of
406@qcode{"first"} or @qcode{"last"}, requesting only the first or last
407@var{n} indices, respectively. However, the indices are always returned in
408ascending order.
409
410If two outputs are requested, @code{find} returns the row and column
411indices of nonzero elements of a matrix. For example:
412
413@example
414@group
415[i, j] = find (2 * eye (2))
416 @xresult{} i = [ 1; 2 ]
417 @xresult{} j = [ 1; 2 ]
418@end group
419@end example
420
421If three outputs are requested, @code{find} also returns a vector
422containing the nonzero values. For example:
423
424@example
425@group
426[i, j, v] = find (3 * eye (2))
427 @xresult{} i = [ 1; 2 ]
428 @xresult{} j = [ 1; 2 ]
429 @xresult{} v = [ 3; 3 ]
430@end group
431@end example
432
433If @var{x} is a multi-dimensional array of size m x n x p x @dots{}, @var{j}
434contains the column locations as if @var{x} was flattened into a
435two-dimensional matrix of size m x (n + p + @dots{}).
436
437Note that this function is particularly useful for sparse matrices, as
438it extracts the nonzero elements as vectors, which can then be used to
439create the original matrix. For example:
440
441@example
442@group
443sz = size (a);
444[i, j, v] = find (a);
445b = sparse (i, j, v, sz(1), sz(2));
446@end group
447@end example
448@seealso{nonzeros}
449@end deftypefn */)
450{
451 int nargin = args.length ();
452
453 if (nargin < 1 || nargin > 3)
454 print_usage ();
455
456 // Setup the default options.
457 octave_idx_type n_to_find = -1;
458 if (nargin > 1)
459 {
460 double val = args(1).xscalar_value ("find: N must be an integer");
461
462 if (val < 0 || (! math::isinf (val)
463 && val != math::fix (val)))
464 error ("find: N must be a non-negative integer");
465 else if (! math::isinf (val))
466 n_to_find = val;
467 }
468
469 // Direction to do the searching (1 == forward, -1 == reverse).
470 int direction = 1;
471 if (nargin > 2)
472 {
473 std::string s_arg = args(2).string_value ();
474
475 if (s_arg == "first")
476 direction = 1;
477 else if (s_arg == "last")
478 direction = -1;
479 else
480 error (R"(find: DIRECTION must be "first" or "last")");
481 }
482
483 octave_value_list retval;
484
485 octave_value arg = args(0);
486
487 if (arg.islogical ())
488 {
489 if (arg.issparse ())
490 {
492
493 retval = find_nonzero_elem_idx (v, nargout, n_to_find, direction);
494 }
495 else if (nargout <= 1 && n_to_find == -1 && direction == 1)
496 {
497 // This case is equivalent to extracting indices from a logical
498 // matrix. Try to reuse the possibly cached index vector.
499
500 // No need to catch index_exception, since arg is bool.
501 // Out-of-range errors have already set pos, and will be
502 // caught later.
503
504 octave_value result = arg.index_vector ().unmask ();
505
506 const dim_vector& dv = result.dims ();
507
508 retval(0) = (dv.all_zero () || dv.isvector ()
509 ? result : result.reshape (dv.as_column ()));
510 }
511 else
512 {
513 boolNDArray v = arg.bool_array_value ();
514
515 retval = find_nonzero_elem_idx (v, nargout, n_to_find, direction);
516 }
517 }
518 else if (arg.isinteger ())
519 {
520#define DO_INT_BRANCH(INTT) \
521 else if (arg.is_ ## INTT ## _type ()) \
522 { \
523 INTT ## NDArray v = arg.INTT ## _array_value (); \
524 \
525 retval = find_nonzero_elem_idx (v, nargout, n_to_find, direction); \
526 }
527
528 if (false)
529 ;
530 DO_INT_BRANCH (int8)
531 DO_INT_BRANCH (int16)
532 DO_INT_BRANCH (int32)
533 DO_INT_BRANCH (int64)
534 DO_INT_BRANCH (uint8)
535 DO_INT_BRANCH (uint16)
536 DO_INT_BRANCH (uint32)
537 DO_INT_BRANCH (uint64)
538 else
539 error ("find: unexpected integer type - please report this bug");
540 }
541 else if (arg.issparse ())
542 {
543 if (arg.isreal ())
544 {
546
547 retval = find_nonzero_elem_idx (v, nargout, n_to_find, direction);
548 }
549 else if (arg.iscomplex ())
550 {
552
553 retval = find_nonzero_elem_idx (v, nargout, n_to_find, direction);
554 }
555 else
556 err_wrong_type_arg ("find", arg);
557 }
558 else if (arg.is_perm_matrix ())
559 {
560 PermMatrix P = arg.perm_matrix_value ();
561
562 retval = find_nonzero_elem_idx (P, nargout, n_to_find, direction);
563 }
564 else if (arg.is_diag_matrix ())
565 {
566 // diagonal logical matrices are handled above
567 if (arg.is_single_type ())
568 {
569 if (arg.isreal ())
570 {
572
573 retval = find_nonzero_elem_idx (D, nargout, n_to_find, direction);
574 }
575 else if (arg.iscomplex ())
576 {
578
579 retval = find_nonzero_elem_idx (D, nargout, n_to_find, direction);
580 }
581 }
582 else if (arg.isreal ())
583 {
584 DiagMatrix D = arg.diag_matrix_value ();
585
586 retval = find_nonzero_elem_idx (D, nargout, n_to_find, direction);
587 }
588 else if (arg.iscomplex ())
589 {
591
592 retval = find_nonzero_elem_idx (D, nargout, n_to_find, direction);
593 }
594 }
595 else if (arg.is_string ())
596 {
597 charNDArray chnda = arg.char_array_value ();
598
599 retval = find_nonzero_elem_idx (chnda, nargout, n_to_find, direction);
600 }
601 else if (arg.is_single_type ())
602 {
603 if (arg.isreal ())
604 {
605 FloatNDArray nda = arg.float_array_value ();
606
607 retval = find_nonzero_elem_idx (nda, nargout, n_to_find, direction);
608 }
609 else if (arg.iscomplex ())
610 {
612
613 retval = find_nonzero_elem_idx (cnda, nargout, n_to_find, direction);
614 }
615 }
616 else if (arg.isreal ())
617 {
618 NDArray nda = arg.array_value ();
619
620 retval = find_nonzero_elem_idx (nda, nargout, n_to_find, direction);
621 }
622 else if (arg.iscomplex ())
623 {
625
626 retval = find_nonzero_elem_idx (cnda, nargout, n_to_find, direction);
627 }
628 else
629 err_wrong_type_arg ("find", arg);
630
631 return retval;
632}
633
634/*
635%!assert (find (char ([0, 97])), 2)
636%!assert (find ([1, 0, 1, 0, 1]), [1, 3, 5])
637%!assert (find ([1; 0; 3; 0; 1]), [1; 3; 5])
638%!assert (find ([0, 0, 2; 0, 3, 0; -1, 0, 0]), [3; 5; 7])
639%!assert (find (diag ([5, 0, 4, 0, 2])), [1; 13; 25])
640%!assert (find (diag ([5, 0, 4, 0, 2], 7, 6)), [1; 17; 33])
641
642%!assert <*53603> (find (ones (1,1,2) > 0), [1;2])
643%!assert <*53603> (find (ones (1,1,1,3) > 0), [1;2;3])
644
645%!test
646%! [i, j, v] = find ([0, 0, 2; 0, 3, 0; -1, 0, 0]);
647%!
648%! assert (i, [3; 2; 1]);
649%! assert (j, [1; 2; 3]);
650%! assert (v, [-1; 3; 2]);
651
652%!assert (find (single ([1, 0, 1, 0, 1])), [1, 3, 5])
653%!assert (find (single ([1; 0; 3; 0; 1])), [1; 3; 5])
654%!assert (find (single ([0, 0, 2; 0, 3, 0; -1, 0, 0])), [3; 5; 7])
655
656%!test
657%! [i, j, v] = find (single ([0, 0, 2; 0, 3, 0; -1, 0, 0]));
658%!
659%! assert (i, [3; 2; 1]);
660%! assert (j, [1; 2; 3]);
661%! assert (v, single ([-1; 3; 2]));
662
663%!test
664%! pcol = [5 1 4 3 2];
665%! P = eye (5) (:, pcol);
666%! [i, j, v] = find (P);
667%! [ifull, jfull, vfull] = find (full (P));
668%! assert (i, ifull);
669%! assert (j, jfull);
670%! assert (all (v == 1));
671
672%!test
673%! prow = [5 1 4 3 2];
674%! P = eye (5) (prow, :);
675%! [i, j, v] = find (P);
676%! [ifull, jfull, vfull] = find (full (P));
677%! assert (i, ifull);
678%! assert (j, jfull);
679%! assert (all (v == 1));
680
681%!test
682%! D = diag ([5, 0, 4, 0, 2]);
683%! [i, j] = find (D);
684%! [ifull, jfull] = find (full (D));
685%! assert (i, ifull);
686%! assert (j, jfull);
687
688%!test
689%! D = diag ([5, 0, 4, 0, 2], 6, 5);
690%! [i, j, v] = find (D);
691%! [ifull, jfull, vfull] = find (full (D));
692%! assert (i, ifull);
693%! assert (j, jfull);
694%! assert (v, vfull);
695
696%!test <*61986>
697%! P = cat (3, eye(3), eye(3));
698%! loc = find (P);
699%! [i, j, v] = find(P);
700%! assert (loc, [1, 5, 9, 10, 14, 18]');
701%! assert (i, [1, 2, 3, 1, 2, 3]');
702%! assert (j, [1, 2, 3, 4, 5, 6]');
703%! assert (v, [1, 1, 1, 1, 1, 1]');
704
705%!assert <*53655> (find (false), zeros (0, 0))
706%!assert <*53655> (find ([false, false]), zeros (1, 0))
707%!assert <*53655> (find ([false; false]), zeros (0, 1))
708%!assert <*53655> (find ([false, false; false, false]), zeros (0, 1))
709
710%!assert (find ([2 0 1 0 5 0], 1), 1)
711%!assert (find ([2 0 1 0 5 0], 2, "last"), [3, 5])
712
713%!assert (find ([2 0 1 0 5 0], Inf), [1, 3, 5])
714%!assert (find ([2 0 1 0 5 0], Inf, "last"), [1, 3, 5])
715
716%!error find ()
717*/
718
719OCTAVE_END_NAMESPACE(octave)
N Dimensional Array with copy-on-write semantics.
Definition Array-base.h:130
const dim_vector & dims() const
Return a const-reference so that dims ()(i) works efficiently.
Definition Array-base.h:529
T & xelem(octave_idx_type n)
Size of the specified dimension.
Definition Array-base.h:547
Array< T, Alloc > index(const octave::idx_vector &i) const
Indexing without resizing.
octave_idx_type rows() const
Definition Array-base.h:485
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
Array< octave_idx_type > find(octave_idx_type n=-1, bool backward=false) const
Find indices of (at most n) nonzero elements.
bool isempty() const
Size of the specified dimension.
Definition Array-base.h:674
octave_idx_type numel() const
Number of elements in the array.
Definition Array-base.h:440
Array< T > extract_diag(octave_idx_type k=0) const
Definition DiagArray2.cc:48
octave_idx_type rows() const
Definition DiagArray2.h:86
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
Definition dMatrix.h:156
octave_idx_type rows() const
Definition PermMatrix.h:62
octave_idx_type cols() const
Definition PermMatrix.h:63
const Array< octave_idx_type > & col_perm_vec() const
Definition PermMatrix.h:83
octave_idx_type cols() const
Definition Sparse.h:351
octave_idx_type * cidx()
Definition Sparse.h:595
T * data()
Definition Sparse.h:573
octave_idx_type * ridx()
Definition Sparse.h:582
octave_idx_type nnz() const
Actual number of nonzero terms.
Definition Sparse.h:338
octave_idx_type rows() const
Definition Sparse.h:350
Vector representing the dimensions (size) of an Array.
Definition dim-vector.h:92
bool all_zero() const
Definition dim-vector.h:306
bool isvector() const
Definition dim-vector.h:432
dim_vector as_column() const
Definition dim-vector.h:416
octave_idx_type length() const
Definition ovl.h:111
bool is_diag_matrix() const
Definition ov.h:629
bool isinteger() const
Definition ov.h:728
boolNDArray bool_array_value(bool warn=false) const
Definition ov.h:898
SparseMatrix sparse_matrix_value(bool frc_str_conv=false) const
Definition ov.h:907
DiagMatrix diag_matrix_value(bool force=false) const
Definition ov.h:917
octave::idx_vector index_vector(bool require_integers=false) const
Definition ov.h:532
bool isreal() const
Definition ov.h:736
bool is_string() const
Definition ov.h:635
bool is_perm_matrix() const
Definition ov.h:632
ComplexNDArray complex_array_value(bool frc_str_conv=false) const
Definition ov.h:882
bool is_single_type() const
Definition ov.h:696
charNDArray char_array_value(bool frc_str_conv=false) const
Definition ov.h:904
bool issparse() const
Definition ov.h:751
octave_value reshape(const dim_vector &dv) const
Definition ov.h:569
ComplexDiagMatrix complex_diag_matrix_value(bool force=false) const
Definition ov.h:923
bool iscomplex() const
Definition ov.h:739
SparseBoolMatrix sparse_bool_matrix_value(bool warn=false) const
Definition ov.h:914
NDArray array_value(bool frc_str_conv=false) const
Definition ov.h:863
FloatComplexNDArray float_complex_array_value(bool frc_str_conv=false) const
Definition ov.h:886
FloatNDArray float_array_value(bool frc_str_conv=false) const
Definition ov.h:866
PermMatrix perm_matrix_value() const
Definition ov.h:930
SparseComplexMatrix sparse_complex_matrix_value(bool frc_str_conv=false) const
Definition ov.h:911
bool islogical() const
Definition ov.h:733
dim_vector dims() const
Definition ov.h:539
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void print_usage()
Definition defun-int.h:72
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
Definition defun.h:56
void error(const char *fmt,...)
Definition error.cc:1008
void err_wrong_type_arg(const char *name, const char *s)
Definition errwarn.cc:166
octave_value_list find_nonzero_elem_idx(const Array< T > &nda, int nargout, octave_idx_type n_to_find, int direction)
Definition find.cc:45
#define DO_INT_BRANCH(INTT)