3 * Interface to symbolic matrices */
12 /** Symbolic matrices. */
13 class matrix : public basic
16 friend ex determinant_numeric(const matrix & m);
17 friend ex determinant_symbolic_perm(const matrix & m);
18 friend ex determinant_symbolic_minor(const matrix & m);
21 // default constructor, destructor, copy constructor, assignment operator
26 matrix(matrix const & other);
27 matrix const & operator=(matrix const & other);
29 void copy(matrix const & other);
30 void destroy(bool call_parent);
35 matrix(int r, int c, vector<ex> const & m2);
37 // functions overriding virtual functions from bases classes
39 basic * duplicate() const;
40 void printraw(ostream & os) const;
41 void print(ostream & os, unsigned upper_precedence=0) const;
43 ex & let_op(int const i);
44 ex expand(unsigned options=0) const;
45 bool has(ex const & other) const;
46 ex eval(int level=0) const;
47 ex evalf(int level=0) const;
48 // ex subs(lst const & ls, lst const & lr) const;
50 int compare_same_type(basic const & other) const;
51 unsigned return_type(void) const { return return_types::noncommutative; };
52 // new virtual functions which can be overridden by derived classes
55 // non-virtual functions in this class
57 int rows() const //! get number of rows.
59 int cols() const //! get number of columns.
61 matrix add(matrix const & other) const;
62 matrix sub(matrix const & other) const;
63 matrix mul(matrix const & other) const;
64 ex const & operator() (int ro, int co) const;
65 matrix & set(int ro, int co, ex value);
66 matrix transpose(void) const;
67 ex determinant(bool normalized=true) const;
69 ex charpoly(ex const & lambda) const;
70 matrix inverse(void) const;
71 matrix fraction_free_elim(matrix const & vars, matrix const & v) const;
72 matrix solve(matrix const & v) const;
75 void ffe_swap(int r1, int c1, int r2 ,int c2);
76 void ffe_set(int r, int c, ex e);
77 ex ffe_get(int r, int c) const;
81 int row; /**< number of rows */
82 int col; /**< number of columns */
83 vector<ex> m; /**< representation (cols indexed first) */
84 static unsigned precedence;
88 extern const matrix some_matrix;
89 extern type_info const & typeid_matrix;
91 // wrapper functions around member functions
93 inline int nops(matrix const & m)
96 inline ex expand(matrix const & m, unsigned options=0)
97 { return m.expand(options); }
99 inline bool has(matrix const & m, ex const & other)
100 { return m.has(other); }
102 inline ex eval(matrix const & m, int level=0)
103 { return m.eval(level); }
105 inline ex evalf(matrix const & m, int level=0)
106 { return m.evalf(level); }
108 inline int rows(matrix const & m)
111 inline int cols(matrix const & m)
114 inline matrix transpose(matrix const & m)
115 { return m.transpose(); }
117 inline ex determinant(matrix const & m, bool normalized=true)
118 { return m.determinant(normalized); }
120 inline ex trace(matrix const & m)
121 { return m.trace(); }
123 inline ex charpoly(matrix const & m, ex const & lambda)
124 { return m.charpoly(lambda); }
126 inline matrix inverse(matrix const & m)
127 { return m.inverse(); }
131 #define ex_to_matrix(X) (static_cast<matrix const &>(*(X).bp))
133 #endif // ndef _MATRIX_H_