![]() |
Prev | Next |
Matlab or Octave |
y = min( min( x) )
|
C++ |
y = min( x)
|
y = min( min(
x) )
sets y to the minimum element in the matrix x.
If either m or n is equal to one,
y = min(
x)
also sets y to the minimum element in the matrix x.
function [ok] = min_ok()
ok = true;
m = 2;
n = 3;
x = rand(m, n);
% ------------------
y = min( min(x) );
% ------------------
[m, n] = size(y);
ok = ok & (m == 1) & (n == 1);
ok = ok & all( all ( x >= y ) );
ok = ok & ~ all( all ( x > y ) );
return
y = min(
x)
where x is a non-empty
(non-zero row and column size)
ublas matrix<double>
object
and y is a double
.
# include <mat2cpp.hpp>
bool min_ok(void)
{ bool ok = true;
using namespace mat2cpp;
size_t i, j, m(2), n(3);
matrix<double> x = rand(m, n);
// ---------------
double y = min(x);
// ---------------
bool greater = true;
for(i = 0; i < m; i++)
{ for(j = 0; j < n; j++)
{ ok &= x(i,j) >= y;
greater &= x(i,j) > y;
}
}
ok &= ! greater;
return ok;
}