Mercurial > hg > octave-thorsten
comparison liboctave/Array-util.cc @ 8333:9238637cb81c
style fixes
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 18 Nov 2008 11:14:31 -0500 |
parents | 7cbe01c21986 |
children | 095ae5e0a831 |
comparison
equal
deleted
inserted
replaced
8332:34fde4755a0f | 8333:9238637cb81c |
---|---|
27 #include "Array-util.h" | 27 #include "Array-util.h" |
28 #include "dim-vector.h" | 28 #include "dim-vector.h" |
29 #include "lo-error.h" | 29 #include "lo-error.h" |
30 | 30 |
31 bool | 31 bool |
32 index_in_bounds (const Array<octave_idx_type>& ra_idx, const dim_vector& dimensions) | 32 index_in_bounds (const Array<octave_idx_type>& ra_idx, |
33 const dim_vector& dimensions) | |
33 { | 34 { |
34 bool retval = true; | 35 bool retval = true; |
35 | 36 |
36 int n = ra_idx.length (); | 37 int n = ra_idx.length (); |
37 | 38 |
337 | 338 |
338 return retval; | 339 return retval; |
339 } | 340 } |
340 | 341 |
341 Array<octave_idx_type> | 342 Array<octave_idx_type> |
342 get_elt_idx (const Array<idx_vector>& ra_idx, const Array<octave_idx_type>& result_idx) | 343 get_elt_idx (const Array<idx_vector>& ra_idx, |
344 const Array<octave_idx_type>& result_idx) | |
343 { | 345 { |
344 octave_idx_type n = ra_idx.length (); | 346 octave_idx_type n = ra_idx.length (); |
345 | 347 |
346 Array<octave_idx_type> retval (n); | 348 Array<octave_idx_type> retval (n); |
347 | 349 |
373 | 375 |
374 #if 0 | 376 #if 0 |
375 octave_idx_type var = 1; | 377 octave_idx_type var = 1; |
376 for (int i = 0; i < n_dims; i++) | 378 for (int i = 0; i < n_dims; i++) |
377 { | 379 { |
378 std::cout << "idx: " << idx << ", var: " << var << ", dims(" << i << "): " << dims(i) <<"\n"; | 380 std::cout << "idx: " << idx << ", var: " << var |
381 << ", dims(" << i << "): " << dims(i) <<"\n"; | |
379 retval(i) = ((int)floor(((idx) / (double)var))) % dims(i); | 382 retval(i) = ((int)floor(((idx) / (double)var))) % dims(i); |
380 idx -= var * retval(i); | 383 idx -= var * retval(i); |
381 var = dims(i); | 384 var = dims(i); |
382 } | 385 } |
383 #endif | 386 #endif |
395 // Mark scalars and colons, count non-scalar indices. | 398 // Mark scalars and colons, count non-scalar indices. |
396 int nonsc = 0; | 399 int nonsc = 0; |
397 bool all_colons = true; | 400 bool all_colons = true; |
398 for (int i = 0; i < ial; i++) | 401 for (int i = 0; i < ial; i++) |
399 { | 402 { |
400 // FIXME: should we check for length() instead? | 403 // FIXME -- should we check for length() instead? |
401 scalar[i] = ia(i).is_scalar (); | 404 scalar[i] = ia(i).is_scalar (); |
402 colon[i] = ia(i).is_colon (); | 405 colon[i] = ia(i).is_colon (); |
403 if (! scalar[i]) nonsc++; | 406 if (! scalar[i]) nonsc++; |
404 if (! colon[i]) rdv(i) = ia(i).extent (0); | 407 if (! colon[i]) rdv(i) = ia(i).extent (0); |
405 all_colons = all_colons && colon[i]; | 408 all_colons = all_colons && colon[i]; |
406 } | 409 } |
407 | 410 |
408 bool match = false; | 411 bool match = false; |
409 // If the number of nonscalar indices matches the dimensionality of RHS, | 412 // If the number of nonscalar indices matches the dimensionality of |
410 // we try an exact match, inquiring even singleton dimensions. | 413 // RHS, we try an exact match, inquiring even singleton dimensions. |
411 if (all_colons) | 414 if (all_colons) |
412 { | 415 { |
413 rdv = rhdv; | 416 rdv = rhdv; |
414 rdv.resize(ial, 1); | 417 rdv.resize(ial, 1); |
415 } | 418 } |