Mercurial > hg > octave-nkf
comparison liboctave/dSparse.cc @ 13030:b646413c3d0e
Make operators do smarter sparse conversions on permutation matrices.
* Sparse.cc (Sparse<T>::Sparse): New templated ctor, plus two instantiations.
* Sparse.h (Sparse<T>): Declare new ctor.
* MSparse.h (MSparse): Give this class a PermMatrix ctor.
* boolSparse.h (BoolSparseMatrix): Ditto.
* dSparse.cc: Refactor PermMatrix ctor, moved into common parent class.
* dSparse.h (SparseMatrix): Ditto.
* op-pm-sm.cc: Declare and install smarter permutation matrix operators.
* ov-perm.cc (octave_perm_matrix): Declare new virtual function override.
* ov-perm.cc (sparse_bool_matrix_value): Override this virtual function.
author | Jordi Gutiérrez Hermoso <jordigh@gmail.com> |
---|---|
date | Tue, 30 Aug 2011 18:36:06 -0500 |
parents | 12df7854fa7c |
children | d672edef956e |
comparison
equal
deleted
inserted
replaced
13029:50db905c3cf1 | 13030:b646413c3d0e |
---|---|
176 j++; | 176 j++; |
177 } | 177 } |
178 } | 178 } |
179 for (octave_idx_type i = l; i <= a.cols (); i++) | 179 for (octave_idx_type i = l; i <= a.cols (); i++) |
180 cidx(i) = j; | 180 cidx(i) = j; |
181 } | |
182 | |
183 SparseMatrix::SparseMatrix (const PermMatrix& a) | |
184 : MSparse<double> (a.rows (), a.cols (), a.rows ()) | |
185 { | |
186 octave_idx_type n = a.rows (); | |
187 for (octave_idx_type i = 0; i <= n; i++) | |
188 cidx (i) = i; | |
189 const Array<octave_idx_type> pv = a.pvec (); | |
190 | |
191 if (a.is_row_perm ()) | |
192 { | |
193 for (octave_idx_type i = 0; i < n; i++) | |
194 ridx (pv (i)) = i; | |
195 } | |
196 else | |
197 { | |
198 for (octave_idx_type i = 0; i < n; i++) | |
199 ridx (i) = pv (i); | |
200 } | |
201 | |
202 for (octave_idx_type i = 0; i < n; i++) | |
203 data (i) = 1.0; | |
204 } | 181 } |
205 | 182 |
206 bool | 183 bool |
207 SparseMatrix::operator == (const SparseMatrix& a) const | 184 SparseMatrix::operator == (const SparseMatrix& a) const |
208 { | 185 { |