home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / c / math_classes.lha / math_classes / matrix / libmatrix / mat_inverse.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-05  |  234 b   |  16 lines

  1. #include "Matrix.h"
  2.     
  3.     
  4. Matrix inverse(const Matrix& a)
  5.     {
  6.     Matrix m(a.rows(),a.cols());
  7.     LUmatrix b;
  8.     if(a.rows()!=a.cols())
  9.         {
  10.         error("dimensions do not match");
  11.         }
  12.     b=LUdecompose(a);
  13.     m=LUsolve(b,unity(a.rows()));
  14.     return m;
  15.     }
  16.