Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

matrix.h

Go to the documentation of this file.
00001 //----------------------------------------------------------------------
00002 //               The Motion Strategy Library (MSL)
00003 //----------------------------------------------------------------------
00004 //
00005 // Copyright (c) University of Illinois and Steven M. LaValle.     
00006 // All Rights Reserved.
00007 //
00008 // Permission to use, copy, and distribute this software and its
00009 // documentation is hereby granted free of charge, provided that
00010 // (1) it is not a component of a commercial product, and
00011 // (2) this notice appears in all copies of the software and
00012 //     related documentation.
00013 //
00014 // The University of Illinois and the author make no representations
00015 // about the suitability or fitness of this software for any purpose.
00016 // It is provided "as is" without express or implied warranty.
00017 //----------------------------------------------------------------------
00018 
00019 #ifndef MSL_MATRIX_H
00020 #define MSL_MATRIX_H
00021 
00022 #include "vector.h"
00023 #include "mslio.h"
00024 
00025 class MSLMatrix {
00026 
00027   MSLVector** v;
00028   int  d1;
00029   int  d2;
00030 
00031   void     flip_rows(int,int);
00032   void     check_dimensions(const MSLMatrix&) const; 
00033   double&  elem(int i, int j) const { return v[i]->v[j]; }
00034   double** triang(const MSLMatrix&, int&) const;
00035   
00036 public:
00037 
00038   MSLMatrix(int n=0, int m=0);
00039   MSLMatrix(int n, int m, double* D);
00040   MSLMatrix(const MSLMatrix&);
00041   MSLMatrix(const MSLVector&);
00042   MSLMatrix& operator=(const MSLMatrix&);
00043   ~MSLMatrix();
00044 
00045   int     dim1()  const  {  return d1; }
00046   int     dim2()  const  {  return d2; }
00047   MSLVector& row(int i) const;
00048   MSLVector  col(int i) const;
00049   MSLMatrix  trans() const;
00050   MSLMatrix  inv()   const;
00051   double  det()   const;
00052   MSLMatrix solve(const MSLMatrix&) const;
00053   MSLVector solve(const MSLVector& b) const 
00054     { return MSLVector(solve(MSLMatrix(b))); }
00055   operator MSLVector() const;
00056   MSLVector& operator[](int i)    const { return row(i); }
00057   double& operator()(int i, int j);
00058   double  operator()(int,int) const;
00059   int     operator==(const MSLMatrix&)    const;
00060   int     operator!=(const MSLMatrix& x)  const { return !(*this == x); }
00061   MSLMatrix operator+(const MSLMatrix& M1) const;
00062   MSLMatrix operator-(const MSLMatrix& M1) const;
00063   MSLMatrix operator-() const;
00064   MSLMatrix& operator-=(const MSLMatrix&);
00065   MSLMatrix& operator+=(const MSLMatrix&);
00066   MSLMatrix operator*(const MSLMatrix& M1) const;
00067   MSLVector operator*(const MSLVector& vec) const 
00068     { return MSLVector(*this * MSLMatrix(vec)); }
00069   MSLMatrix operator*(double x) const;
00070   void read(istream& I);
00071   void read() { read(cin); }
00072 
00073   friend ostream& operator<<(ostream& O, const MSLMatrix& M);
00074   friend istream& operator>>(istream& I, MSLMatrix& M);
00075 };
00076 
00077 ostream& operator<<(ostream& O, const MSLMatrix& M);
00078 istream& operator>>(istream& I, MSLMatrix& M);
00079 
00080 
00081 #endif
Motion Strategy Library


Web page maintained by Steve LaValle