/* FloatVect.c -- Data type-specific functions for class FloatVec

Author:
	K. E. Gorlen
	Bg. 12A, Rm. 2017
	Computer Systems Laboratory
	Division of Computer Research and Technology
	National Institutes of Health
	Bethesda, Maryland 20892
	Phone: (301) 496-5363
	uucp: {decvax!}seismo!elsie!cecil!keith
	June, 1986

Function:
	
Data type -specific functions for class FloatVec.

Modification History:
	
*/

#include "FloatVec.h"
#include "oopsconfig.h"
//#include <libc.h>		// cfront bug
extern void qsort(void*,int,int,int(*)());

#define	THIS	FloatVec
#define	BASE	Vector

static int typeCmp(float& a, float& b)
{
	register float t = a-b;
	if (t < 0) return -1;
	if (t > 0) return 1;
	return 0;
}

int THIS::hash()
{
	register int h = n;
#ifdef LOG2_INT
	register int i = n*sizeof(float) >> LOG2_INT;
#else
	register int i = n*sizeof(float)/sizeof(int);
#endif
	register int* vv = (int*)v;
	while (i--) h ^= *vv++;
	return h;
}

void THIS::printOn(ostream& strm)
{
	for (register int i=0; i<n; i++) {
		if (i>0 && (i%6 == 0)) strm << "\n\t";
		strm << form("%13.4g",v[i]);
	}
}

THIS::THIS(istream& strm, THIS& where)
{
	this = &where;
	strm >> n;
	v = new float[n];
	for (register int i =0; i<n; i++) strm >> v[i];
}

void THIS::storer(ostream& strm)
{
	Object::storer(strm);
	for (register int i=0; i<n; i++) strm << v[i] << " ";
}
