#include "mex.h" typedef double elem_type ; #define ELEM_SWAP(a,b) { register elem_type t=(a);(a)=(b);(b)=t; } /*--------------------------------------------------------------------------- Function : kth_smallest() In : array of elements, # of elements in the array, rank k Out : one element Job : find the kth smallest element in the array Notice : use the median() macro defined below to get the median. Reference: Author: Wirth, Niklaus Title: Algorithms + data structures = programs Publisher: Englewood Cliffs: Prentice-Hall, 1976 Physical description: 366 p. Series: Prentice-Hall Series in Automatic Computation ---------------------------------------------------------------------------*/ elem_type kth_smallest(elem_type a[], int n, int k) { register i,j,l,m ; register elem_type x ; l=0 ; m=n-1 ; while (l