comparison src/ov-base.cc @ 9329:67fc970dad7d

improve indexed assignment using indexed numel
author Jaroslav Hajek <highegg@gmail.com>
date Wed, 10 Jun 2009 11:31:58 +0200
parents c2248cc4821a
children e08d72bb988e
comparison
equal deleted inserted replaced
9328:0307f5e5568c 9329:67fc970dad7d
72 octave_value 72 octave_value
73 octave_base_value::full_value (void) const 73 octave_base_value::full_value (void) const
74 { 74 {
75 gripe_wrong_type_arg ("full: invalid operation for %s type", type_name ()); 75 gripe_wrong_type_arg ("full: invalid operation for %s type", type_name ());
76 return octave_value (); 76 return octave_value ();
77 }
78
79 Matrix
80 octave_base_value::size (void)
81 {
82 const dim_vector dv = dims ();
83 Matrix mdv (1, dv.length ());
84 for (octave_idx_type i = 0; i < dv.length (); i++)
85 mdv(i) = dv(i);
86 return mdv;
87 }
88
89 octave_idx_type
90 octave_base_value::numel (const octave_value_list& idx)
91 {
92 octave_idx_type retval;
93
94 octave_idx_type len = idx.length ();
95
96 if (len == 0)
97 retval = numel ();
98 else
99 {
100 const dim_vector dv = dims ().redim (len);
101 retval = 1;
102 for (octave_idx_type i = 0; i < len; i++)
103 {
104 if (idx(i).is_magic_colon ())
105 retval *= dv(i);
106 else
107 retval *= idx(i).numel ();
108 }
109 }
110
111 return retval;
77 } 112 }
78 113
79 octave_value 114 octave_value
80 octave_base_value::subsref (const std::string&, 115 octave_base_value::subsref (const std::string&,
81 const std::list<octave_value_list>&) 116 const std::list<octave_value_list>&)