Mercurial > hg > octave-lyh
comparison liboctave/Sparse.cc @ 14791:90c131272396
maint: periodic merge of stable to default
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Thu, 21 Jun 2012 14:29:10 -0400 |
parents | 8d2ce821e38a b8041f48b0ff |
children | 8483286c0a13 |
comparison
equal
deleted
inserted
replaced
14787:acb09716fc94 | 14791:90c131272396 |
---|---|
1246 copy_or_memcpy (lbi, tmp.data (), data ()); | 1246 copy_or_memcpy (lbi, tmp.data (), data ()); |
1247 copy_or_memcpy (lbi, tmp.ridx (), ridx ()); | 1247 copy_or_memcpy (lbi, tmp.ridx (), ridx ()); |
1248 copy_or_memcpy (nz - ubi, tmp.data () + ubi, xdata () + lbi); | 1248 copy_or_memcpy (nz - ubi, tmp.data () + ubi, xdata () + lbi); |
1249 copy_or_memcpy (nz - ubi, tmp.ridx () + ubi, xridx () + lbi); | 1249 copy_or_memcpy (nz - ubi, tmp.ridx () + ubi, xridx () + lbi); |
1250 copy_or_memcpy (lb, tmp.cidx () + 1, cidx () + 1); | 1250 copy_or_memcpy (lb, tmp.cidx () + 1, cidx () + 1); |
1251 mx_inline_sub (nc - ub, xcidx () + 1, tmp.cidx () + ub + 1, ubi - lbi); | 1251 mx_inline_sub (nc - ub, xcidx () + lb + 1, |
1252 tmp.cidx () + ub + 1, ubi - lbi); | |
1252 } | 1253 } |
1253 else | 1254 else |
1254 *this = index (idx_i, idx_j.complement (nc)); | 1255 *this = index (idx_i, idx_j.complement (nc)); |
1255 } | 1256 } |
1256 else if (idx_j.is_colon ()) | 1257 else if (idx_j.is_colon ()) |
1581 } | 1582 } |
1582 else if (nc == 1 && idx_j.is_colon_equiv (nc) && idx_i.is_vector ()) | 1583 else if (nc == 1 && idx_j.is_colon_equiv (nc) && idx_i.is_vector ()) |
1583 { | 1584 { |
1584 // It's actually vector indexing. The 1D index is specialized for that. | 1585 // It's actually vector indexing. The 1D index is specialized for that. |
1585 retval = index (idx_i); | 1586 retval = index (idx_i); |
1587 | |
1588 // If nr == 1 then the vector indexing will return a column vector!! | |
1589 if (nr == 1) | |
1590 retval.transpose(); | |
1586 } | 1591 } |
1587 else if (idx_i.is_scalar ()) | 1592 else if (idx_i.is_scalar ()) |
1588 { | 1593 { |
1589 octave_idx_type ii = idx_i(0); | 1594 octave_idx_type ii = idx_i(0); |
1590 retval = Sparse<T> (1, m); | 1595 retval = Sparse<T> (1, m); |
2734 | 2739 |
2735 bug #35570: | 2740 bug #35570: |
2736 | 2741 |
2737 %!assert (speye (3,1)(3:-1:1), sparse ([0; 0; 1])) | 2742 %!assert (speye (3,1)(3:-1:1), sparse ([0; 0; 1])) |
2738 | 2743 |
2744 ## Test removing columns (bug #36656) | |
2745 | |
2746 %!test | |
2747 %! s = sparse (magic (5)); | |
2748 %! s(:,2:4) = []; | |
2749 %! assert (s, sparse (magic (5)(:, [1,5]))); | |
2750 | |
2751 %!test | |
2752 %! s = sparse([], [], [], 1, 1); | |
2753 %! s(1,:) = []; | |
2754 %! assert (s, sparse ([], [], [], 0, 1)); | |
2755 | |
2739 */ | 2756 */ |
2740 | 2757 |
2741 template <class T> | 2758 template <class T> |
2742 void | 2759 void |
2743 Sparse<T>::print_info (std::ostream& os, const std::string& prefix) const | 2760 Sparse<T>::print_info (std::ostream& os, const std::string& prefix) const |