Mercurial > hg > octave-lyh
comparison src/ov-struct.cc @ 8679:280fae940bb0
optimize scalar indexing
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 05 Feb 2009 13:58:11 +0100 |
parents | 35656d6ad061 |
children | 5a956c026b6c |
comparison
equal
deleted
inserted
replaced
8678:e2b4c19c455c | 8679:280fae940bb0 |
---|---|
534 } | 534 } |
535 | 535 |
536 octave_value | 536 octave_value |
537 octave_struct::do_index_op (const octave_value_list& idx, bool resize_ok) | 537 octave_struct::do_index_op (const octave_value_list& idx, bool resize_ok) |
538 { | 538 { |
539 octave_value retval; | 539 // Octave_map handles indexing itself. |
540 | 540 return map.index (idx, resize_ok); |
541 octave_idx_type n_idx = idx.length (); | |
542 | |
543 int nd = map.ndims (); | |
544 | |
545 switch (n_idx) | |
546 { | |
547 case 0: | |
548 retval = map; | |
549 break; | |
550 | |
551 case 1: | |
552 { | |
553 idx_vector i = idx (0).index_vector (); | |
554 | |
555 if (! error_state) | |
556 retval = map.index (i, resize_ok, Cell::resize_fill_value ()); | |
557 } | |
558 break; | |
559 | |
560 default: | |
561 { | |
562 if (n_idx == 2 && nd == 2) | |
563 { | |
564 idx_vector i = idx (0).index_vector (); | |
565 | |
566 if (! error_state) | |
567 { | |
568 idx_vector j = idx (1).index_vector (); | |
569 | |
570 if (! error_state) | |
571 retval = map.index (i, j, resize_ok, | |
572 Cell::resize_fill_value ()); | |
573 } | |
574 } | |
575 else | |
576 { | |
577 Array<idx_vector> idx_vec (n_idx); | |
578 | |
579 for (octave_idx_type i = 0; i < n_idx; i++) | |
580 { | |
581 idx_vec(i) = idx(i).index_vector (); | |
582 | |
583 if (error_state) | |
584 break; | |
585 } | |
586 | |
587 if (! error_state) | |
588 retval = map.index (idx_vec, resize_ok, | |
589 Cell::resize_fill_value ()); | |
590 } | |
591 } | |
592 break; | |
593 } | |
594 | |
595 return retval; | |
596 } | 541 } |
597 | 542 |
598 size_t | 543 size_t |
599 octave_struct::byte_size (void) const | 544 octave_struct::byte_size (void) const |
600 { | 545 { |