X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fmatrix.cpp;h=a6f3ca9268135c73fa51e186b234b36cb05459fd;hp=9dc46de92776ff3a8988d40e76b92e10c6effe03;hb=846e62e85c483f74d1e253c7841050ea11d70451;hpb=dfa384d36f986f5f8d7dbb5e20c0d3a63af42cd9 diff --git a/ginac/matrix.cpp b/ginac/matrix.cpp index 9dc46de9..a6f3ca92 100644 --- a/ginac/matrix.cpp +++ b/ginac/matrix.cpp @@ -3,7 +3,7 @@ * Implementation of symbolic matrices */ /* - * GiNaC Copyright (C) 1999-2003 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2004 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -234,6 +234,34 @@ ex matrix::subs(const exmap & mp, unsigned options) const return matrix(row, col, m2).subs_one_level(mp, options); } +/** Complex conjugate every matrix entry. */ +ex matrix::conjugate() const +{ + exvector * ev = 0; + for (exvector::const_iterator i=m.begin(); i!=m.end(); ++i) { + ex x = i->conjugate(); + if (ev) { + ev->push_back(x); + continue; + } + if (are_ex_trivially_equal(x, *i)) { + continue; + } + ev = new exvector; + ev->reserve(m.size()); + for (exvector::const_iterator j=m.begin(); j!=i; ++j) { + ev->push_back(*j); + } + ev->push_back(x); + } + if (ev) { + ex result = matrix(row, col, *ev); + delete ev; + return result; + } + return *this; +} + // protected int matrix::compare_same_type(const basic & other) const @@ -938,6 +966,7 @@ matrix matrix::inverse() const * * @param vars n x p matrix, all elements must be symbols * @param rhs m x p matrix + * @param algo selects the solving algorithm * @return n x p solution matrix * @exception logic_error (incompatible matrices) * @exception invalid_argument (1st argument must be matrix of symbols)