Mercurial > hg > octave-nkf
diff liboctave/CDiagMatrix.cc @ 3580:2923f52d8fda
[project @ 2000-02-05 07:14:21 by jwe]
author | jwe |
---|---|
date | Sat, 05 Feb 2000 07:14:25 +0000 |
parents | 5eef8a2294bd |
children | d9803711e047 |
line wrap: on
line diff
--- a/liboctave/CDiagMatrix.cc +++ b/liboctave/CDiagMatrix.cc @@ -418,120 +418,6 @@ return *this; } -ComplexDiagMatrix& -ComplexDiagMatrix::operator -= (const DiagMatrix& a) -{ - int r = rows (); - int c = cols (); - - int a_nr = a.rows (); - int a_nc = a.cols (); - - if (r != a_nr || c != a_nc) - { - gripe_nonconformant ("operator -=", r, c, a_nr, a_nc); - return *this; - } - - if (r == 0 || c == 0) - return *this; - - Complex *d = fortran_vec (); // Ensures only one reference to my privates! - - subtract2 (d, a.data (), length ()); - return *this; -} - -ComplexDiagMatrix& -ComplexDiagMatrix::operator += (const ComplexDiagMatrix& a) -{ - int r = rows (); - int c = cols (); - - int a_nr = a.rows (); - int a_nc = a.cols (); - - if (r != a_nr || c != a_nc) - { - gripe_nonconformant ("operator +=", r, c, a_nr, a_nc); - return *this; - } - - if (r == 0 || c == 0) - return *this; - - Complex *d = fortran_vec (); // Ensures only one reference to my privates! - - add2 (d, a.data (), length ()); - return *this; -} - -ComplexDiagMatrix& -ComplexDiagMatrix::operator -= (const ComplexDiagMatrix& a) -{ - int r = rows (); - int c = cols (); - - int a_nr = a.rows (); - int a_nc = a.cols (); - - if (r != a_nr || c != a_nc) - { - gripe_nonconformant ("operator -=", r, c, a_nr, a_nc); - return *this; - } - - if (r == 0 || c == 0) - return *this; - - Complex *d = fortran_vec (); // Ensures only one reference to my privates! - - subtract2 (d, a.data (), length ()); - return *this; -} - -// diagonal matrix by diagonal matrix -> diagonal matrix operations - -ComplexDiagMatrix -operator * (const ComplexDiagMatrix& a, const ComplexDiagMatrix& b) -{ - int a_nr = a.rows (); - int a_nc = a.cols (); - - int b_nr = b.rows (); - int b_nc = b.cols (); - - if (a_nc != b_nr) - { - gripe_nonconformant ("operator *", a_nr, a_nc, b_nr, b_nc); - return ComplexDiagMatrix (); - } - - if (a_nr == 0 || a_nc == 0 || b_nc == 0) - return ComplexDiagMatrix (a_nr, a_nc, 0.0); - - ComplexDiagMatrix c (a_nr, b_nc); - - int len = a_nr < b_nc ? a_nr : b_nc; - - for (int i = 0; i < len; i++) - { - Complex a_element = a.elem (i, i); - Complex b_element = b.elem (i, i); - - if (a_element == 0.0 || b_element == 0.0) - c.elem (i, i) = 0.0; - else if (a_element == 1.0) - c.elem (i, i) = b_element; - else if (b_element == 1.0) - c.elem (i, i) = a_element; - else - c.elem (i, i) = a_element * b_element; - } - - return c; -} - ComplexDiagMatrix operator * (const ComplexDiagMatrix& a, const DiagMatrix& b) {