Mercurial > octave
comparison src/DLD-FUNCTIONS/find.cc @ 6005:b4351cfb5659
[project @ 2006-09-26 21:38:16 by jwe]
author | jwe |
---|---|
date | Tue, 26 Sep 2006 21:38:16 +0000 |
parents | c5d0490aad55 |
children | 31bf61b463ce |
comparison
equal
deleted
inserted
replaced
6004:01556febbaaf | 6005:b4351cfb5659 |
---|---|
116 octave_idx_type j = 0; | 116 octave_idx_type j = 0; |
117 | 117 |
118 // Search for elements to return. Only search the region where | 118 // Search for elements to return. Only search the region where |
119 // there are elements to be found using the count that we want | 119 // there are elements to be found using the count that we want |
120 // to find. | 120 // to find. |
121 | |
122 // For compatibility, all N-d arrays are handled as if they are | |
123 // 2-d, with the number of columns equal to "prod (dims (2:end))". | |
124 | |
121 for (k = start_el; k < end_el; k++) | 125 for (k = start_el; k < end_el; k++) |
122 { | 126 { |
123 OCTAVE_QUIT; | 127 OCTAVE_QUIT; |
124 | 128 |
125 if (nda(k) != 0.0) | 129 if (nda(k) != 0.0) |
126 { | 130 { |
127 idx(count) = k + 1; | 131 idx(count) = k + 1; |
128 | 132 |
129 i_idx(count) = i + 1; | 133 octave_idx_type xr = k % nr; |
130 j_idx(count) = j + 1; | 134 i_idx(count) = xr + 1; |
135 j_idx(count) = (k - xr) / nr + 1; | |
131 | 136 |
132 val(count) = nda(k); | 137 val(count) = nda(k); |
133 | 138 |
134 count++; | 139 count++; |
135 } | 140 } |
136 | 141 |
137 i++; | 142 i++; |
138 | |
139 if (i == nr) | |
140 { | |
141 i = 0; | |
142 | |
143 j++; | |
144 } | |
145 } | 143 } |
146 } | 144 } |
147 else if (scalar_arg) | 145 else if (scalar_arg) |
148 { | 146 { |
149 idx.resize (0, 0); | 147 idx.resize (0, 0); |