/*
 *  $Id: NetVecRand.c 1.3 1995/03/14 23:11:41 daltern Exp $
 *
 *	Function	NetVecRand
 *	Programmer	Nicholas d'Alterio
 *	Date		15/01/95
 *
 *  Synopsis:	This randomises the order of a set of vectors by 
 *		swapping random rows many times.
 *
 *  $Log: NetVecRand.c $
 * Revision 1.3  1995/03/14  23:11:41  daltern
 * Added comments and cleaned up
 *
 *
 */

#include "Neural.h"

void NetVecRand( VECTOR *vec )

 {

  register int i;

  int	row1;
  int	row2;

  float *temp_in_row;
  float *temp_out_row;

/*
 * Randomise data sets by swapping 2 random rows NUM_RAND_STEPS times.
 */

  for ( i = 0; i < NUM_RAND_STEPS; i++ ) {


/*
 *  Get 2 random rows to swap.
 */

	row1 = (int)((vec->NumVecs-1) * RAND_FUNC());		  	
	row2 = (int)((vec->NumVecs-1) * RAND_FUNC());

/*
 *  Swap rows over.
 */

	temp_in_row 	  = vec->InVec[row1];
	temp_out_row      = vec->OutVec[row1];
	vec->InVec[row1]  = vec->InVec[row2];
	vec->OutVec[row1] = vec->OutVec[row2];
	vec->InVec[row2]  = temp_in_row;
	vec->OutVec[row2] = temp_out_row;


  }   /* end for i */

 return;

 }   /* end function NetVecRand */

