From df55f81fe9ba93ede4f02c3b6778942de9502a37 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Wed, 9 Jul 2008 21:02:11 +0000
Subject: [PATCH] getdp2

---
 contrib/NR/Makefile   |  53 +------
 contrib/NR/nrutil.cpp | 333 +-----------------------------------------
 contrib/NR/nrutil.h   |  90 ++----------
 3 files changed, 22 insertions(+), 454 deletions(-)

diff --git a/contrib/NR/Makefile b/contrib/NR/Makefile
index c8567e7e84..5038ee04c7 100644
--- a/contrib/NR/Makefile
+++ b/contrib/NR/Makefile
@@ -1,32 +1,16 @@
-# $Id: Makefile,v 1.15 2008-06-07 17:20:57 geuzaine Exp $
+# GetDP - Copyright (C) 1997-2008 P. Dular, C. Geuzaine
 #
-# Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-# USA.
-# 
-# Please report all bugs and problems to <gmsh@geuz.org>.
+# See the LICENSE.txt file for license information. Please report all
+# bugs and problems to <getdp@geuz.org>.
 
 include ../../variables
 
-LIB = ../../lib/libGmshNR${LIBEXT}
+LIB = ../../lib/libGetDPNR${LIBEXT}
 
-INC = ${DASH}I../NR ${DASH}I../../Common ${DASH}I../../Numeric
+INC = ${DASH}I../../Common ${DASH}I../../DataStr ${DASH}I../../Numeric
 
 # don't optimize this library: there are some problems with gcc...
-CFLAGS  = ${FLAGS} ${INC} ${SYSINCLUDE}
+CFLAGS  = ${FLAGS} ${INC}
 
 SRC = brent.cpp\
       dpythag.cpp\
@@ -48,14 +32,11 @@ ${LIB}: ${OBJ}
 	${AR} ${ARFLAGS}${LIB} ${OBJ}
 	${RANLIB} ${LIB}
 
-cpobj: ${OBJ} 
-	cp -f ${OBJ} ../../lib/
-
 .cpp${OBJEXT}:
 	${CXX} ${CFLAGS} ${DASH}c $<
 
 clean:
