comparison liboctave/CSparse.cc @ 8910:6e9f26506804

optimize diag -> sparse and perm -> sparse conversions
author Jaroslav Hajek <highegg@gmail.com>
date Thu, 05 Mar 2009 08:34:52 +0100
parents 25bc2d31e1bf
children eb63fbe60fab
comparison
equal deleted inserted replaced
8909:52596fe9f178 8910:6e9f26506804
144 ridx (i) = a.ridx (i); 144 ridx (i) = a.ridx (i);
145 } 145 }
146 } 146 }
147 147
148 SparseComplexMatrix::SparseComplexMatrix (const ComplexDiagMatrix& a) 148 SparseComplexMatrix::SparseComplexMatrix (const ComplexDiagMatrix& a)
149 : MSparse<Complex> (a.rows (), a.cols (), a.nnz ()) 149 : MSparse<Complex> (a.rows (), a.cols (), a.length ())
150 { 150 {
151 octave_idx_type nz = a.nnz (), l = a.length (); 151 octave_idx_type j = 0, l = a.length ();
152 for (octave_idx_type i = 0, j = 0; i < l; i++) 152 for (octave_idx_type i = 0; i < l; i++)
153 { 153 {
154 if (a(i, i) != Complex (0.0, 0.0)) 154 cidx (i) = j;
155 if (a(i, i) != 0.0)
155 { 156 {
156 data (j) = a(i, i); 157 data (j) = a(i, i);
157 ridx (j) = i; 158 ridx (j) = i;
158 cidx (j) = j;
159 j++; 159 j++;
160 } 160 }
161 } 161 }
162 cidx (nz) = nz; 162 for (octave_idx_type i = l; i <= a.cols (); i++)
163 cidx(i) = j;
163 } 164 }
164 bool 165 bool
165 SparseComplexMatrix::operator == (const SparseComplexMatrix& a) const 166 SparseComplexMatrix::operator == (const SparseComplexMatrix& a) const
166 { 167 {
167 octave_idx_type nr = rows (); 168 octave_idx_type nr = rows ();