/*
 * MRANKP.C
 * "Posix" C main program illustrating the use of the MATLAB Math Library.
 * Calls mlfMrank, obtained by using MCC to compile mrank.m.
 */

#include <stdio.h>
#include <math.h>
#include "matlab.h"

/* Prototype for mlfMrank */
extern Matrix *mlfMrank( Matrix *);

int main( int argc, char **argv )
{
 int     n;    /* Integer parameter from command line. */
 Matrix *N;    /* Matrix containing n. */
 Matrix *R;    /* Result matrix. */

 /* Get any command line parameter. */
   if (argc >= 2)
     n = atoi(argv[1]);
   else
     n = 12;

 /* Create a 1-by-1 matrix containing n. */
   N = mxCreateFull (1, 1, REAL);
   *mxGetPr(N) = n;

 /* Call mlfMrank, the compiled version of mrank.m. */
   R = mlfMrank(N);

 /* Print the results. */
   mlfPrintMatrix(R);

 /* Free the matrices allocated during this computation. */
   mxFreeMatrix(N);
   mxFreeMatrix(R);

   return(0);
}

