PageRenderTime 37ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/Proj4/p_series.c

http://github.com/route-me/route-me
C | 42 lines | 40 code | 1 blank | 1 comment | 8 complexity | 860ad58f1d23bbb53c73ed71572c4dcf MD5 | raw file
  1. /* print row coefficients of Tseries structure */
  2. #ifndef lint
  3. static const char SCCSID[]="@(#)p_series.c 4.6 95/08/19 GIE REL";
  4. #endif
  5. #include "projects.h"
  6. #include <stdio.h>
  7. #include <string.h>
  8. #define NF 20 /* length of final format string */
  9. #define CUT 60 /* check length of line */
  10. void
  11. p_series(Tseries *T, FILE *file, char *fmt) {
  12. int i, j, n, L;
  13. char format[NF+1];
  14. *format = ' ';
  15. strncpy(format + 1, fmt, NF - 3);
  16. strcat(format, "%n");
  17. fprintf(file, "u: %d\n", T->mu+1);
  18. for (i = 0; i <= T->mu; ++i)
  19. if (T->cu[i].m) {
  20. L = fprintf(file, "%d %d", i, T->cu[i].m);
  21. n = 0;
  22. for (j = 0; j < T->cu[i].m; ++j) {
  23. if ((L += n) > CUT)
  24. L = fprintf(file, "\n ");
  25. fprintf(file, format, T->cu[i].c[j], &n);
  26. }
  27. fputc('\n', file);
  28. }
  29. fprintf(file, "v: %d\n", T->mv+1);
  30. for (i = 0; i <= T->mv; ++i)
  31. if (T->cv[i].m) {
  32. L = fprintf(file, "%d %d", i, T->cv[i].m);
  33. n = 0;
  34. for (j = 0; j < T->cv[i].m; ++j) {
  35. if ((L += n) > 60)
  36. L = fprintf(file, "\n ");
  37. fprintf(file, format, T->cv[i].c[j], &n);
  38. }
  39. fputc('\n', file);
  40. }
  41. }