-	rm -f *.o *.obj 
+	rm -f *.o *.obj
 
 depend:
 	(sed '/^# DO NOT DELETE THIS LINE/q' Makefile && \
@@ -66,23 +47,3 @@ depend:
 	rm -f Makefile.new
 
 # DO NOT DELETE THIS LINE
-brent.o: brent.cpp nrutil.h ../../Numeric/Numeric.h \
-  ../../Numeric/NumericEmbedded.h
-dpythag.o: dpythag.cpp nrutil.h ../../Numeric/Numeric.h \
-  ../../Numeric/NumericEmbedded.h
-dsvdcmp.o: dsvdcmp.cpp nrutil.h ../../Numeric/Numeric.h \
-  ../../Numeric/NumericEmbedded.h
-fdjac.o: fdjac.cpp nrutil.h ../../Numeric/Numeric.h \
-  ../../Numeric/NumericEmbedded.h
-fmin.o: fmin.cpp nrutil.h ../../Numeric/Numeric.h \
-  ../../Numeric/NumericEmbedded.h
-lnsrch.o: lnsrch.cpp nrutil.h ../../Numeric/Numeric.h \
-  ../../Numeric/NumericEmbedded.h
-lubksb.o: lubksb.cpp
-ludcmp.o: ludcmp.cpp nrutil.h ../../Numeric/Numeric.h \
-  ../../Numeric/NumericEmbedded.h
-mnbrak.o: mnbrak.cpp nrutil.h ../../Numeric/Numeric.h \
-  ../../Numeric/NumericEmbedded.h
-newt.o: newt.cpp nrutil.h ../../Numeric/Numeric.h \
-  ../../Numeric/NumericEmbedded.h
-nrutil.o: nrutil.cpp ../../Common/Message.h
diff --git a/contrib/NR/nrutil.cpp b/contrib/NR/nrutil.cpp
index 1aad573de9..019d915a65 100644
--- a/contrib/NR/nrutil.cpp
+++ b/contrib/NR/nrutil.cpp
@@ -1,14 +1,13 @@
-#define NRANSI
-#if defined(__STDC__) || defined(ANSI) || defined(NRANSI) /* ANSI */
+// This file has been modified for inclusion in GetDP
 
 #include <stdio.h>
 #include <stddef.h>
 #include <stdlib.h>
+#include "Message.h"
+
 #define NR_END 1
 #define FREE_ARG char*
 
-#include "Message.h"
-
 void nrerror(char error_text[])
 /* Numerical Recipes standard error handler */
 {
@@ -292,329 +291,3 @@ void free_f3tensor(float ***t, long nrl, long nrh, long ncl, long nch,
 	free((FREE_ARG) (t[nrl]+ncl-NR_END));
 	free((FREE_ARG) (t+nrl-NR_END));
 }
-
-#else /* ANSI */
-/* traditional - K&R */
-
-#include <stdio.h>
-#define NR_END 1
-#define FREE_ARG char*
-
-void nrerror(error_text)
-char error_text[];
-/* Numerical Recipes standard error handler */
-{
-	void exit();
-
-	fprintf(stderr,"Numerical Recipes run-time error...\n");
-	fprintf(stderr,"%s\n",error_text);
-	fprintf(stderr,"...now exiting to system...\n");
-	exit(1);
-}
-
-float *vector(nl,nh)
-long nh,nl;
-/* allocate a float vector with subscript range v[nl..nh] */
-{
-	float *v;
-
-	v=(float *)malloc((unsigned int) ((nh-nl+1+NR_END)*sizeof(float)));
-	if (!v) nrerror("allocation failure in vector()");
-	return v-nl+NR_END;
-}
-
-int *ivector(nl,nh)
-long nh,nl;
-/* allocate an int vector with subscript range v[nl..nh] */
-{
-	int *v;
-
-	v=(int *)malloc((unsigned int) ((nh-nl+1+NR_END)*sizeof(int)));
-	if (!v) nrerror("allocation failure in ivector()");
-	return v-nl+NR_END;
-}
-
-unsigned char *cvector(nl,nh)
-long nh,nl;
-/* allocate an unsigned char vector with subscript range v[nl..nh] */
-{
-	unsigned char *v;
-
-	v=(unsigned char *)malloc((unsigned int) ((nh-nl+1+NR_END)*sizeof(unsigned char)));
-	if (!v) nrerror("allocation failure in cvector()");
-	return v-nl+NR_END;
-}
-
-unsigned long *lvector(nl,nh)
-long nh,nl;
-/* allocate an unsigned long vector with subscript range v[nl..nh] */
-{
-	unsigned long *v;
-
-	v=(unsigned long *)malloc((unsigned int) ((nh-nl+1+NR_END)*sizeof(long)));
-	if (!v) nrerror("allocation failure in lvector()");
-	return v-nl+NR_END;
-}
-
-double *dvector(nl,nh)
-long nh,nl;
-/* allocate a double vector with subscript range v[nl..nh] */
-{
-	double *v;
-
-	v=(double *)malloc((unsigned int) ((nh-nl+1+NR_END)*sizeof(double)));
-	if (!v) nrerror("allocation failure in dvector()");
-	return v-nl+NR_END;
-}
-
-float **matrix(nrl,nrh,ncl,nch)
-long nch,ncl,nrh,nrl;
-/* allocate a float matrix with subscript range m[nrl..nrh][ncl..nch] */
-{
-	long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
-	float **m;
-
-	/* allocate pointers to rows */
-	m=(float **) malloc((unsigned int)((nrow+NR_END)*sizeof(float*)));
-	if (!m) nrerror("allocation failure 1 in matrix()");
-	m += NR_END;
-	m -= nrl;
-
-	/* allocate rows and set pointers to them */
-	m[nrl]=(float *) malloc((unsigned int)((nrow*ncol+NR_END)*sizeof(float)));
-	if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
-	m[nrl] += NR_END;
-	m[nrl] -= ncl;
-
-	for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
-
-	/* return pointer to array of pointers to rows */
-	return m;
-}
-
-double **dmatrix(nrl,nrh,ncl,nch)
-long nch,ncl,nrh,nrl;
-/* allocate a double matrix with subscript range m[nrl..nrh][ncl..nch] */
-{
-	long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
-	double **m;
-
-	/* allocate pointers to rows */
-	m=(double **) malloc((unsigned int)((nrow+NR_END)*sizeof(double*)));
-	if (!m) nrerror("allocation failure 1 in matrix()");
-	m += NR_END;
-	m -= nrl;
-
-	/* allocate rows and set pointers to them */
-	m[nrl]=(double *) malloc((unsigned int)((nrow*ncol+NR_END)*sizeof(double)));
-	if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
-	m[nrl] += NR_END;
-	m[nrl] -= ncl;
-
-	for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
-
-	/* return pointer to array of pointers to rows */
-	return m;
-}
-
-int **imatrix(nrl,nrh,ncl,nch)
-long nch,ncl,nrh,nrl;
-/* allocate a int matrix with subscript range m[nrl..nrh][ncl..nch] */
-{
-	long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
-	int **m;
-
-	/* allocate pointers to rows */
-	m=(int **) malloc((unsigned int)((nrow+NR_END)*sizeof(int*)));
-	if (!m) nrerror("allocation failure 1 in matrix()");
-	m += NR_END;
-	m -= nrl;
-
-
-	/* allocate rows and set pointers to them */
-	m[nrl]=(int *) malloc((unsigned int)((nrow*ncol+NR_END)*sizeof(int)));
-	if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
-	m[nrl] += NR_END;
-	m[nrl] -= ncl;
-
-	for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
-
-	/* return pointer to array of pointers to rows */
-	return m;
-}
-
-float **submatrix(a,oldrl,oldrh,oldcl,oldch,newrl,newcl)
-float **a;
-long newcl,newrl,oldch,oldcl,oldrh,oldrl;
-/* point a submatrix [newrl..][newcl..] to a[oldrl..oldrh][oldcl..oldch] */
-{
-	long i,j,nrow=oldrh-oldrl+1,ncol=oldcl-newcl;
-	float **m;
-
-	/* allocate array of pointers to rows */
-	m=(float **) malloc((unsigned int) ((nrow+NR_END)*sizeof(float*)));
-	if (!m) nrerror("allocation failure in submatrix()");
-	m += NR_END;
-	m -= newrl;
-
-	/* set pointers to rows */
-	for(i=oldrl,j=newrl;i<=oldrh;i++,j++) m[j]=a[i]+ncol;
-
-	/* return pointer to array of pointers to rows */
-	return m;
-}
-
-float **convert_matrix(a,nrl,nrh,ncl,nch)
-float *a;
-long nch,ncl,nrh,nrl;
-/* allocate a float matrix m[nrl..nrh][ncl..nch] that points to the matrix
-declared in the standard C manner as a[nrow][ncol], where nrow=nrh-nrl+1
-and ncol=nch-ncl+1. The routine should be called with the address
-&a[0][0] as the first argument. */
-{
-	long i,j,nrow=nrh-nrl+1,ncol=nch-ncl+1;
-	float **m;
-
-	/* allocate pointers to rows */
-	m=(float **) malloc((unsigned int) ((nrow+NR_END)*sizeof(float*)));
-	if (!m)	nrerror("allocation failure in convert_matrix()");
-	m += NR_END;
-	m -= nrl;
-
-	/* set pointers to rows */
-	m[nrl]=a-ncl;
-	for(i=1,j=nrl+1;i<nrow;i++,j++) m[j]=m[j-1]+ncol;
-	/* return pointer to array of pointers to rows */
-	return m;
-}
-
-float ***f3tensor(nrl,nrh,ncl,nch,ndl,ndh)
-long nch,ncl,ndh,ndl,nrh,nrl;
-/* allocate a float 3tensor with range t[nrl..nrh][ncl..nch][ndl..ndh] */
-{
-	long i,j,nrow=nrh-nrl+1,ncol=nch-ncl+1,ndep=ndh-ndl+1;
-	float ***t;
-
-	/* allocate pointers to pointers to rows */
-	t=(float ***) malloc((unsigned int)((nrow+NR_END)*sizeof(float**)));
-	if (!t) nrerror("allocation failure 1 in f3tensor()");
-	t += NR_END;
-	t -= nrl;
-
-	/* allocate pointers to rows and set pointers to them */
-	t[nrl]=(float **) malloc((unsigned int)((nrow*ncol+NR_END)*sizeof(float*)));
-	if (!t[nrl]) nrerror("allocation failure 2 in f3tensor()");
-	t[nrl] += NR_END;
-	t[nrl] -= ncl;
-
-	/* allocate rows and set pointers to them */
-	t[nrl][ncl]=(float *) malloc((unsigned int)((nrow*ncol*ndep+NR_END)*sizeof(float)));
-	if (!t[nrl][ncl]) nrerror("allocation failure 3 in f3tensor()");
-	t[nrl][ncl] += NR_END;
-	t[nrl][ncl] -= ndl;
-
-	for(j=ncl+1;j<=nch;j++) t[nrl][j]=t[nrl][j-1]+ndep;
-	for(i=nrl+1;i<=nrh;i++) {
-		t[i]=t[i-1]+ncol;
-		t[i][ncl]=t[i-1][ncl]+ncol*ndep;
-		for(j=ncl+1;j<=nch;j++) t[i][j]=t[i][j-1]+ndep;
-	}
-
-	/* return pointer to array of pointers to rows */
-	return t;
-}
-
-void free_vector(v,nl,nh)
-float *v;
-long nh,nl;
-/* free a float vector allocated with vector() */
-{
-	free((FREE_ARG) (v+nl-NR_END));
-}
-
-void free_ivector(v,nl,nh)
-int *v;
-long nh,nl;
-/* free an int vector allocated with ivector() */
-{
-	free((FREE_ARG) (v+nl-NR_END));
-}
-
-void free_cvector(v,nl,nh)
-long nh,nl;
-unsigned char *v;
-/* free an unsigned char vector allocated with cvector() */
-{
-	free((FREE_ARG) (v+nl-NR_END));
-}
-
-void free_lvector(v,nl,nh)
-long nh,nl;
-unsigned long *v;
-/* free an unsigned long vector allocated with lvector() */
-{
-	free((FREE_ARG) (v+nl-NR_END));
-}
-
-void free_dvector(v,nl,nh)
-double *v;
-long nh,nl;
-/* free a double vector allocated with dvector() */
-{
-	free((FREE_ARG) (v+nl-NR_END));
-}
-
-void free_matrix(m,nrl,nrh,ncl,nch)
-float **m;
-long nch,ncl,nrh,nrl;
-/* free a float matrix allocated by matrix() */
-{
-	free((FREE_ARG) (m[nrl]+ncl-NR_END));
-	free((FREE_ARG) (m+nrl-NR_END));
-}
-
-void free_dmatrix(m,nrl,nrh,ncl,nch)
-double **m;
-long nch,ncl,nrh,nrl;
-/* free a double matrix allocated by dmatrix() */
-{
-	free((FREE_ARG) (m[nrl]+ncl-NR_END));
-	free((FREE_ARG) (m+nrl-NR_END));
-}
-
-void free_imatrix(m,nrl,nrh,ncl,nch)
-int **m;
-long nch,ncl,nrh,nrl;
-/* free an int matrix allocated by imatrix() */
-{
-	free((FREE_ARG) (m[nrl]+ncl-NR_END));
-	free((FREE_ARG) (m+nrl-NR_END));
-}
-
-void free_submatrix(b,nrl,nrh,ncl,nch)
-float **b;
-long nch,ncl,nrh,nrl;
-/* free a submatrix allocated by submatrix() */
-{
-	free((FREE_ARG) (b+nrl-NR_END));
-}
-
-void free_convert_matrix(b,nrl,nrh,ncl,nch)
-float **b;
-long nch,ncl,nrh,nrl;
-/* free a matrix allocated by convert_matrix() */
-{
-	free((FREE_ARG) (b+nrl-NR_END));
-}
-
-void free_f3tensor(t,nrl,nrh,ncl,nch,ndl,ndh)
-float ***t;
-long nch,ncl,ndh,ndl,nrh,nrl;
-/* free a float f3tensor allocated by f3tensor() */
-{
-	free((FREE_ARG) (t[nrl][ncl]+ndl-NR_END));
-	free((FREE_ARG) (t[nrl]+ncl-NR_END));
-	free((FREE_ARG) (t+nrl-NR_END));
-}
-
-#endif /* ANSI */
diff --git a/contrib/NR/nrutil.h b/contrib/NR/nrutil.h
index dc6e7af56b..25aa402060 100644
--- a/contrib/NR/nrutil.h
+++ b/contrib/NR/nrutil.h
@@ -1,58 +1,21 @@
+// This file has been modified for inclusion in GetDP
+
 #ifndef _NR_UTILS_H_
 #define _NR_UTILS_H_
 
-/* This file has been modified for inclusion in Gmsh */
-
-/* Gmsh: */
 #include <math.h>
-#include "Numeric.h"
-
-/* Gmsh:
-static float sqrarg;
-#define SQR(a) ((sqrarg=(a)) == 0.0 ? 0.0 : sqrarg*sqrarg)
-
-static double dsqrarg;
-#define DSQR(a) ((dsqrarg=(a)) == 0.0 ? 0.0 : dsqrarg*dsqrarg)
-
-static double dmaxarg1,dmaxarg2;
-#define DMAX(a,b) (dmaxarg1=(a),dmaxarg2=(b),(dmaxarg1) > (dmaxarg2) ?\
-        (dmaxarg1) : (dmaxarg2))
-
-static double dminarg1,dminarg2;
-#define DMIN(a,b) (dminarg1=(a),dminarg2=(b),(dminarg1) < (dminarg2) ?\
-        (dminarg1) : (dminarg2))
-
-static float maxarg1,maxarg2;
-#define FMAX(a,b) (maxarg1=(a),maxarg2=(b),(maxarg1) > (maxarg2) ?\
-        (maxarg1) : (maxarg2))
-
-static float minarg1,minarg2;
-#define FMIN(a,b) (minarg1=(a),minarg2=(b),(minarg1) < (minarg2) ?\
-        (minarg1) : (minarg2))
 
-static long lmaxarg1,lmaxarg2;
-#define LMAX(a,b) (lmaxarg1=(a),lmaxarg2=(b),(lmaxarg1) > (lmaxarg2) ?\
-        (lmaxarg1) : (lmaxarg2))
-
-static long lminarg1,lminarg2;
-#define LMIN(a,b) (lminarg1=(a),lminarg2=(b),(lminarg1) < (lminarg2) ?\
-        (lminarg1) : (lminarg2))
-
-static int imaxarg1,imaxarg2;
-#define IMAX(a,b) (imaxarg1=(a),imaxarg2=(b),(imaxarg1) > (imaxarg2) ?\
-        (imaxarg1) : (imaxarg2))
-
-static int iminarg1,iminarg2;
-#define IMIN(a,b) (iminarg1=(a),iminarg2=(b),(iminarg1) < (iminarg2) ?\
-        (iminarg1) : (iminarg2))
-*/
-
-#define SIGN(a,b) ((b) >= 0.0 ? fabs(a) : -fabs(a))
-
-#if defined(__STDC__) || defined(ANSI) || defined(NRANSI) /* ANSI */
+#define SIGN(a,b)   ((b) >= 0.0 ? fabs(a) : -fabs(a))
+#define DSQR(a)     ((a)*(a)) 
+#define SQR(a)      ((a)*(a)) 
+#define DMIN(a,b)   ((a)<(b) ? (a) : (b))
+#define DMAX(a,b)   ((a)>(b) ? (a) : (b))
+#define FMIN(a,b)   ((a)<(b) ? (a) : (b))
+#define FMAX(a,b)   ((a)>(b) ? (a) : (b))
+#define IMIN(a,b)   ((a)<(b) ? (a) : (b))
+#define IMAX(a,b)   ((a)>(b) ? (a) : (b))
 
 void nrerror(char error_text[]);
-//float *vector(long nl, long nh);
 int *ivector(long nl, long nh);
 unsigned char *cvector(long nl, long nh);
 unsigned long *lvector(long nl, long nh);
@@ -77,33 +40,4 @@ void free_convert_matrix(float **b, long nrl, long nrh, long ncl, long nch);
 void free_f3tensor(float ***t, long nrl, long nrh, long ncl, long nch,
 	long ndl, long ndh);
 
-#else /* ANSI */
-/* traditional - K&R */
-
-void nrerror();
-float *vector();
-float **matrix();
-float **submatrix();
-float **convert_matrix();
-float ***f3tensor();
-double *dvector();
-double **dmatrix();
-int *ivector();
-int **imatrix();
-unsigned char *cvector();
-unsigned long *lvector();
-void free_vector();
-void free_dvector();
-void free_ivector();
-void free_cvector();
-void free_lvector();
-void free_matrix();
-void free_submatrix();
-void free_convert_matrix();
-void free_dmatrix();
-void free_imatrix();
-void free_f3tensor();
-
-#endif /* ANSI */
-
-#endif /* _NR_UTILS_H_ */
+#endif
-- 
GitLab