(file) Return to nrutil.c CVS log (file) (dir) Up to [Development] / JSOC / proj / limbfit / apps

File: [Development] / JSOC / proj / limbfit / apps / nrutil.c (download)
Revision: 1.1, Tue Sep 21 23:06:38 2010 UTC (12 years, 6 months ago) by scholl
Branch: MAIN
CVS Tags: Ver_LATEST, Ver_9-5, Ver_9-41, Ver_9-4, Ver_9-3, Ver_9-2, Ver_9-1, Ver_9-0, Ver_8-8, Ver_8-7, Ver_8-6, Ver_8-5, Ver_8-4, Ver_8-3, Ver_8-2, Ver_8-12, Ver_8-11, Ver_8-10, Ver_8-1, Ver_8-0, Ver_7-1, Ver_7-0, Ver_6-4, Ver_6-3, Ver_6-2, Ver_6-1, Ver_6-0, Ver_5-14, Ver_5-13, Ver_5-12, Ver_5-11, HEAD
1st ready version

#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include "nrutil.h"
#define NR_END 1
#define FREE_ARG char*

float *vector(long nl, long nh, int *status)
/* allocate a float vector with subscript range v[nl..nh] */
{
	float *v;
	*status=0;
	v=(float *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(float)));
	if (!v) {
		//nrerror("allocation failure in vector()");
		*status=-1;
	}
	return v-nl+NR_END;
}

int *ivector(long nl, long nh, int *status)
/* allocate an int vector with subscript range v[nl..nh] */
{
	int *v;
	*status=0;
	v=(int *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(int)));
	if (!v) {
		//nrerror("allocation failure in ivector()");
		*status=-1;
	}
	return v-nl+NR_END;
}


unsigned long *lvector(long nl, long nh, int *status)
/* allocate an unsigned long vector with subscript range v[nl..nh] */
{
	unsigned long *v;
	*status=0;
	v=(unsigned long *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(long)));
	if (!v){
		//nrerror("allocation failure in lvector()");
		*status=-1;
	}
	return v-nl+NR_END;
}

void free_vector(float *v, long nl, long nh)
/* free a float vector allocated with vector() */
{
	free((FREE_ARG) (v+nl-NR_END));
}

void free_ivector(int *v, long nl, long nh)
/* free an int vector allocated with ivector() */
{
	free((FREE_ARG) (v+nl-NR_END));
}

void free_lvector(unsigned long *v, long nl, long nh)
/* free an unsigned long vector allocated with lvector() */
{
	free((FREE_ARG) (v+nl-NR_END));
}




Karen Tian
Powered by
ViewCVS 0.9.4