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

  1. #include "Matrix.h"
  2.     
  3.  
  4. void Matrix::setunity(void)
  5.     {
  6.     if(rows()!=cols()) error("dimensions do not match");
  7.     for(unsigned int i=1;i<=rows();i++)
  8.         {
  9.         for(unsigned int j=1;j<=cols();j++)
  10.             {
  11.             if(i==j)
  12.                 {
  13.                 (*this)(i,j)=1.0;
  14.                 }
  15.             else
  16.                 {
  17.                 (*this)(i,j)=0.0;
  18.                 }
  19.             }
  20.         }
  21.     }
  22.  
  23.