Mercurial > hg > octave-nkf
comparison src/ov.cc @ 11586:12df7854fa7c
strip trailing whitespace from source files
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 20 Jan 2011 17:24:59 -0500 |
parents | fd0a3ac60b0e |
children | d08901c05c1b |
comparison
equal
deleted
inserted
replaced
11585:1473d0cf86d2 | 11586:12df7854fa7c |
---|---|
1175 { | 1175 { |
1176 if (--rep->count == 0) | 1176 if (--rep->count == 0) |
1177 delete rep; | 1177 delete rep; |
1178 | 1178 |
1179 rep = tmp; | 1179 rep = tmp; |
1180 } | 1180 } |
1181 } | 1181 } |
1182 | 1182 |
1183 octave_value | 1183 octave_value |
1184 octave_value::single_subsref (const std::string& type, | 1184 octave_value::single_subsref (const std::string& type, |
1185 const octave_value_list& idx) | 1185 const octave_value_list& idx) |
1213 } | 1213 } |
1214 | 1214 |
1215 octave_value | 1215 octave_value |
1216 octave_value::next_subsref (const std::string& type, | 1216 octave_value::next_subsref (const std::string& type, |
1217 const std::list<octave_value_list>& idx, | 1217 const std::list<octave_value_list>& idx, |
1218 size_t skip) | 1218 size_t skip) |
1219 { | 1219 { |
1220 if (! error_state && idx.size () > skip) | 1220 if (! error_state && idx.size () > skip) |
1221 { | 1221 { |
1222 std::list<octave_value_list> new_idx (idx); | 1222 std::list<octave_value_list> new_idx (idx); |
1223 for (size_t i = 0; i < skip; i++) | 1223 for (size_t i = 0; i < skip; i++) |
1229 } | 1229 } |
1230 | 1230 |
1231 octave_value_list | 1231 octave_value_list |
1232 octave_value::next_subsref (int nargout, const std::string& type, | 1232 octave_value::next_subsref (int nargout, const std::string& type, |
1233 const std::list<octave_value_list>& idx, | 1233 const std::list<octave_value_list>& idx, |
1234 size_t skip) | 1234 size_t skip) |
1235 { | 1235 { |
1236 if (! error_state && idx.size () > skip) | 1236 if (! error_state && idx.size () > skip) |
1237 { | 1237 { |
1238 std::list<octave_value_list> new_idx (idx); | 1238 std::list<octave_value_list> new_idx (idx); |
1239 for (size_t i = 0; i < skip; i++) | 1239 for (size_t i = 0; i < skip; i++) |
1245 } | 1245 } |
1246 | 1246 |
1247 octave_value | 1247 octave_value |
1248 octave_value::next_subsref (bool auto_add, const std::string& type, | 1248 octave_value::next_subsref (bool auto_add, const std::string& type, |
1249 const std::list<octave_value_list>& idx, | 1249 const std::list<octave_value_list>& idx, |
1250 size_t skip) | 1250 size_t skip) |
1251 { | 1251 { |
1252 if (! error_state && idx.size () > skip) | 1252 if (! error_state && idx.size () > skip) |
1253 { | 1253 { |
1254 std::list<octave_value_list> new_idx (idx); | 1254 std::list<octave_value_list> new_idx (idx); |
1255 for (size_t i = 0; i < skip; i++) | 1255 for (size_t i = 0; i < skip; i++) |
1350 // Regularize a null matrix if stored into a variable. | 1350 // Regularize a null matrix if stored into a variable. |
1351 operator = (rhs.storable_value ()); | 1351 operator = (rhs.storable_value ()); |
1352 else if (is_defined ()) | 1352 else if (is_defined ()) |
1353 { | 1353 { |
1354 octave_value_typeinfo::assign_op_fcn f = 0; | 1354 octave_value_typeinfo::assign_op_fcn f = 0; |
1355 | 1355 |
1356 // Only attempt to operate in-place if this variable is unshared. | 1356 // Only attempt to operate in-place if this variable is unshared. |
1357 if (rep->count == 1) | 1357 if (rep->count == 1) |
1358 { | 1358 { |
1359 int tthis = this->type_id (); | 1359 int tthis = this->type_id (); |
1360 int trhs = rhs.type_id (); | 1360 int trhs = rhs.type_id (); |
1531 | 1531 |
1532 ColumnVector | 1532 ColumnVector |
1533 octave_value::column_vector_value (bool force_string_conv, | 1533 octave_value::column_vector_value (bool force_string_conv, |
1534 bool frc_vec_conv) const | 1534 bool frc_vec_conv) const |
1535 { | 1535 { |
1536 return ColumnVector (vector_value (force_string_conv, | 1536 return ColumnVector (vector_value (force_string_conv, |
1537 frc_vec_conv)); | 1537 frc_vec_conv)); |
1538 } | 1538 } |
1539 | 1539 |
1540 ComplexColumnVector | 1540 ComplexColumnVector |
1541 octave_value::complex_column_vector_value (bool force_string_conv, | 1541 octave_value::complex_column_vector_value (bool force_string_conv, |
1542 bool frc_vec_conv) const | 1542 bool frc_vec_conv) const |
1543 { | 1543 { |
1544 return ComplexColumnVector (complex_vector_value (force_string_conv, | 1544 return ComplexColumnVector (complex_vector_value (force_string_conv, |
1545 frc_vec_conv)); | 1545 frc_vec_conv)); |
1546 } | 1546 } |
1547 | 1547 |
1548 RowVector | 1548 RowVector |
1549 octave_value::row_vector_value (bool force_string_conv, | 1549 octave_value::row_vector_value (bool force_string_conv, |
1550 bool frc_vec_conv) const | 1550 bool frc_vec_conv) const |
1551 { | 1551 { |
1552 return RowVector (vector_value (force_string_conv, | 1552 return RowVector (vector_value (force_string_conv, |
1553 frc_vec_conv)); | 1553 frc_vec_conv)); |
1554 } | 1554 } |
1555 | 1555 |
1556 ComplexRowVector | 1556 ComplexRowVector |
1557 octave_value::complex_row_vector_value (bool force_string_conv, | 1557 octave_value::complex_row_vector_value (bool force_string_conv, |
1558 bool frc_vec_conv) const | 1558 bool frc_vec_conv) const |
1559 { | 1559 { |
1560 return ComplexRowVector (complex_vector_value (force_string_conv, | 1560 return ComplexRowVector (complex_vector_value (force_string_conv, |
1561 frc_vec_conv)); | 1561 frc_vec_conv)); |
1562 } | 1562 } |
1563 | 1563 |
1564 Array<double> | 1564 Array<double> |
1565 octave_value::vector_value (bool force_string_conv, | 1565 octave_value::vector_value (bool force_string_conv, |
1613 else if (is_uint8_type ()) | 1613 else if (is_uint8_type ()) |
1614 retval = convert_to_int_array (uint8_array_value ()); | 1614 retval = convert_to_int_array (uint8_array_value ()); |
1615 else | 1615 else |
1616 retval = array_value (force_string_conv); | 1616 retval = array_value (force_string_conv); |
1617 } | 1617 } |
1618 else | 1618 else |
1619 { | 1619 { |
1620 const NDArray a = array_value (force_string_conv); | 1620 const NDArray a = array_value (force_string_conv); |
1621 if (! error_state) | 1621 if (! error_state) |
1622 { | 1622 { |
1623 if (require_int) | 1623 if (require_int) |
1689 else if (is_uint8_type ()) | 1689 else if (is_uint8_type ()) |
1690 retval = convert_to_octave_idx_type_array (uint8_array_value ()); | 1690 retval = convert_to_octave_idx_type_array (uint8_array_value ()); |
1691 else | 1691 else |
1692 retval = array_value (force_string_conv); | 1692 retval = array_value (force_string_conv); |
1693 } | 1693 } |
1694 else | 1694 else |
1695 { | 1695 { |
1696 const NDArray a = array_value (force_string_conv); | 1696 const NDArray a = array_value (force_string_conv); |
1697 if (! error_state) | 1697 if (! error_state) |
1698 { | 1698 { |
1699 if (require_int) | 1699 if (require_int) |
1742 | 1742 |
1743 FloatColumnVector | 1743 FloatColumnVector |
1744 octave_value::float_column_vector_value (bool force_string_conv, | 1744 octave_value::float_column_vector_value (bool force_string_conv, |
1745 bool frc_vec_conv) const | 1745 bool frc_vec_conv) const |
1746 { | 1746 { |
1747 return FloatColumnVector (float_vector_value (force_string_conv, | 1747 return FloatColumnVector (float_vector_value (force_string_conv, |
1748 frc_vec_conv)); | 1748 frc_vec_conv)); |
1749 } | 1749 } |
1750 | 1750 |
1751 FloatComplexColumnVector | 1751 FloatComplexColumnVector |
1752 octave_value::float_complex_column_vector_value (bool force_string_conv, | 1752 octave_value::float_complex_column_vector_value (bool force_string_conv, |
1753 bool frc_vec_conv) const | 1753 bool frc_vec_conv) const |
1754 { | 1754 { |
1755 return FloatComplexColumnVector (float_complex_vector_value (force_string_conv, | 1755 return FloatComplexColumnVector (float_complex_vector_value (force_string_conv, |
1756 frc_vec_conv)); | 1756 frc_vec_conv)); |
1757 } | 1757 } |
1758 | 1758 |
1759 FloatRowVector | 1759 FloatRowVector |
1760 octave_value::float_row_vector_value (bool force_string_conv, | 1760 octave_value::float_row_vector_value (bool force_string_conv, |
1761 bool frc_vec_conv) const | 1761 bool frc_vec_conv) const |
1762 { | 1762 { |
1763 return FloatRowVector (float_vector_value (force_string_conv, | 1763 return FloatRowVector (float_vector_value (force_string_conv, |
1764 frc_vec_conv)); | 1764 frc_vec_conv)); |
1765 } | 1765 } |
1766 | 1766 |
1767 FloatComplexRowVector | 1767 FloatComplexRowVector |
1768 octave_value::float_complex_row_vector_value (bool force_string_conv, | 1768 octave_value::float_complex_row_vector_value (bool force_string_conv, |
1769 bool frc_vec_conv) const | 1769 bool frc_vec_conv) const |
1770 { | 1770 { |
1771 return FloatComplexRowVector (float_complex_vector_value (force_string_conv, | 1771 return FloatComplexRowVector (float_complex_vector_value (force_string_conv, |
1772 frc_vec_conv)); | 1772 frc_vec_conv)); |
1773 } | 1773 } |
1774 | 1774 |
1775 Array<float> | 1775 Array<float> |
1776 octave_value::float_vector_value (bool force_string_conv, | 1776 octave_value::float_vector_value (bool force_string_conv, |
1798 return retval.reshape (make_vector_dims (retval.dims (), | 1798 return retval.reshape (make_vector_dims (retval.dims (), |
1799 force_vector_conversion, | 1799 force_vector_conversion, |
1800 type_name (), "complex vector")); | 1800 type_name (), "complex vector")); |
1801 } | 1801 } |
1802 | 1802 |
1803 octave_value | 1803 octave_value |
1804 octave_value::storable_value (void) const | 1804 octave_value::storable_value (void) const |
1805 { | 1805 { |
1806 octave_value retval = *this; | 1806 octave_value retval = *this; |
1807 if (is_null_value ()) | 1807 if (is_null_value ()) |
1808 retval = octave_value (rep->empty_clone ()); | 1808 retval = octave_value (rep->empty_clone ()); |
1810 retval.maybe_economize (); | 1810 retval.maybe_economize (); |
1811 | 1811 |
1812 return retval; | 1812 return retval; |
1813 } | 1813 } |
1814 | 1814 |
1815 void | 1815 void |
1816 octave_value::make_storable_value (void) | 1816 octave_value::make_storable_value (void) |
1817 { | 1817 { |
1818 if (is_null_value ()) | 1818 if (is_null_value ()) |
1819 { | 1819 { |
1820 octave_base_value *rc = rep->empty_clone (); | 1820 octave_base_value *rc = rep->empty_clone (); |
1821 if (--rep->count == 0) | 1821 if (--rep->count == 0) |
1871 } | 1871 } |
1872 catch (octave_execution_exception) | 1872 catch (octave_execution_exception) |
1873 { | 1873 { |
1874 gripe_library_execution_error (); | 1874 gripe_library_execution_error (); |
1875 } | 1875 } |
1876 } | 1876 } |
1877 else | 1877 else |
1878 gripe_binary_op (octave_value::binary_op_as_string (op), | 1878 gripe_binary_op (octave_value::binary_op_as_string (op), |
1879 v1.class_name (), v2.class_name ()); | 1879 v1.class_name (), v2.class_name ()); |
1880 } | 1880 } |
1881 else | 1881 else |
2118 } | 2118 } |
2119 catch (octave_execution_exception) | 2119 catch (octave_execution_exception) |
2120 { | 2120 { |
2121 gripe_library_execution_error (); | 2121 gripe_library_execution_error (); |
2122 } | 2122 } |
2123 } | 2123 } |
2124 else | 2124 else |
2125 retval = decompose_binary_op (op, v1, v2); | 2125 retval = decompose_binary_op (op, v1, v2); |
2126 } | 2126 } |
2127 else | 2127 else |
2128 { | 2128 { |
2159 { | 2159 { |
2160 error ("type conversion failed for concatenation operator"); | 2160 error ("type conversion failed for concatenation operator"); |
2161 } | 2161 } |
2162 | 2162 |
2163 octave_value | 2163 octave_value |
2164 do_cat_op (const octave_value& v1, const octave_value& v2, | 2164 do_cat_op (const octave_value& v1, const octave_value& v2, |
2165 const Array<octave_idx_type>& ra_idx) | 2165 const Array<octave_idx_type>& ra_idx) |
2166 { | 2166 { |
2167 octave_value retval; | 2167 octave_value retval; |
2168 | 2168 |
2169 // Can't rapid return for concatenation with an empty object here as | 2169 // Can't rapid return for concatenation with an empty object here as |
2362 // not happen, and if it did anyway (internal error), the message would | 2362 // not happen, and if it did anyway (internal error), the message would |
2363 // be confusing. | 2363 // be confusing. |
2364 if (is_undefined ()) | 2364 if (is_undefined ()) |
2365 { | 2365 { |
2366 std::string op_str = unary_op_as_string (op); | 2366 std::string op_str = unary_op_as_string (op); |
2367 error ("in x%s or %sx, x must be defined first", | 2367 error ("in x%s or %sx, x must be defined first", |
2368 op_str.c_str (), op_str.c_str ()); | 2368 op_str.c_str (), op_str.c_str ()); |
2369 return *this; | 2369 return *this; |
2370 } | 2370 } |
2371 | 2371 |
2372 // Genuine. | 2372 // Genuine. |
2513 } | 2513 } |
2514 | 2514 |
2515 return binop; | 2515 return binop; |
2516 } | 2516 } |
2517 | 2517 |
2518 octave_value::binary_op | 2518 octave_value::binary_op |
2519 octave_value::op_eq_to_binary_op (assign_op op) | 2519 octave_value::op_eq_to_binary_op (assign_op op) |
2520 { | 2520 { |
2521 binary_op binop = unknown_binary_op; | 2521 binary_op binop = unknown_binary_op; |
2522 | 2522 |
2523 switch (op) | 2523 switch (op) |