| 1 | /* ----------------- */ |
|---|
| 2 | /* --- nrio1fx.c --- */ |
|---|
| 3 | /* ----------------- */ |
|---|
| 4 | |
|---|
| 5 | /* |
|---|
| 6 | * Copyright (c) 2000-2014, Lionel Lacassagne, All rights reserved |
|---|
| 7 | * Univ Paris Sud XI, CNRS |
|---|
| 8 | */ |
|---|
| 9 | |
|---|
| 10 | #include <stdlib.h> |
|---|
| 11 | #include <stdio.h> |
|---|
| 12 | |
|---|
| 13 | #include "nrc_os_config.h" |
|---|
| 14 | #include "mypredef.h" |
|---|
| 15 | #include "nrtype.h" |
|---|
| 16 | #include "nrdef.h" |
|---|
| 17 | #include "nrkernel.h" |
|---|
| 18 | #include "nrmacro.h" |
|---|
| 19 | |
|---|
| 20 | #include "nralloc1.h" |
|---|
| 21 | #include "nrio1x.h" |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | /* --------------------------- */ |
|---|
| 25 | /* -- write_vector_circular -- */ |
|---|
| 26 | /* --------------------------- */ |
|---|
| 27 | |
|---|
| 28 | #undef write_type_vector_circular |
|---|
| 29 | #define write_type_vector_circular(t) \ |
|---|
| 30 | void short_name(t,write_,vector_circular)(t * v, int32_t nl, int32_t nh, int32_t c0, int32_t c1, char * format, char * filename) \ |
|---|
| 31 | { \ |
|---|
| 32 | int32_t n = nh - nl + 1; \ |
|---|
| 33 | FILE * f = fopen(filename, "wt"); \ |
|---|
| 34 | if (f == NULL) { \ |
|---|
| 35 | nrerror("Can't open file %s in %s\n", filename, __func__); \ |
|---|
| 36 | } \ |
|---|
| 37 | for (int32_t i = c0; i <= c1; i++) { \ |
|---|
| 38 | fprintf(f, format, v[i % n + nl]); \ |
|---|
| 39 | } \ |
|---|
| 40 | fprintf(f, "\n"); \ |
|---|
| 41 | fclose(f); \ |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | write_type_vector_circular(int8_t); |
|---|
| 45 | write_type_vector_circular(uint8_t); |
|---|
| 46 | write_type_vector_circular(int16_t); |
|---|
| 47 | write_type_vector_circular(uint16_t); |
|---|
| 48 | write_type_vector_circular(int32_t); |
|---|
| 49 | write_type_vector_circular(uint32_t); |
|---|
| 50 | write_type_vector_circular(int64_t); |
|---|
| 51 | write_type_vector_circular(uint64_t); |
|---|
| 52 | write_type_vector_circular(float); |
|---|
| 53 | write_type_vector_circular(double); |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | // Local Variables: |
|---|
| 58 | // tab-width: 4 |
|---|
| 59 | // c-basic-offset: 4 |
|---|
| 60 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
|---|
| 61 | // indent-tabs-mode: nil |
|---|
| 62 | // End: |
|---|
| 63 | |
|---|
| 64 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
|---|
| 65 | |
|---|