/* vecdebug.c routines to help debugging with the vector package. * (C) Copyright 1999 by John Halleck * All rights reserved. */ /* Version of August 16th, 1999 */ #include /* Standard IO */ #include "errors.h" /* Common error codes */ #include "vec.h" /* Matrix specific stuff */ #include "vecdebug.h" /* And interfaces specific to this. */ /* --------------------- Printing ----------------------------------- */ error vecprint (char *text, int size, vector toprint) { if (text) printf ("%s\n", text); if (!toprint) return ERRnil; if (size < 1) return ERRsize; printf ("["); while (size--) printf (" %f", *toprint++); printf (" ]\n"); return NoError; } /* ---------------------- Equality ------------------------------- */ /* Exact */ error veciseq (int size, vector a, vector b) { if (!a || !b) return ERRnil; if (size < 1) return ERRsize; while (size--) if (*a++ != *b++) return ERRfalse; return NoError; } /* Approximate */ error vecisaeq (int size, vector a, vector b, double fudge) { double diff; if (!a || !b) return ERRnil; if (size<1) return ERRsize; while (size--) { diff = *a++ - *b++; if (diff < 0) diff = -diff; if (diff > fudge) return ERRfalse; } return NoError; }