X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?a=blobdiff_plain;f=ginac%2Fmatrix.h;h=4dc2ee0584e1cad9c78fcf3752700093da75e305;hb=1d07d8ac9fb47c51aa19a84df6c8c5fee5dd5105;hp=927c27c1434896cc2776f69c0c222e3114e3e094;hpb=708e9e647029af699333fceffc0a76bef70a4709;p=ginac.git diff --git a/ginac/matrix.h b/ginac/matrix.h index 927c27c1..4dc2ee05 100644 --- a/ginac/matrix.h +++ b/ginac/matrix.h @@ -3,7 +3,7 @@ * Interface to symbolic matrices */ /* - * GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2003 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 @@ -24,6 +24,7 @@ #define __GINAC_MATRIX_H__ #include +#include #include "basic.h" #include "ex.h" @@ -40,7 +41,7 @@ public: matrix(unsigned r, unsigned c, const exvector & m2); matrix(unsigned r, unsigned c, const lst & l); - // functions overriding virtual functions from bases classes + // functions overriding virtual functions from base classes public: void print(const print_context & c, unsigned level = 0) const; unsigned nops() const; @@ -132,13 +133,6 @@ inline matrix inverse(const matrix & m) // utility functions -/** Return the matrix object handled by an ex. Deprecated: use ex_to(). - * This is unsafe: you need to check the type first. */ -inline const matrix &ex_to_matrix(const ex &e) -{ - return static_cast(*e.bp); -} - /** Specialization of is_exactly_a(obj) for matrix objects. */ template<> inline bool is_exactly_a(const basic & obj) { @@ -151,6 +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 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__