From: Christian Bauer Date: Thu, 21 Nov 2002 20:48:57 +0000 (+0000) Subject: added symbolic_matrix() X-Git-Tag: release_1-0-13~16 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=1a75b1adc0e425989d9d3bf1b208411b738b9672 added symbolic_matrix() --- diff --git a/ginac/matrix.cpp b/ginac/matrix.cpp index 8daa11db..eaf4468a 100644 --- a/ginac/matrix.cpp +++ b/ginac/matrix.cpp @@ -20,7 +20,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include #include +#include #include #include #include @@ -229,7 +231,7 @@ ex matrix::eval(int level) const m2[r*col+c] = m[r*col+c].eval(level); return (new matrix(row, col, m2))->setflag(status_flags::dynallocated | - status_flags::evaluated ); + status_flags::evaluated); } ex matrix::subs(const lst & ls, const lst & lr, bool no_pattern) const @@ -1454,15 +1456,15 @@ ex lst_to_matrix(const lst & l) cols = l.op(i).nops(); // Allocate and fill matrix - matrix &m = *new matrix(rows, cols); - m.setflag(status_flags::dynallocated); + matrix &M = *new matrix(rows, cols); + M.setflag(status_flags::dynallocated); for (i=0; i j) - m(i, j) = l.op(i).op(j); + M(i, j) = l.op(i).op(j); else - m(i, j) = _ex0; - return m; + M(i, j) = _ex0; + return M; } ex diag_matrix(const lst & l) @@ -1485,4 +1487,41 @@ ex unit_matrix(unsigned r, unsigned c) return Id; } +ex symbolic_matrix(unsigned r, unsigned c, const std::string & base_name, const std::string & tex_base_name) +{ + matrix &M = *new matrix(r, c); + M.setflag(status_flags::dynallocated | status_flags::evaluated); + + bool long_format = (r > 10 || c > 10); + bool single_row = (r == 1 || c == 1); + + for (unsigned i=0; i +#include #include "basic.h" #include "ex.h" @@ -144,13 +145,23 @@ extern ex lst_to_matrix(const lst & l); /** Convert list of diagonal elements to matrix. */ extern ex diag_matrix(const lst & l); -/** Create a r times c unit matrix. */ +/** Create an r times c unit matrix. */ extern ex unit_matrix(unsigned r, unsigned c); /** Create a x times x unit matrix. */ inline ex unit_matrix(unsigned x) { return unit_matrix(x, x); } +/** Create an r times c matrix of newly generated symbols consisting of the + * given base name plus the numeric row/column position of each element. + * The base name for LaTeX output is specified separately. */ +extern ex symbolic_matrix(unsigned r, unsigned c, const std::string & base_name, const std::string & tex_base_name); + +/** Create an r times c matrix of newly generated symbols consisting of the + * given base name plus the numeric row/column position of each element. */ +inline ex symbolic_matrix(unsigned r, unsigned c, const std::string & base_name) +{ return symbolic_matrix(r, c, base_name, base_name); } + } // namespace GiNaC #endif // ndef __GINAC_MATRIX_H__