#include "ld_nrutil.h"
#include "malloc.h"
#include <stdio.h>


long double *ldvector(int nl,int nh)
{
	long double *v;

	v=(long double *)malloc((unsigned) (nh-nl+1)*sizeof(long double));
	if (!v) nrerror("allocation failure in ldvector()");
	return v-nl;
}



long double **ldmatrix(int nrl,int nrh,int ncl,int nch)
{
	int i;
	long double **m;

	m=(long double **) malloc((unsigned) (nrh-nrl+1)*sizeof(long double*));
	if (!m) nrerror("allocation failure 1 in ldmatrix()");
	m -= nrl;

	for(i=nrl;i<=nrh;i++) {
		m[i]=(long double *) malloc((unsigned) (nch-ncl+1)*sizeof(long double));
		if (!m[i]) nrerror("allocation failure 2 in ldmatrix()");
		m[i] -= ncl;
	}
	return m;
}


void free_ldvector(long double *v, int nl,int nh)
{
	free((char*) (v+nl));
}


void free_ldmatrix(long double **m, int nrl,int nrh,int ncl,int nch)
{
	int i;

	for(i=nrh;i>=nrl;i--) free((char*) (m[i]+ncl));
	free((char*) (m+nrl));
}

