/** @file matrix.h
*
- * Interface to symbolic matrices
- *
+ * Interface to symbolic matrices */
+
+/*
* GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
*
* This program is free software; you can redistribute it and/or modify
#define __GINAC_MATRIX_H__
#include <vector>
+#include <ginac/basic.h>
+#include <ginac/ex.h>
+
+#ifndef NO_GINAC_NAMESPACE
+namespace GiNaC {
+#endif // ndef NO_GINAC_NAMESPACE
/** Symbolic matrices. */
class matrix : public basic
// other constructors
public:
- matrix(int r, int c);
- matrix(int r, int c, vector<ex> const & m2);
+ matrix(unsigned r, unsigned c);
+ matrix(unsigned r, unsigned c, exvector const & m2);
// functions overriding virtual functions from bases classes
public:
basic * duplicate() const;
- void printraw(ostream & os) const;
void print(ostream & os, unsigned upper_precedence=0) const;
+ void printraw(ostream & os) const;
int nops() const;
ex & let_op(int const i);
ex expand(unsigned options=0) const;
// non-virtual functions in this class
public:
- int rows() const //! get number of rows.
+ unsigned rows() const //! get number of rows.
{ return row; }
- int cols() const //! get number of columns.
+ unsigned cols() const //! get number of columns.
{ return col; }
matrix add(matrix const & other) const;
matrix sub(matrix const & other) const;
matrix mul(matrix const & other) const;
- ex const & operator() (int ro, int co) const;
- matrix & set(int ro, int co, ex value);
+ ex const & operator() (unsigned ro, unsigned co) const;
+ matrix & set(unsigned ro, unsigned co, ex value);
matrix transpose(void) const;
ex determinant(bool normalized=true) const;
ex trace(void) const;
matrix fraction_free_elim(matrix const & vars, matrix const & v) const;
matrix solve(matrix const & v) const;
protected:
- int pivot(int ro);
- void ffe_swap(int r1, int c1, int r2 ,int c2);
- void ffe_set(int r, int c, ex e);
- ex ffe_get(int r, int c) const;
+ int pivot(unsigned ro);
+ void ffe_swap(unsigned r1, unsigned c1, unsigned r2 ,unsigned c2);
+ void ffe_set(unsigned r, unsigned c, ex e);
+ ex ffe_get(unsigned r, unsigned c) const;
// member variables
protected:
- int row; /**< number of rows */
- int col; /**< number of columns */
- vector<ex> m; /**< representation (cols indexed first) */
+ unsigned row; /**< number of rows */
+ unsigned col; /**< number of columns */
+ exvector m; /**< representation (cols indexed first) */
static unsigned precedence;
};
inline ex evalf(matrix const & m, int level=0)
{ return m.evalf(level); }
-inline int rows(matrix const & m)
+inline unsigned rows(matrix const & m)
{ return m.rows(); }
-inline int cols(matrix const & m)
+inline unsigned cols(matrix const & m)
{ return m.cols(); }
inline matrix transpose(matrix const & m)
inline matrix inverse(matrix const & m)
{ return m.inverse(); }
-// macros
+// utility functions
+inline const matrix &ex_to_matrix(const ex &e)
+{
+ return static_cast<const matrix &>(*e.bp);
+}
-#define ex_to_matrix(X) (static_cast<matrix const &>(*(X).bp))
+#ifndef NO_GINAC_NAMESPACE
+} // namespace GiNaC
+#endif // ndef NO_GINAC_NAMESPACE
#endif // ndef __GINAC_MATRIX_H__