X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=moebius2.git;a=blobdiff_plain;f=common.c;h=62b981efa930fd19bbb3eab3bb94dd0ba0d14d69;hp=b87dedb3110950267c54157283a03d9592f5c1b0;hb=09c0156fef9837ca0eff4bf8b158d5638f18775e;hpb=f5fef8bc75d9d5658705763fa7c083ae75a501ba diff --git a/common.c b/common.c index b87dedb..62b981e 100644 --- a/common.c +++ b/common.c @@ -2,9 +2,6 @@ * Generally useful stuff. */ -#include -#include - #include "common.h" double magnD(const double pq[D3]) { @@ -46,5 +43,23 @@ void xprod(double r[D3], const double a[D3], const double b[D3]) { r[2]= a[0]*b[1] - a[1]*b[0]; } +double dotprod(const double a[D3], const double b[D3]) { + int k; + double result= 0; + K result += a[k] * b[k]; + return result; +} + +void libdie(const char *lib, int l, const char *str) { + fprintf(stderr,"%s library call failed, line %d: %s\n", lib, l, str); +} + +void gsldie(int l, const char *what, int status) { + fprintf(stderr,"gsl function failed, line %d: %s: %s\n", + l, what, gsl_strerror(status)); + exit(-1); +} + void diee(const char *what) { perror(what); exit(16); } +void fail(const char *emsg) { fputs(emsg,stderr); exit(12); } void flushoutput(void) { if (fflush(stdout)||ferror(stdout)) diee("stdout"); }