![]() |
Prev | Next |
integer f2cad::idamax_(integer *n, doublereal *dx, integer *incx);
idamax.f
to
determine the index corresponding to the maximum element in the vector
\[
\left( \begin{array}{cccc}
1 & 2 & 5 & 4
\end{array} \right)
\]
The maximum element is 5 and its index (in Fortran notation) is 3.
# include <f2cad/idamax.hpp>
test_result idamax(void)
{ bool ok = true;
// dx is a vector of length 4
double data[] = {1, 2, 5, 4};
doublereal dx[4];
integer i;
for(i = 0; i < 4; i++)
dx[i] = data[i];
// other arguments to idamax
integer n = 4;
integer incx = 1;
// check return value
ok &= ( 3 == f2cad::idamax_(&n, dx, &incx) );
if( ok )
return test_pass;
return test_fail;
}