comparison src/ov-cell.cc @ 8679:280fae940bb0

optimize scalar indexing
author Jaroslav Hajek <highegg@gmail.com>
date Thu, 05 Feb 2009 13:58:11 +0100
parents 1dce30ab0e72
children a669df7beb73
comparison
equal deleted inserted replaced
8678:e2b4c19c455c 8679:280fae940bb0
53 #include "ls-oct-ascii.h" 53 #include "ls-oct-ascii.h"
54 #include "ls-oct-binary.h" 54 #include "ls-oct-binary.h"
55 #include "ls-hdf5.h" 55 #include "ls-hdf5.h"
56 #include "ls-utils.h" 56 #include "ls-utils.h"
57 57
58 // Cell is able to handle octave_value indexing by itself, so just forward
59 // everything.
60
61 template <>
62 octave_value
63 octave_base_matrix<Cell>::do_index_op (const octave_value_list& idx,
64 bool resize_ok)
65 {
66 return matrix.index (idx, resize_ok);
67 }
68
69 template <>
70 void
71 octave_base_matrix<Cell>::assign (const octave_value_list& idx, const Cell& rhs)
72 {
73 matrix.assign (idx, rhs);
74 }
75
76 template <>
77 void
78 octave_base_matrix<Cell>::assign (const octave_value_list& idx, octave_value rhs)
79 {
80 // FIXME: Really?
81 if (rhs.is_cell ())
82 matrix.assign (idx, rhs.cell_value ());
83 else
84 matrix.assign (idx, Cell (rhs));
85 }
86
87 template <>
88 void
89 octave_base_matrix<Cell>::delete_elements (const octave_value_list& idx)
90 {
91 matrix.delete_elements (idx);
92 }
93
58 template class octave_base_matrix<Cell>; 94 template class octave_base_matrix<Cell>;
59 95
60 DEFINE_OCTAVE_ALLOCATOR (octave_cell); 96 DEFINE_OCTAVE_ALLOCATOR (octave_cell);
61 97
62 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_cell, "cell", "cell"); 98 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_cell, "cell", "cell");
336 panic_impossible (); 372 panic_impossible ();
337 } 373 }
338 } 374 }
339 375
340 return retval; 376 return retval;
341 }
342
343 void
344 octave_cell::assign (const octave_value_list& idx, const octave_value& rhs)
345 {
346 if (rhs.is_cell ())
347 octave_base_matrix<Cell>::assign (idx, rhs.cell_value ());
348 else
349 octave_base_matrix<Cell>::assign (idx, Cell (rhs));
350 } 377 }
351 378
352 size_t 379 size_t
353 octave_cell::byte_size (void) const 380 octave_cell::byte_size (void) const
354 { 381 {