comparison liboctave/Sparse.cc @ 10509:ddbd812d09aa

properly compress sparse matrices after assembly
author Jaroslav Hajek <highegg@gmail.com>
date Mon, 12 Apr 2010 12:57:44 +0200
parents bdf5d85cfc5e
children aac9f4265048
comparison
equal deleted inserted replaced
10508:9a5e2d13fa5a 10509:ddbd812d09aa
327 } 327 }
328 else if (a_scalar) 328 else if (a_scalar)
329 { 329 {
330 // This is completely specialized, because the sorts can be simplified. 330 // This is completely specialized, because the sorts can be simplified.
331 T a0 = a(0); 331 T a0 = a(0);
332 if (cl == 1) 332 if (a0 == T())
333 {
334 // Do nothing, it's an empty matrix.
335 }
336 else if (cl == 1)
333 { 337 {
334 // Sparse column vector. Sort row indices. 338 // Sparse column vector. Sort row indices.
335 idx_vector rs = r.sorted (); 339 idx_vector rs = r.sorted ();
336 340
337 octave_quit (); 341 octave_quit ();
514 if (rd[i] != rd[i-1]) 518 if (rd[i] != rd[i-1])
515 rri[++k] = rd[i]; 519 rri[++k] = rd[i];
516 rrd[k] = a(rdi[i]); 520 rrd[k] = a(rdi[i]);
517 } 521 }
518 } 522 }
523
524 maybe_compress (true);
519 } 525 }
520 else 526 else
521 { 527 {
522 idx_vector rr = r, cc = c; 528 idx_vector rr = r, cc = c;
523 const octave_idx_type *rd = rr.raw (), *cd = cc.raw (); 529 const octave_idx_type *rd = rr.raw (), *cd = cc.raw ();
604 } 610 }
605 rrd[jj] = a(spairs[i].second); 611 rrd[jj] = a(spairs[i].second);
606 } 612 }
607 } 613 }
608 } 614 }
615
616 maybe_compress (true);
609 } 617 }
610 } 618 }
611 619
612 template <class T> 620 template <class T>
613 Sparse<T>::Sparse (const Array<T>& a) 621 Sparse<T>::Sparse (const Array<T>& a)