Prev Next max.cpp Headings

Maximum Element of a Matrix Source code
 
# include <mat2cpp.hpp>
# include <cassert>
namespace mat2cpp {
     double max 
     (const matrix<double> &x)
     {    assert( x.size1() * x.size2() > 0 );
          double y = x(0, 0);
          size_t m = x.size1();
          size_t n = x.size2();
          size_t i, j;
          for(i = 0; i < m; i++)
          {    for(j = 0; j < n; j++)
                    y = std::max(y, x(i, j));
          }
          return y;
     }
}

Input File: lib/max.cpp