comparison src/DLD-FUNCTIONS/find.cc @ 5275:23b37da9fd5b

[project @ 2005-04-08 16:07:35 by jwe]
author jwe
date Fri, 08 Apr 2005 16:07:37 +0000
parents 89cddd966068
children 4c8a2e4e0717
comparison
equal deleted inserted replaced
5274:eae7b40388e9 5275:23b37da9fd5b
37 octave_value_list 37 octave_value_list
38 find_nonzero_elem_idx (const T& nda, int nargout) 38 find_nonzero_elem_idx (const T& nda, int nargout)
39 { 39 {
40 octave_value_list retval (((nargout == 0) ? 1 : nargout), Matrix ()); 40 octave_value_list retval (((nargout == 0) ? 1 : nargout), Matrix ());
41 41
42 int count = 0; 42 octave_idx_type count = 0;
43 43
44 int nel = nda.nelem (); 44 octave_idx_type nel = nda.nelem ();
45 45
46 for (int i = 0; i < nel; i++) 46 for (octave_idx_type i = 0; i < nel; i++)
47 { 47 {
48 OCTAVE_QUIT; 48 OCTAVE_QUIT;
49 49
50 if (nda(i) != 0.0) 50 if (nda(i) != 0.0)
51 count++; 51 count++;
53 53
54 // If the original argument was a row vector, force a row vector of 54 // If the original argument was a row vector, force a row vector of
55 // the overall indices to be returned. But see below for scalar 55 // the overall indices to be returned. But see below for scalar
56 // case... 56 // case...
57 57
58 int result_nr = count; 58 octave_idx_type result_nr = count;
59 int result_nc = 1; 59 octave_idx_type result_nc = 1;
60 60
61 bool scalar_arg = false; 61 bool scalar_arg = false;
62 62
63 if (nda.ndims () == 2 && nda.rows () == 1) 63 if (nda.ndims () == 2 && nda.rows () == 1)
64 { 64 {
77 77
78 if (count > 0) 78 if (count > 0)
79 { 79 {
80 count = 0; 80 count = 0;
81 81
82 int nr = nda.rows (); 82 octave_idx_type nr = nda.rows ();
83 83
84 int i = 0; 84 octave_idx_type i = 0;
85 int j = 0; 85 octave_idx_type j = 0;
86 86
87 for (int k = 0; k < nel; k++) 87 for (octave_idx_type k = 0; k < nel; k++)
88 { 88 {
89 OCTAVE_QUIT; 89 OCTAVE_QUIT;
90 90
91 if (nda(k) != 0.0) 91 if (nda(k) != 0.0)
92 { 92 {