Mercurial > hg > octave-nkf
comparison liboctave/dDiagMatrix.cc @ 1627:8f798f963805
[project @ 1995-11-13 14:37:05 by jwe]
author | jwe |
---|---|
date | Mon, 13 Nov 1995 14:37:10 +0000 |
parents | 33bb7975f866 |
children | 23aa282707e8 |
comparison
equal
deleted
inserted
replaced
1626:90bbeec37a0e | 1627:8f798f963805 |
---|---|
284 { | 284 { |
285 (*current_liboctave_error_handler) ("inverse requires square matrix"); | 285 (*current_liboctave_error_handler) ("inverse requires square matrix"); |
286 return DiagMatrix (); | 286 return DiagMatrix (); |
287 } | 287 } |
288 | 288 |
289 DiagMatrix retval (nr, nc); | |
290 | |
289 info = 0; | 291 info = 0; |
290 double *tmp_data = dup (data (), len); | |
291 for (int i = 0; i < len; i++) | 292 for (int i = 0; i < len; i++) |
292 { | 293 { |
293 if (elem (i, i) == 0.0) | 294 if (elem (i, i) == 0.0) |
294 { | 295 { |
295 info = -1; | 296 info = -1; |
296 copy (tmp_data, data (), len); // Restore contents. | 297 return *this; |
297 break; | |
298 } | 298 } |
299 else | 299 else |
300 { | 300 retval.elem (i, i) = 1.0 / elem (i, i); |
301 tmp_data[i] = 1.0 / elem (i, i); | 301 } |
302 } | 302 |
303 } | 303 return retval; |
304 | |
305 return DiagMatrix (tmp_data, nr, nc); | |
306 } | 304 } |
307 | 305 |
308 // diagonal matrix by diagonal matrix -> diagonal matrix operations | 306 // diagonal matrix by diagonal matrix -> diagonal matrix operations |
309 | 307 |
310 DiagMatrix& | 308 DiagMatrix& |