matrix.cpp 350 B

12345678910111213141516171819202122
  1. #include "matrix.hpp"
  2. void
  3. Matrix::resize(size_t _nr,size_t _nc){
  4. assert(_nr>0);
  5. assert(_nc>0);
  6. if(data!=nullptr) delete[] data;
  7. nr=_nr;
  8. nc=_nc;
  9. data=new double[nc*nr];
  10. }
  11. void
  12. Matrix::view() const{
  13. for(size_t i=0;i<nr;++i){
  14. cout<<'['<<get(i,0);
  15. for(size_t j=1;j<nc;++j){
  16. cout<<','<<get(i,j);
  17. }
  18. cout<<endl;
  19. }
  20. }