]> www.ginac.de Git - ginac.git/blobdiff - ginac/matrix.h
- speedup by declaring x_pt and so on const
[ginac.git] / ginac / matrix.h
index 141437bfa06f93fc4bb8988e7205555c4b8cc5a5..68532db4a9aa2ca8c99c402d620863fd9e29e75f 100644 (file)
@@ -1,7 +1,8 @@
 /** @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
@@ -46,14 +53,14 @@ protected:
 
     // 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;
@@ -69,15 +76,15 @@ protected:
     
     // 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;
@@ -86,16 +93,16 @@ public:
     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;
 };
 
@@ -120,10 +127,10 @@ inline ex eval(matrix const & m, int level=0)
 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)
@@ -141,8 +148,14 @@ inline ex charpoly(matrix const & m, ex const & lambda)
 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__