]> www.ginac.de Git - ginac.git/blobdiff - ginac/matrix.h
- Made determinant_algo (in flags.h) really work.
[ginac.git] / ginac / matrix.h
index 23d2a475c894ef6a87e06990c38369d20269a3cb..b737a38c72fec2e74b118cf57aaf285a295bb6ce 100644 (file)
 #define __GINAC_MATRIX_H__
 
 #include <vector>
-#include <ginac/basic.h>
-#include <ginac/ex.h>
+#include "basic.h"
+#include "ex.h"
 
-#ifndef NO_GINAC_NAMESPACE
+#ifndef NO_NAMESPACE_GINAC
 namespace GiNaC {
-#endif // ndef NO_GINAC_NAMESPACE
+#endif // ndef NO_NAMESPACE_GINAC
 
 /** Symbolic matrices. */
 class matrix : public basic
@@ -37,10 +37,7 @@ class matrix : public basic
     GINAC_DECLARE_REGISTERED_CLASS(matrix, basic)
 
 // friends
-    friend ex determinant_numeric(const matrix & m);
-    friend ex determinant_symbolic_perm(const matrix & m);
-    friend ex determinant_symbolic_minor(const matrix & m);
-
+// (none)
 // member functions
 
     // default constructor, destructor, copy constructor, assignment operator
@@ -62,8 +59,8 @@ public:
     // functions overriding virtual functions from bases classes
 public:
     basic * duplicate() const;
-    void print(ostream & os, unsigned upper_precedence=0) const;
-    void printraw(ostream & os) const;
+    void print(std::ostream & os, unsigned upper_precedence=0) const;
+    void printraw(std::ostream & os) const;
     unsigned nops() const;
     ex op(int i) const;
     ex & let_op(int i);
@@ -80,9 +77,9 @@ protected:
     
     // non-virtual functions in this class
 public:
-    unsigned rows() const            //! get number of rows.
+    unsigned rows(void) const        //! Get number of rows.
         { return row; }
-    unsigned cols() const            //! get number of columns.
+    unsigned cols(void) const        //! Get number of columns.
         { return col; }
     matrix add(const matrix & other) const;
     matrix sub(const matrix & other) const;
@@ -90,17 +87,19 @@ public:
     const ex & 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 determinant(unsigned options = determinant_algo::automatic) const;
     ex trace(void) const;
-    ex charpoly(const ex & lambda) const;
+    ex charpoly(const symbol & lambda) const;
     matrix inverse(void) const;
     matrix fraction_free_elim(const matrix & vars, const matrix & v) const;
-    matrix solve(const matrix & v) const;
+    matrix solve(const matrix & vars, const matrix & rhs) const;
+    matrix old_solve(const matrix & v) const;  // FIXME: may be removed
 protected:
-    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;
+    ex determinant_minor(void) const;
+    int gauss_elimination(void);
+    int division_free_elimination(void);
+    int fraction_free_elimination(bool det = false);
+    int pivot(unsigned ro, bool symbolic=true);
     
 // member variables
 protected:
@@ -110,10 +109,12 @@ protected:
     static unsigned precedence;
 };
 
+
 // global constants
 extern const matrix some_matrix;
 extern const type_info & typeid_matrix;
 
+
 // wrapper functions around member functions
 
 inline unsigned nops(const matrix & m)
@@ -140,13 +141,13 @@ inline unsigned cols(const matrix & m)
 inline matrix transpose(const matrix & m)
 { return m.transpose(); }
 
-inline ex determinant(const matrix & m, bool normalized=true)
-{ return m.determinant(normalized); }
+inline ex determinant(const matrix & m, unsigned options = determinant_algo::automatic)
+{ return m.determinant(options); }
 
 inline ex trace(const matrix & m)
 { return m.trace(); }
 
-inline ex charpoly(const matrix & m, const ex & lambda)
+inline ex charpoly(const matrix & m, const symbol & lambda)
 { return m.charpoly(lambda); }
 
 inline matrix inverse(const matrix & m)
@@ -158,8 +159,10 @@ inline const matrix &ex_to_matrix(const ex &e)
        return static_cast<const matrix &>(*e.bp);
 }
 
-#ifndef NO_GINAC_NAMESPACE
+extern ex lst_to_matrix(const ex &l);
+
+#ifndef NO_NAMESPACE_GINAC
 } // namespace GiNaC
-#endif // ndef NO_GINAC_NAMESPACE
+#endif // ndef NO_NAMESPACE_GINAC
 
 #endif // ndef __GINAC_MATRIX_H__