Mercurial > hg > octave-nkf
comparison liboctave/CDiagMatrix.cc @ 10363:a0728e81ed25
improve diag matrix interface & implementation
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Fri, 26 Feb 2010 11:44:38 +0100 |
parents | 07ebe522dac2 |
children | fd0a3ac60b0e |
comparison
equal
deleted
inserted
replaced
10362:b47ab50a6aa8 | 10363:a0728e81ed25 |
---|---|
235 } | 235 } |
236 | 236 |
237 DiagMatrix | 237 DiagMatrix |
238 ComplexDiagMatrix::abs (void) const | 238 ComplexDiagMatrix::abs (void) const |
239 { | 239 { |
240 DiagMatrix retval (rows (), cols ()); | 240 return DiagMatrix (diag ().abs (), rows (), columns ()); |
241 for (octave_idx_type i = 0; i < rows (); i++) | |
242 retval(i, i) = std::abs (elem (i, i)); | |
243 return retval; | |
244 } | 241 } |
245 | 242 |
246 ComplexDiagMatrix | 243 ComplexDiagMatrix |
247 conj (const ComplexDiagMatrix& a) | 244 conj (const ComplexDiagMatrix& a) |
248 { | 245 { |
249 ComplexDiagMatrix retval; | 246 return ComplexDiagMatrix (conj (a.diag ()), a.rows (), a.columns ()); |
250 octave_idx_type a_len = a.length (); | |
251 if (a_len > 0) | |
252 retval = ComplexDiagMatrix (mx_inline_conj_dup (a.data (), a_len), | |
253 a.rows (), a.cols ()); | |
254 return retval; | |
255 } | 247 } |
256 | 248 |
257 // resize is the destructive analog for this one | 249 // resize is the destructive analog for this one |
258 | 250 |
259 ComplexMatrix | 251 ComplexMatrix |