From 40d5c33f78b9703ed22e4ee6a8f03baad9fa9656 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fran=C3=A7ois=20Grondin?= Date: Mon, 3 Jul 2017 15:19:56 -0400 Subject: [PATCH] Add files via upload --- src/signal/aimg.c | 42 +++++++++++++ src/signal/aimg.h | 21 +++++++ src/signal/area.c | 90 +++++++++++++++++++++++++++ src/signal/area.h | 38 +++++++++++ src/signal/assignation.c | 43 +++++++++++++ src/signal/assignation.h | 22 +++++++ src/signal/beampattern.c | 54 ++++++++++++++++ src/signal/beampattern.h | 27 ++++++++ src/signal/coherence.c | 43 +++++++++++++ src/signal/coherence.h | 22 +++++++ src/signal/delta.c | 65 +++++++++++++++++++ src/signal/delta.h | 23 +++++++ src/signal/frame.c | 92 +++++++++++++++++++++++++++ src/signal/frame.h | 24 +++++++ src/signal/freq.c | 102 ++++++++++++++++++++++++++++++ src/signal/freq.h | 28 +++++++++ src/signal/gain.c | 46 ++++++++++++++ src/signal/gain.h | 22 +++++++ src/signal/hop.c | 100 +++++++++++++++++++++++++++++ src/signal/hop.h | 28 +++++++++ src/signal/impulse.c | 23 +++++++ src/signal/impulse.h | 18 ++++++ src/signal/index.c | 57 +++++++++++++++++ src/signal/index.h | 23 +++++++ src/signal/kalman.c | 28 +++++++++ src/signal/kalman.h | 22 +++++++ src/signal/map.c | 46 ++++++++++++++ src/signal/map.h | 22 +++++++ src/signal/mask.c | 46 ++++++++++++++ src/signal/mask.h | 22 +++++++ src/signal/mixture.c | 128 ++++++++++++++++++++++++++++++++++++++ src/signal/mixture.h | 35 +++++++++++ src/signal/pair.c | 65 +++++++++++++++++++ src/signal/pair.h | 23 +++++++ src/signal/particle.c | 49 +++++++++++++++ src/signal/particle.h | 22 +++++++ src/signal/point.c | 69 ++++++++++++++++++++ src/signal/point.h | 23 +++++++ src/signal/postprob.c | 64 +++++++++++++++++++ src/signal/postprob.h | 25 ++++++++ src/signal/pot.c | 69 ++++++++++++++++++++ src/signal/pot.h | 27 ++++++++ src/signal/scan.c | 81 ++++++++++++++++++++++++ src/signal/scan.h | 33 ++++++++++ src/signal/shift.c | 47 ++++++++++++++ src/signal/shift.h | 22 +++++++ src/signal/spatialgain.c | 78 +++++++++++++++++++++++ src/signal/spatialgain.h | 25 ++++++++ src/signal/spatialindex.c | 95 ++++++++++++++++++++++++++++ src/signal/spatialindex.h | 26 ++++++++ src/signal/spatialmask.c | 87 ++++++++++++++++++++++++++ src/signal/spatialmask.h | 25 ++++++++ src/signal/tau.c | 51 +++++++++++++++ src/signal/tau.h | 23 +++++++ src/signal/tdoa.c | 74 ++++++++++++++++++++++ src/signal/tdoa.h | 24 +++++++ src/signal/track.c | 75 ++++++++++++++++++++++ src/signal/track.h | 28 +++++++++ src/signal/triangle.c | 45 ++++++++++++++ src/signal/triangle.h | 21 +++++++ src/signal/window.c | 23 +++++++ src/signal/window.h | 18 ++++++ src/signal/xcorr.c | 80 ++++++++++++++++++++++++ src/signal/xcorr.h | 24 +++++++ 64 files changed, 2843 insertions(+) create mode 100644 src/signal/aimg.c create mode 100644 src/signal/aimg.h create mode 100644 src/signal/area.c create mode 100644 src/signal/area.h create mode 100644 src/signal/assignation.c create mode 100644 src/signal/assignation.h create mode 100644 src/signal/beampattern.c create mode 100644 src/signal/beampattern.h create mode 100644 src/signal/coherence.c create mode 100644 src/signal/coherence.h create mode 100644 src/signal/delta.c create mode 100644 src/signal/delta.h create mode 100644 src/signal/frame.c create mode 100644 src/signal/frame.h create mode 100644 src/signal/freq.c create mode 100644 src/signal/freq.h create mode 100644 src/signal/gain.c create mode 100644 src/signal/gain.h create mode 100644 src/signal/hop.c create mode 100644 src/signal/hop.h create mode 100644 src/signal/impulse.c create mode 100644 src/signal/impulse.h create mode 100644 src/signal/index.c create mode 100644 src/signal/index.h create mode 100644 src/signal/kalman.c create mode 100644 src/signal/kalman.h create mode 100644 src/signal/map.c create mode 100644 src/signal/map.h create mode 100644 src/signal/mask.c create mode 100644 src/signal/mask.h create mode 100644 src/signal/mixture.c create mode 100644 src/signal/mixture.h create mode 100644 src/signal/pair.c create mode 100644 src/signal/pair.h create mode 100644 src/signal/particle.c create mode 100644 src/signal/particle.h create mode 100644 src/signal/point.c create mode 100644 src/signal/point.h create mode 100644 src/signal/postprob.c create mode 100644 src/signal/postprob.h create mode 100644 src/signal/pot.c create mode 100644 src/signal/pot.h create mode 100644 src/signal/scan.c create mode 100644 src/signal/scan.h create mode 100644 src/signal/shift.c create mode 100644 src/signal/shift.h create mode 100644 src/signal/spatialgain.c create mode 100644 src/signal/spatialgain.h create mode 100644 src/signal/spatialindex.c create mode 100644 src/signal/spatialindex.h create mode 100644 src/signal/spatialmask.c create mode 100644 src/signal/spatialmask.h create mode 100644 src/signal/tau.c create mode 100644 src/signal/tau.h create mode 100644 src/signal/tdoa.c create mode 100644 src/signal/tdoa.h create mode 100644 src/signal/track.c create mode 100644 src/signal/track.h create mode 100644 src/signal/triangle.c create mode 100644 src/signal/triangle.h create mode 100644 src/signal/window.c create mode 100644 src/signal/window.h create mode 100644 src/signal/xcorr.c create mode 100644 src/signal/xcorr.h diff --git a/src/signal/aimg.c b/src/signal/aimg.c new file mode 100644 index 0000000..8c7f5c8 --- /dev/null +++ b/src/signal/aimg.c @@ -0,0 +1,42 @@ + + #include "aimg.h" + + aimg_obj * aimg_construct_zero(const unsigned int aimgSize) { + + aimg_obj * obj; + + obj = (aimg_obj *) malloc(sizeof(aimg_obj)); + + obj->aimgSize = aimgSize; + obj->array = (float *) malloc(sizeof(float) * aimgSize); + memset(obj->array, 0x00, aimgSize * sizeof(float)); + + return obj; + + } + + void aimg_destroy(aimg_obj * obj) { + + free((void *) obj->array); + free((void *) obj); + + } + + void aimg_printf(const aimg_obj * obj) { + + unsigned int iSignal; + unsigned int iSample; + + for (iSample = 0; iSample < obj->aimgSize; iSample++) { + + printf("%+1.5f ",obj->array[iSample]); + + if ((((iSample+1) % 16) == 0) && ((iSample+1)!=obj->aimgSize)) { + printf("\n"); + } + + } + + printf("\n"); + + } \ No newline at end of file diff --git a/src/signal/aimg.h b/src/signal/aimg.h new file mode 100644 index 0000000..10ad4bc --- /dev/null +++ b/src/signal/aimg.h @@ -0,0 +1,21 @@ +#ifndef __ODAS_SIGNAL_AIMG +#define __ODAS_SIGNAL_AIMG + + #include + #include + #include + + typedef struct aimg_obj { + + unsigned int aimgSize; + float * array; + + } aimg_obj; + + aimg_obj * aimg_construct_zero(const unsigned int aimgSize); + + void aimg_destroy(aimg_obj * obj); + + void aimg_printf(const aimg_obj * obj); + +#endif \ No newline at end of file diff --git a/src/signal/area.c b/src/signal/area.c new file mode 100644 index 0000000..79f43f7 --- /dev/null +++ b/src/signal/area.c @@ -0,0 +1,90 @@ + + #include "area.h" + + areas_obj * areas_construct_zero(const unsigned int nPointsDiscrete, const unsigned int nResolutionsPerDiscrete, const unsigned int nPairs) { + + areas_obj * obj; + + obj = (areas_obj *) malloc(sizeof(areas_obj)); + + obj->nPointsDiscrete = nPointsDiscrete; + obj->nResolutionsPerDiscrete = nResolutionsPerDiscrete; + obj->nPairs = nPairs; + + obj->array = (float *) malloc(sizeof(float) * nPointsDiscrete * nResolutionsPerDiscrete * nPairs); + memset(obj->array, 0x00, sizeof(float) * nPointsDiscrete * nResolutionsPerDiscrete * nPairs); + + return obj; + + } + + void areas_destroy(areas_obj * obj) { + + free((void *) obj->array); + free((void *) obj); + + } + + void areas_printf(const areas_obj * obj) { + + unsigned int iPointDiscrete; + unsigned int iResolutionPerDiscrete; + unsigned int iPair; + + printf("%u\n",obj->nPointsDiscrete); + printf("%u\n",obj->nResolutionsPerDiscrete); + printf("%u\n",obj->nPairs); + + for (iPointDiscrete = 0; iPointDiscrete < obj->nPointsDiscrete; iPointDiscrete++) { + + for (iResolutionPerDiscrete = 0; iResolutionPerDiscrete < obj->nResolutionsPerDiscrete; iResolutionPerDiscrete++) { + + printf("(%04u:%03u): ", iPointDiscrete, iResolutionPerDiscrete); + + for (iPair = 0; iPair < obj->nPairs; iPair++) { + + printf("%1.1E ",obj->array[iPointDiscrete * (obj->nResolutionsPerDiscrete * obj->nPairs) + iResolutionPerDiscrete * obj->nPairs + iPair]); + + } + + printf("\n"); + + } + + } + + } + + area_obj * area_construct_zero(const unsigned int nPairs) { + + area_obj * obj; + + obj = (area_obj *) malloc(sizeof(area_obj)); + + obj->nPairs = nPairs; + + obj->array = (float *) malloc(sizeof(float) * nPairs); + memset(obj->array, 0x00, sizeof(float) * nPairs); + + return obj; + + } + + void area_destroy(area_obj * obj) { + + free((void *) obj->array); + free((void *) obj); + + } + + void area_printf(const area_obj * obj) { + + unsigned int iPair; + + for (iPair = 0; iPair < obj->nPairs; iPair++) { + + printf("(%03u): %+1.3f\n", iPair, obj->array[iPair]); + + } + + } diff --git a/src/signal/area.h b/src/signal/area.h new file mode 100644 index 0000000..1801a31 --- /dev/null +++ b/src/signal/area.h @@ -0,0 +1,38 @@ +#ifndef __ODAS_SIGNAL_AREA +#define __ODAS_SIGNAL_AREA + + #include + #include + #include + + typedef struct areas_obj { + + unsigned int nPointsDiscrete; + unsigned int nResolutionsPerDiscrete; + unsigned int nPairs; + + float * array; + + } areas_obj; + + typedef struct area_obj { + + unsigned int nPairs; + + float * array; + + } area_obj; + + areas_obj * areas_construct_zero(const unsigned int nPointsDiscrete, const unsigned int nResolutionsPerDiscrete, const unsigned int nPairs); + + void areas_destroy(areas_obj * obj); + + void areas_printf(const areas_obj * obj); + + area_obj * area_construct_zero(const unsigned int nPairs); + + void area_destroy(area_obj * obj); + + void area_printf(const area_obj * obj); + +#endif \ No newline at end of file diff --git a/src/signal/assignation.c b/src/signal/assignation.c new file mode 100644 index 0000000..1469f98 --- /dev/null +++ b/src/signal/assignation.c @@ -0,0 +1,43 @@ + + #include "assignation.h" + + assignations_obj * assignations_construct_zero(const unsigned int nAssignations, const unsigned int nPots) { + + assignations_obj * obj; + + obj = (assignations_obj *) malloc(sizeof(assignations_obj)); + + obj->nAssignations = nAssignations; + obj->nPots = nPots; + obj->array = (signed int *) malloc(sizeof(signed int) * nAssignations * nPots); + memset(obj->array, 0x00, nAssignations * nPots * sizeof(signed int)); + + return obj; + + } + + void assignations_destroy(assignations_obj * obj) { + + free((void *) obj->array); + free((void *) obj); + + } + + void assignations_printf(const assignations_obj * obj) { + + unsigned int iAssignation; + unsigned int iPot; + + for (iAssignation = 0; iAssignation < obj->nAssignations; iAssignation++) { + + for (iPot = 0; iPot < obj->nPots; iPot++) { + + printf("%+01d ",obj->array[iAssignation * obj->nPots + iPot]); + + } + + printf("\n"); + + } + + } diff --git a/src/signal/assignation.h b/src/signal/assignation.h new file mode 100644 index 0000000..2ceaffe --- /dev/null +++ b/src/signal/assignation.h @@ -0,0 +1,22 @@ +#ifndef __ODAS_SIGNAL_ASSIGNATION +#define __ODAS_SIGNAL_ASSIGNATION + + #include + #include + #include + + typedef struct assignations_obj { + + unsigned int nAssignations; + unsigned int nPots; + signed int * array; + + } assignations_obj; + + assignations_obj * assignations_construct_zero(const unsigned int nAssignations, const unsigned int nPots); + + void assignations_destroy(assignations_obj * obj); + + void assignations_printf(const assignations_obj * obj); + +#endif \ No newline at end of file diff --git a/src/signal/beampattern.c b/src/signal/beampattern.c new file mode 100644 index 0000000..2e56289 --- /dev/null +++ b/src/signal/beampattern.c @@ -0,0 +1,54 @@ + + #include "beampattern.h" + + beampatterns_obj * beampatterns_construct_zero(const unsigned int nChannels, const unsigned int nThetas) { + + beampatterns_obj * obj; + + obj = (beampatterns_obj *) malloc(sizeof(beampatterns_obj)); + + obj->nChannels = nChannels; + obj->nThetas = nThetas; + + obj->minThetas = (float *) malloc(sizeof(float) * nChannels); + memset(obj->minThetas, 0x00, sizeof(float) * nChannels); + + obj->maxThetas = (float *) malloc(sizeof(float) * nChannels); + memset(obj->maxThetas, 0x00, sizeof(float) * nChannels); + + obj->deltaThetas = (float *) malloc(sizeof(float) * nChannels); + memset(obj->deltaThetas, 0x00, sizeof(float) * nChannels); + + obj->gains = (float *) malloc(sizeof(float) * nThetas * nChannels); + memset(obj->gains, 0x00, sizeof(float) * nThetas * nChannels); + + return obj; + + } + + void beampatterns_destroy(beampatterns_obj * obj) { + + free((void *) obj->minThetas); + free((void *) obj->maxThetas); + free((void *) obj->deltaThetas); + free((void *) obj->gains); + free((void *) obj); + + } + + void beampatterns_printf(const beampatterns_obj * obj) { + + unsigned int iChannel; + unsigned int iTheta; + + for (iChannel = 0; iChannel < obj->nChannels; iChannel++) { + + for (iTheta = 0; iTheta < obj->nThetas; iTheta++) { + + printf("(%02u,%04u): %1.3f\n", iChannel, iTheta, obj->gains[obj->nThetas * iChannel + iTheta]); + + } + + } + + } \ No newline at end of file diff --git a/src/signal/beampattern.h b/src/signal/beampattern.h new file mode 100644 index 0000000..a9cdabc --- /dev/null +++ b/src/signal/beampattern.h @@ -0,0 +1,27 @@ +#ifndef __ODAS_SIGNAL_BEAMPATTERN +#define __ODAS_SIGNAL_BEAMPATTERN + + #include + #include + #include + + typedef struct beampatterns_obj { + + unsigned int nChannels; + unsigned int nThetas; + + float * minThetas; + float * maxThetas; + float * deltaThetas; + + float * gains; + + } beampatterns_obj; + + beampatterns_obj * beampatterns_construct_zero(const unsigned int nChannels, const unsigned int nThetas); + + void beampatterns_destroy(beampatterns_obj * obj); + + void beampatterns_printf(const beampatterns_obj * obj); + +#endif \ No newline at end of file diff --git a/src/signal/coherence.c b/src/signal/coherence.c new file mode 100644 index 0000000..5bfb677 --- /dev/null +++ b/src/signal/coherence.c @@ -0,0 +1,43 @@ + + #include "coherence.h" + + coherences_obj * coherences_construct_zero(const unsigned int nPots, const unsigned int nTracks) { + + coherences_obj * obj; + obj = (coherences_obj *) malloc(sizeof(coherences_obj)); + obj->nPots = nPots; + obj->nTracks = nTracks; + obj->array = (float *) malloc(sizeof(float) * nTracks * nPots); + memset(obj->array, 0x00, sizeof(float) * nTracks * nPots); + + return obj; + + } + + void coherences_destroy(coherences_obj * obj) { + + free((void *) obj->array); + free((void *) obj); + + } + + void coherences_printf(coherences_obj * obj) { + + unsigned int iTrack; + unsigned int iPot; + + for (iTrack = 0; iTrack < obj->nTracks; iTrack++) { + + printf("p(z|C,%u) = ",iTrack); + + for (iPot = 0; iPot < obj->nPots; iPot++) { + + printf("%+1.3e ",obj->array[iTrack * obj->nPots + iPot]); + + } + + printf("\n"); + + } + + } diff --git a/src/signal/coherence.h b/src/signal/coherence.h new file mode 100644 index 0000000..fa9b7eb --- /dev/null +++ b/src/signal/coherence.h @@ -0,0 +1,22 @@ +#ifndef __ODAS_SIGNAL_COHERENCE +#define __ODAS_SIGNAL_COHERENCE + + #include + #include + #include + + typedef struct coherences_obj { + + unsigned int nTracks; + unsigned int nPots; + float * array; + + } coherences_obj; + + coherences_obj * coherences_construct_zero(const unsigned int nTracks, const unsigned int nPots); + + void coherences_destroy(coherences_obj * obj); + + void coherences_printf(coherences_obj * obj); + +#endif \ No newline at end of file diff --git a/src/signal/delta.c b/src/signal/delta.c new file mode 100644 index 0000000..1802a17 --- /dev/null +++ b/src/signal/delta.c @@ -0,0 +1,65 @@ + + #include "delta.h" + + // +----------------------------------------------------------+ + // | Constructor | + // +----------------------------------------------------------+ + + deltas_obj * deltas_construct_zero(const unsigned int nPairs) { + + deltas_obj * obj; + + obj = (deltas_obj *) malloc(sizeof(deltas_obj)); + + obj->nPairs = nPairs; + obj->array = (unsigned int *) malloc(sizeof(unsigned int) * nPairs); + memset(obj->array, 0x00, sizeof(unsigned int) * nPairs); + + return obj; + + } + + // +----------------------------------------------------------+ + // | Clone | + // +----------------------------------------------------------+ + + deltas_obj * deltas_clone(const deltas_obj * obj) { + + deltas_obj * clone; + + clone = (deltas_obj *) malloc(sizeof(deltas_obj)); + + clone->nPairs = obj->nPairs; + clone->array = (unsigned int *) malloc(sizeof(unsigned int) * obj->nPairs); + memcpy(clone->array, obj->array, sizeof(unsigned int) * obj->nPairs); + + return clone; + + } + + // +----------------------------------------------------------+ + // | Destructor | + // +----------------------------------------------------------+ + + void deltas_destroy(deltas_obj * obj) { + + free((void *) obj->array); + free((void *) obj); + + } + + // +----------------------------------------------------------+ + // | Print | + // +----------------------------------------------------------+ + + void deltas_printf(const deltas_obj * obj) { + + unsigned int iPair; + + for (iPair = 0; iPair < obj->nPairs; iPair++) { + + printf("(%02u): %02u\n",iPair,obj->array[iPair]); + + } + + } \ No newline at end of file diff --git a/src/signal/delta.h b/src/signal/delta.h new file mode 100644 index 0000000..9159e96 --- /dev/null +++ b/src/signal/delta.h @@ -0,0 +1,23 @@ +#ifndef __ODAS_SIGNAL_DELTA +#define __ODAS_SIGNAL_DELTA + + #include + #include + #include + + typedef struct deltas_obj { + + unsigned int nPairs; + unsigned int * array; + + } deltas_obj; + + deltas_obj * deltas_construct_zero(const unsigned int nPairs); + + deltas_obj * deltas_clone(const deltas_obj * obj); + + void deltas_destroy(deltas_obj * obj); + + void deltas_printf(const deltas_obj * obj); + +#endif \ No newline at end of file diff --git a/src/signal/frame.c b/src/signal/frame.c new file mode 100644 index 0000000..f80bdcd --- /dev/null +++ b/src/signal/frame.c @@ -0,0 +1,92 @@ + + #include "frame.h" + + frames_obj * frames_construct_zero(const unsigned int nSignals, const unsigned int frameSize) { + + frames_obj * obj; + unsigned int iSignal; + + obj = (frames_obj *) malloc(sizeof(frames_obj)); + + obj->nSignals = nSignals; + obj->frameSize = frameSize; + + obj->array = (float **) malloc(sizeof(float *) * nSignals); + for (iSignal = 0; iSignal < nSignals; iSignal++) { + obj->array[iSignal] = (float *) malloc(sizeof(float) * frameSize); + memset(obj->array[iSignal], 0x00, frameSize * sizeof(float)); + } + + return obj; + + } + + // +----------------------------------------------------------+ + // | Clone | + // +----------------------------------------------------------+ + + frames_obj * frames_clone(const frames_obj * obj) { + + frames_obj * clone; + unsigned int iSignal; + + clone = (frames_obj *) malloc(sizeof(frames_obj)); + + clone->nSignals = obj->nSignals; + clone->frameSize = obj->frameSize; + + clone->array = (float **) malloc(sizeof(float *) * obj->nSignals); + for (iSignal = 0; iSignal < obj->nSignals; iSignal++) { + clone->array[iSignal] = (float *) malloc(sizeof(float) * obj->frameSize); + memcpy(clone->array[iSignal], obj->array[iSignal], obj->frameSize * sizeof(float)); + } + + return clone; + + } + + // +----------------------------------------------------------+ + // | Destructor | + // +----------------------------------------------------------+ + + void frames_destroy(frames_obj * obj) { + + unsigned int iSignal; + + for (iSignal = 0; iSignal < obj->nSignals; iSignal++) { + free((void *) obj->array[iSignal]); + } + free((void *) obj->array); + + free((void *) obj); + + } + + // +----------------------------------------------------------+ + // | Print | + // +----------------------------------------------------------+ + + void frames_printf(const frames_obj * obj) { + + unsigned int iSignal; + unsigned int iSample; + + for (iSignal = 0; iSignal < obj->nSignals; iSignal++) { + + printf("(%04u): ",iSignal); + + for (iSample = 0; iSample < obj->frameSize; iSample++) { + + printf("%+1.5f ",obj->array[iSignal][iSample]); + + if ((((iSample+1) % 16) == 0) && ((iSample+1)!=obj->frameSize)) { + printf("\n "); + } + + } + + printf("\n"); + + } + + } \ No newline at end of file diff --git a/src/signal/frame.h b/src/signal/frame.h new file mode 100644 index 0000000..53264d0 --- /dev/null +++ b/src/signal/frame.h @@ -0,0 +1,24 @@ +#ifndef __ODAS_SIGNAL_FRAME +#define __ODAS_SIGNAL_FRAME + + #include + #include + #include + + typedef struct frames_obj { + + unsigned int nSignals; + unsigned int frameSize; + float ** array; + + } frames_obj; + + frames_obj * frames_construct_zero(const unsigned int nSignals, const unsigned int frameSize); + + frames_obj * frames_clone(const frames_obj * obj); + + void frames_destroy(frames_obj * obj); + + void frames_printf(const frames_obj * obj); + +#endif \ No newline at end of file diff --git a/src/signal/freq.c b/src/signal/freq.c new file mode 100644 index 0000000..14233b5 --- /dev/null +++ b/src/signal/freq.c @@ -0,0 +1,102 @@ + + #include "freq.h" + + freqs_obj * freqs_construct_zero(const unsigned int nSignals, const unsigned int halfFrameSize) { + + freqs_obj * obj; + unsigned int iSignal; + + obj = (freqs_obj *) malloc(sizeof(freqs_obj)); + + obj->nSignals = nSignals; + obj->halfFrameSize = halfFrameSize; + + obj->array = (float **) malloc(sizeof(float *) * nSignals); + for (iSignal = 0; iSignal < nSignals; iSignal++) { + obj->array[iSignal] = (float *) malloc(sizeof(float) * halfFrameSize * 2); + memset(obj->array[iSignal], 0x00, halfFrameSize * 2 * sizeof(float)); + } + + return obj; + + } + + freqs_obj * freqs_clone(const freqs_obj * obj) { + + freqs_obj * clone; + unsigned int iSignal; + + clone = (freqs_obj *) malloc(sizeof(freqs_obj)); + + clone->nSignals = obj->nSignals; + clone->halfFrameSize = obj->halfFrameSize; + + clone->array = (float **) malloc(sizeof(float *) * obj->nSignals); + for (iSignal = 0; iSignal < obj->nSignals; iSignal++) { + clone->array[iSignal] = (float *) malloc(sizeof(float) * obj->halfFrameSize * 2); + memcpy(clone->array[iSignal], obj->array[iSignal], obj->halfFrameSize * 2 * sizeof(float)); + } + + return clone; + + } + + void freqs_copy(freqs_obj * dest, const freqs_obj * src) { + + unsigned int iSignal; + + for (iSignal = 0; iSignal < src->nSignals; iSignal++) { + memcpy(dest->array[iSignal], src->array[iSignal], src->halfFrameSize * 2 * sizeof(float)); + } + + } + + void freqs_zero(freqs_obj * obj) { + + unsigned int iSignal; + + for (iSignal = 0; iSignal < obj->nSignals; iSignal++) { + memset(obj->array[iSignal], 0x00, obj->halfFrameSize * 2 * sizeof(float)); + } + + } + + void freqs_destroy(freqs_obj * obj) { + + unsigned int iSignal; + + for (iSignal = 0; iSignal < obj->nSignals; iSignal++) { + free((void *) obj->array[iSignal]); + } + free((void *) obj->array); + + free((void *) obj); + + } + + void freqs_printf(const freqs_obj * obj) { + + unsigned int iSignal; + unsigned int iSample; + + for (iSignal = 0; iSignal < obj->nSignals; iSignal++) { + + printf("(%04u): ",iSignal); + + for (iSample = 0; iSample < obj->halfFrameSize; iSample++) { + + printf("(%+1.5f + %+1.5fj) ", + obj->array[iSignal][iSample*2 + 0], + obj->array[iSignal][iSample*2 + 1]); + + if ((((iSample+1) % 8) == 0) && ((iSample+1)!=obj->halfFrameSize)) { + printf("\n "); + } + + } + + printf("\n"); + + } + + } \ No newline at end of file diff --git a/src/signal/freq.h b/src/signal/freq.h new file mode 100644 index 0000000..10588c8 --- /dev/null +++ b/src/signal/freq.h @@ -0,0 +1,28 @@ +#ifndef __ODAS_SIGNAL_FREQ +#define __ODAS_SIGNAL_FREQ + + #include + #include + #include + + typedef struct freqs_obj { + + unsigned int nSignals; + unsigned int halfFrameSize; + float ** array; + + } freqs_obj; + + freqs_obj * freqs_construct_zero(const unsigned int nSignals, const unsigned int halfFrameSize); + + freqs_obj * freqs_clone(const freqs_obj * obj); + + void freqs_copy(freqs_obj * dest, const freqs_obj * src); + + void freqs_zero(freqs_obj * obj); + + void freqs_destroy(freqs_obj * obj); + + void freqs_printf(const freqs_obj * obj); + +#endif \ No newline at end of file diff --git a/src/signal/gain.c b/src/signal/gain.c new file mode 100644 index 0000000..5fbdf78 --- /dev/null +++ b/src/signal/gain.c @@ -0,0 +1,46 @@ + + #include "gain.h" + + gains_obj * gains_construct_zero(const unsigned int nSeps, const unsigned int nChannels) { + + gains_obj * obj; + + obj = (gains_obj *) malloc(sizeof(gains_obj)); + + obj->nSeps = nSeps; + obj->nChannels = nChannels; + + obj->array = (float *) malloc(sizeof(float) * nSeps * nChannels); + memset(obj->array, 0x00, sizeof(float) * nSeps * nChannels); + + return obj; + + } + + void gains_destroy(gains_obj * obj) { + + free((void *) obj->array); + free((void *) obj); + + } + + void gains_printf(const gains_obj * obj) { + + unsigned int iSep; + unsigned int iChannel; + + for (iSep = 0; iSep < obj->nSeps; iSep++) { + + printf("(%02u): ",iSep); + + for (iChannel = 0; iChannel < obj->nChannels; iChannel++) { + + printf("%+1.3f ",obj->array[iChannel]); + + } + + printf("\n"); + + } + + } \ No newline at end of file diff --git a/src/signal/gain.h b/src/signal/gain.h new file mode 100644 index 0000000..c49c521 --- /dev/null +++ b/src/signal/gain.h @@ -0,0 +1,22 @@ +#ifndef __ODAS_SIGNAL_GAIN +#define __ODAS_SIGNAL_GAIN + + #include + #include + #include + + typedef struct gains_obj { + + unsigned int nSeps; + unsigned int nChannels; + float * array; + + } gains_obj; + + gains_obj * gains_construct_zero(const unsigned int nSeps, const unsigned int nChannels); + + void gains_destroy(gains_obj * obj); + + void gains_printf(const gains_obj * obj); + +#endif \ No newline at end of file diff --git a/src/signal/hop.c b/src/signal/hop.c new file mode 100644 index 0000000..be8263c --- /dev/null +++ b/src/signal/hop.c @@ -0,0 +1,100 @@ + + #include "hop.h" + + hops_obj * hops_construct_zero(const unsigned int nSignals, const unsigned int hopSize) { + + hops_obj * obj; + unsigned int iSignal; + + obj = (hops_obj *) malloc(sizeof(hops_obj)); + + obj->nSignals = nSignals; + obj->hopSize = hopSize; + + obj->array = (float **) malloc(sizeof(float *) * nSignals); + for (iSignal = 0; iSignal < nSignals; iSignal++) { + obj->array[iSignal] = (float *) malloc(sizeof(float) * hopSize); + memset(obj->array[iSignal], 0x00, hopSize * sizeof(float)); + } + + return obj; + + } + + hops_obj * hops_clone(const hops_obj * obj) { + + hops_obj * clone; + unsigned int iSignal; + + clone = (hops_obj *) malloc(sizeof(hops_obj)); + + clone->nSignals = obj->nSignals; + clone->hopSize = obj->hopSize; + + clone->array = (float **) malloc(sizeof(float *) * obj->nSignals); + for (iSignal = 0; iSignal < obj->nSignals; iSignal++) { + clone->array[iSignal] = (float *) malloc(sizeof(float) * obj->hopSize); + memcpy(clone->array[iSignal], obj->array[iSignal], obj->hopSize * sizeof(float)); + } + + return clone; + + } + + void hops_copy(hops_obj * dest, const hops_obj * src) { + + unsigned int iSignal; + + for (iSignal = 0; iSignal < src->nSignals; iSignal++) { + memcpy(dest->array[iSignal], src->array[iSignal], src->hopSize * sizeof(float)); + } + + } + + void hops_zero(hops_obj * obj) { + + unsigned int iSignal; + + for (iSignal = 0; iSignal < obj->nSignals; iSignal++) { + memset(obj->array[iSignal], 0x00, obj->hopSize * sizeof(float)); + } + + } + + void hops_destroy(hops_obj * obj) { + + unsigned int iSignal; + + for (iSignal = 0; iSignal < obj->nSignals; iSignal++) { + free((void *) obj->array[iSignal]); + } + free((void *) obj->array); + + free((void *) obj); + + } + + void hops_printf(const hops_obj * obj) { + + unsigned int iSignal; + unsigned int iSample; + + for (iSignal = 0; iSignal < obj->nSignals; iSignal++) { + + printf("(%04u): ",iSignal); + + for (iSample = 0; iSample < obj->hopSize; iSample++) { + + printf("%+1.5f ",obj->array[iSignal][iSample]); + + if ((((iSample+1) % 16) == 0) && ((iSample+1)!=obj->hopSize)) { + printf("\n "); + } + + } + + printf("\n"); + + } + + } \ No newline at end of file diff --git a/src/signal/hop.h b/src/signal/hop.h new file mode 100644 index 0000000..2a8e4e5 --- /dev/null +++ b/src/signal/hop.h @@ -0,0 +1,28 @@ +#ifndef __ODAS_SIGNAL_HOP +#define __ODAS_SIGNAL_HOP + + #include + #include + #include + + typedef struct hops_obj { + + unsigned int nSignals; + unsigned int hopSize; + float ** array; + + } hops_obj; + + hops_obj * hops_construct_zero(const unsigned int nSignals, const unsigned int hopSize); + + hops_obj * hops_clone(const hops_obj * obj); + + void hops_copy(hops_obj * dest, const hops_obj * src); + + void hops_zero(hops_obj * obj); + + void hops_destroy(hops_obj * obj); + + void hops_printf(const hops_obj * obj); + +#endif \ No newline at end of file diff --git a/src/signal/impulse.c b/src/signal/impulse.c new file mode 100644 index 0000000..d8ff0bb --- /dev/null +++ b/src/signal/impulse.c @@ -0,0 +1,23 @@ + + #include "impulse.h" + + impulse_obj * impulse_construct(const unsigned int nCoefficients) { + + impulse_obj * obj; + + obj = (impulse_obj *) malloc(sizeof(impulse_obj)); + + obj->nCoefficients = nCoefficients; + obj->array = (float *) malloc(sizeof(float) * nCoefficients); + memset(obj->array, 0x00, sizeof(float) * nCoefficients); + + return obj; + + } + + void impulse_destroy(impulse_obj * obj) { + + free((void *) obj->array); + free((void *) obj); + + } \ No newline at end of file diff --git a/src/signal/impulse.h b/src/signal/impulse.h new file mode 100644 index 0000000..5133621 --- /dev/null +++ b/src/signal/impulse.h @@ -0,0 +1,18 @@ +#ifndef __ODAS_SIGNAL_IMPULSE +#define __ODAS_SIGNAL_IMPULSE + + #include + #include + + typedef struct impulse_obj { + + float * array; + unsigned int nCoefficients; + + } impulse_obj; + + impulse_obj * impulse_construct(const unsigned int nCoefficients); + + void impulse_destroy(impulse_obj * obj); + +#endif \ No newline at end of file diff --git a/src/signal/index.c b/src/signal/index.c new file mode 100644 index 0000000..1b1f019 --- /dev/null +++ b/src/signal/index.c @@ -0,0 +1,57 @@ + + #include "index.h" + + indexes_obj * indexes_construct_zero(const unsigned int nCoarses, const unsigned int nFines) { + + indexes_obj * obj; + + obj = (indexes_obj *) malloc(sizeof(indexes_obj)); + + obj->nCoarses = nCoarses; + obj->nFines = nFines; + obj->array = (unsigned int *) malloc(sizeof(unsigned int) * nCoarses * nFines); + memset(obj->array, 0x00, sizeof(unsigned int) * nCoarses * nFines); + obj->count = (unsigned int *) malloc(sizeof(unsigned int) * nCoarses); + memset(obj->count, 0x00, sizeof(unsigned int) * nCoarses); + + return obj; + + } + + void indexes_destroy(indexes_obj * obj) { + + free((void *) obj->array); + free((void *) obj->count); + free((void *) obj); + + } + + void indexes_printf(const indexes_obj * obj) { + + unsigned int iCoarse; + unsigned int iFine; + + for (iCoarse = 0; iCoarse < obj->nCoarses; iCoarse++) { + + printf("(%04u): ",iCoarse); + + if (obj->count[iCoarse] > 0) { + + for (iFine = 0; iFine < obj->count[iCoarse]; iFine++) { + + printf("%04u ",obj->array[iCoarse * obj->nFines + iFine]); + + } + + } + else { + + printf("-"); + + } + + printf("\n"); + + } + + } \ No newline at end of file diff --git a/src/signal/index.h b/src/signal/index.h new file mode 100644 index 0000000..891334a --- /dev/null +++ b/src/signal/index.h @@ -0,0 +1,23 @@ +#ifndef __ODAS_SIGNAL_INDEX +#define __ODAS_SIGNAL_INDEX + + #include + #include + #include + + typedef struct indexes_obj { + + unsigned int nCoarses; + unsigned int nFines; + unsigned int * array; + unsigned int * count; + + } indexes_obj; + + indexes_obj * indexes_construct_zero(const unsigned int nCoarses, const unsigned int nFines); + + void indexes_destroy(indexes_obj * obj); + + void indexes_printf(const indexes_obj * obj); + +#endif \ No newline at end of file diff --git a/src/signal/kalman.c b/src/signal/kalman.c new file mode 100644 index 0000000..eb5cce2 --- /dev/null +++ b/src/signal/kalman.c @@ -0,0 +1,28 @@ + + #include "kalman.h" + + kalman_obj * kalman_construct_zero(void) { + + kalman_obj * obj; + + obj = (kalman_obj *) malloc(sizeof(kalman_obj)); + + obj->x_lm1lm1 = matrix_construct_zero(6,1); + obj->x_llm1 = matrix_construct_zero(6,1); + obj->P_lm1lm1 = matrix_construct_zero(6,6); + obj->P_llm1 = matrix_construct_zero(6,6); + + return obj; + + } + + void kalman_destroy(kalman_obj * obj) { + + matrix_destroy(obj->x_lm1lm1); + matrix_destroy(obj->x_llm1); + matrix_destroy(obj->P_lm1lm1); + matrix_destroy(obj->P_llm1); + + free((void *) obj); + + } diff --git a/src/signal/kalman.h b/src/signal/kalman.h new file mode 100644 index 0000000..4e2dade --- /dev/null +++ b/src/signal/kalman.h @@ -0,0 +1,22 @@ +#ifndef __ODAS_SIGNAL_KALMAN +#define __ODAS_SIGNAL_KALMAN + + #include + #include + + #include "../utils/matrix.h" + + typedef struct kalman_obj { + + matrix_obj * x_lm1lm1; + matrix_obj * x_llm1; + matrix_obj * P_lm1lm1; + matrix_obj * P_llm1; + + } kalman_obj; + + kalman_obj * kalman_construct_zero(void); + + void kalman_destroy(kalman_obj * obj); + +#endif \ No newline at end of file diff --git a/src/signal/map.c b/src/signal/map.c new file mode 100644 index 0000000..dcc59c5 --- /dev/null +++ b/src/signal/map.c @@ -0,0 +1,46 @@ + + #include "map.h" + + maps_obj * maps_construct_zero(const unsigned int nCoarses, const unsigned int nFines) { + + maps_obj * obj; + + obj = (maps_obj *) malloc(sizeof(maps_obj)); + + obj->nCoarses = nCoarses; + obj->nFines = nFines; + + obj->array = (char *) malloc(sizeof(char) * nFines * nCoarses); + memset(obj->array, 0x00, sizeof(char) * nFines * nCoarses); + + return obj; + + } + + void maps_destroy(maps_obj * obj) { + + free((void *) obj->array); + free((void *) obj); + + } + + void maps_printf(const maps_obj * obj) { + + unsigned int iFine; + unsigned int iCoarse; + + for (iFine = 0; iFine < obj->nFines; iFine++) { + + printf("(%04u): ",iFine); + + for (iCoarse = 0; iCoarse < obj->nCoarses; iCoarse++) { + + printf("%01u",obj->array[iFine * obj->nCoarses + iCoarse]); + + } + + printf("\n"); + + } + + } \ No newline at end of file diff --git a/src/signal/map.h b/src/signal/map.h new file mode 100644 index 0000000..9db88b3 --- /dev/null +++ b/src/signal/map.h @@ -0,0 +1,22 @@ +#ifndef __ODAS_SIGNAL_MAP +#define __ODAS_SIGNAL_MAP + + #include + #include + #include + + typedef struct maps_obj { + + unsigned int nCoarses; + unsigned int nFines; + char * array; + + } maps_obj; + + maps_obj * maps_construct_zero(const unsigned int nCoarses, const unsigned int nFines); + + void maps_destroy(maps_obj * obj); + + void maps_printf(const maps_obj * obj); + +#endif \ No newline at end of file diff --git a/src/signal/mask.c b/src/signal/mask.c new file mode 100644 index 0000000..ab8e586 --- /dev/null +++ b/src/signal/mask.c @@ -0,0 +1,46 @@ + + #include "mask.h" + + masks_obj * masks_construct_zero(const unsigned int nSeps, const unsigned int nChannels) { + + masks_obj * obj; + + obj = (masks_obj *) malloc(sizeof(masks_obj)); + + obj->nSeps = nSeps; + obj->nChannels = nChannels; + + obj->array = (char *) malloc(sizeof(char) * nSeps * nChannels); + memset(obj->array, 0x00, sizeof(char) * nSeps * nChannels); + + return obj; + + } + + void masks_destroy(masks_obj * obj) { + + free((void *) obj->array); + free((void *) obj); + + } + + void masks_printf(const masks_obj * obj) { + + unsigned int iSep; + unsigned int iChannel; + + for (iSep = 0; iSep < obj->nSeps; iSep++) { + + printf("(%02u): ",iSep); + + for (iChannel = 0; iChannel < obj->nChannels; iChannel++) { + + printf("%d ",obj->array[iChannel]); + + } + + printf("\n"); + + } + + } \ No newline at end of file diff --git a/src/signal/mask.h b/src/signal/mask.h new file mode 100644 index 0000000..6251889 --- /dev/null +++ b/src/signal/mask.h @@ -0,0 +1,22 @@ +#ifndef __ODAS_SIGNAL_MASK +#define __ODAS_SIGNAL_MASK + + #include + #include + #include + + typedef struct masks_obj { + + unsigned int nSeps; + unsigned int nChannels; + char * array; + + } masks_obj; + + masks_obj * masks_construct_zero(const unsigned int nSeps, const unsigned int nChannels); + + void masks_destroy(masks_obj * obj); + + void masks_printf(const masks_obj * obj); + +#endif \ No newline at end of file diff --git a/src/signal/mixture.c b/src/signal/mixture.c new file mode 100644 index 0000000..6cc3f31 --- /dev/null +++ b/src/signal/mixture.c @@ -0,0 +1,128 @@ + + #include "mixture.h" + + mixture_obj * mixture_construct_zero(const unsigned int nPots, const unsigned int nTracks) { + + mixture_obj * obj; + + obj = (mixture_obj *) malloc(sizeof(mixture_obj)); + + obj->assignations = combining_generate(nPots, nTracks); + + obj->nPots = nPots; + obj->nTracks = nTracks; + obj->nTracksNewFalse = nTracks + 2; + obj->nCombinations = obj->assignations->nAssignations; + + obj->p_Ez_AICD = (float *) malloc(sizeof(float) * (3+nTracks) * obj->nPots ); + memset(obj->p_Ez_AICD, 0x00, sizeof(float) * (3+nTracks) * obj->nPots ); + + obj->p_Eszs_phics = (float *) malloc(sizeof(float) * obj->nTracksNewFalse * obj->nPots); + memset(obj->p_Eszs_phics, 0x00, sizeof(float) * obj->nTracksNewFalse * obj->nPots); + + obj->p_phics = (float *) malloc(sizeof(float) * obj->nTracksNewFalse * obj->nPots); + memset(obj->p_phics, 0x00, sizeof(float) * obj->nTracksNewFalse * obj->nPots); + + obj->p_Ez_phic = (float *) malloc(sizeof(float) * obj->nCombinations); + memset(obj->p_Ez_phic, 0x00, sizeof(float) * obj->nCombinations); + + obj->p_phic = (float *) malloc(sizeof(float) * obj->nCombinations); + memset(obj->p_phic, 0x00, sizeof(float) * obj->nCombinations); + + obj->p_phic_Ez = (float *) malloc(sizeof(float) * obj->nCombinations); + memset(obj->p_phic_Ez, 0x00, sizeof(float) * obj->nCombinations); + + return obj; + + } + + void mixture_destroy(mixture_obj * obj) { + + assignations_destroy(obj->assignations); + + free((void *) obj->p_Ez_AICD); + free((void *) obj->p_Eszs_phics); + free((void *) obj->p_phics); + free((void *) obj->p_Ez_phic); + free((void *) obj->p_phic); + free((void *) obj->p_phic_Ez); + + free((void *) obj); + + } + + void mixture_printf(const mixture_obj * obj) { + + unsigned int iTrack; + unsigned int iTrackNewFalse; + unsigned int iPot; + unsigned int iCombination; + + printf("p(E|A) = "); + for (iPot = 0; iPot < obj->nPots; iPot++) { + printf("%+1.3e ",obj->p_Ez_AICD[0 * obj->nPots + iPot]); + } + printf("\n"); + + printf("p(E|I) = "); + for (iPot = 0; iPot < obj->nPots; iPot++) { + printf("%+1.3e ",obj->p_Ez_AICD[1 * obj->nPots + iPot]); + } + printf("\n"); + + printf("p(z|D) = "); + for (iPot = 0; iPot < obj->nPots; iPot++) { + printf("%+1.3e ",obj->p_Ez_AICD[2 * obj->nPots + iPot]); + } + printf("\n"); + + for (iTrack = 0; iTrack < obj->nTracks; iTrack++) { + printf("p(z|C,%u) = ",iTrack); + for (iPot = 0; iPot < obj->nPots; iPot++) { + printf("%+1.3e ", obj->p_Ez_AICD[3 * obj->nPots + iPot]); + } + printf("\n"); + } + printf("\n"); + + printf("p(E,z|phi(s)):\n"); + for (iTrackNewFalse = 0; iTrackNewFalse < obj->nTracksNewFalse; iTrackNewFalse++) { + + printf(" phi = %d: ",iTrackNewFalse-2); + for (iPot = 0; iPot < obj->nPots; iPot++) { + printf("%+1.3e ",obj->p_Eszs_phics[iTrackNewFalse * obj->nPots + iPot]); + } + printf("\n"); + + } + printf("\n"); + + printf("p(phi(s)):\n"); + for (iTrackNewFalse = 0; iTrackNewFalse < obj->nTracksNewFalse; iTrackNewFalse++) { + + printf(" phi = %d: ",iTrackNewFalse-2); + for (iPot = 0; iPot < obj->nPots; iPot++) { + printf("%+1.3e ",obj->p_phics[iTrackNewFalse * obj->nPots + iPot]); + } + printf("\n"); + + } + printf("\n"); + + printf("p(E,z|phi), p(phi), p(phi|E,z):\n"); + + for (iCombination = 0; iCombination < obj->nCombinations; iCombination++) { + + printf(" "); + + for (iPot = 0; iPot < obj->nPots; iPot++) { + + printf("%+01d ",obj->assignations->array[iCombination * obj->nPots + iPot]); + + } + + printf(": %+1.3e %+1.3e %+1.3e\n",obj->p_Ez_phic[iCombination],obj->p_phic[iCombination],obj->p_phic_Ez[iCombination]); + + } + + } \ No newline at end of file diff --git a/src/signal/mixture.h b/src/signal/mixture.h new file mode 100644 index 0000000..d7469cf --- /dev/null +++ b/src/signal/mixture.h @@ -0,0 +1,35 @@ +#ifndef __ODAS_SIGNAL_MIXTURE +#define __ODAS_SIGNAL_MIXTURE + + #include + #include + #include + + #include "../signal/assignation.h" + #include "../init/combining.h" + + typedef struct mixture_obj { + + unsigned int nPots; + unsigned int nTracks; + unsigned int nTracksNewFalse; + unsigned int nCombinations; + + assignations_obj * assignations; + + float * p_Ez_AICD; + float * p_Eszs_phics; + float * p_phics; + float * p_Ez_phic; + float * p_phic; + float * p_phic_Ez; + + } mixture_obj; + + mixture_obj * mixture_construct_zero(const unsigned int nPots, const unsigned int nTracks); + + void mixture_destroy(mixture_obj * obj); + + void mixture_printf(const mixture_obj * obj); + +#endif \ No newline at end of file diff --git a/src/signal/pair.c b/src/signal/pair.c new file mode 100644 index 0000000..12b7621 --- /dev/null +++ b/src/signal/pair.c @@ -0,0 +1,65 @@ + + #include "pair.h" + + // +----------------------------------------------------------+ + // | Constructor | + // +----------------------------------------------------------+ + + pairs_obj * pairs_construct_zero(const unsigned int nPairs) { + + pairs_obj * obj; + + obj = (pairs_obj *) malloc(sizeof(pairs_obj)); + + obj->nPairs = nPairs; + obj->array = (char *) malloc(sizeof(char) * nPairs); + memset(obj->array, 0x00, sizeof(char) * nPairs); + + return obj; + + } + + // +----------------------------------------------------------+ + // | Clone | + // +----------------------------------------------------------+ + + pairs_obj * pairs_clone(const pairs_obj * obj) { + + pairs_obj * clone; + + clone = (pairs_obj *) malloc(sizeof(pairs_obj)); + + clone->nPairs = obj->nPairs; + clone->array = (char *) malloc(sizeof(char) * obj->nPairs); + memcpy(clone->array, obj->array, sizeof(char) * obj->nPairs); + + return clone; + + } + + // +----------------------------------------------------------+ + // | Destroy | + // +----------------------------------------------------------+ + + void pairs_destroy(pairs_obj * obj) { + + free((void *) obj->array); + free((void *) obj); + + } + + // +----------------------------------------------------------+ + // | Print | + // +----------------------------------------------------------+ + + void pairs_printf(const pairs_obj * obj) { + + unsigned int iPair; + + printf("nPairs: %u\n", obj->nPairs); + + for (iPair = 0; iPair < obj->nPairs; iPair++) { + printf("(%02u): %d\n", iPair, obj->array[iPair]); + } + + } \ No newline at end of file diff --git a/src/signal/pair.h b/src/signal/pair.h new file mode 100644 index 0000000..c0eabc5 --- /dev/null +++ b/src/signal/pair.h @@ -0,0 +1,23 @@ +#ifndef __ODAS_SIGNAL_PAIR +#define __ODAS_SIGNAL_PAIR + + #include + #include + #include + + typedef struct pairs_obj { + + unsigned int nPairs; + char * array; + + } pairs_obj; + + pairs_obj * pairs_construct_zero(const unsigned int nPairs); + + pairs_obj * pairs_clone(const pairs_obj * obj); + + void pairs_destroy(pairs_obj * obj); + + void pairs_printf(const pairs_obj * obj); + +#endif \ No newline at end of file diff --git a/src/signal/particle.c b/src/signal/particle.c new file mode 100644 index 0000000..4caa5c4 --- /dev/null +++ b/src/signal/particle.c @@ -0,0 +1,49 @@ + + #include "particle.h" + + particles_obj * particles_construct_zero(const unsigned int nParticles) { + + particles_obj * obj; + + obj = (particles_obj *) malloc(sizeof(particles_obj)); + + obj->nParticles = nParticles; + + obj->array = (float *) malloc(sizeof(float) * 7 * nParticles); + memset(obj->array, 0x00, sizeof(float) * 7 * nParticles); + + obj->state = (unsigned char *) malloc(sizeof(unsigned char) * nParticles); + memset(obj->state, 0x00, sizeof(unsigned char) * nParticles); + + return obj; + + } + + void particles_destroy(particles_obj * obj) { + + free((void *) obj->array); + free((void *) obj->state); + free((void *) obj); + + } + + void particles_printf(const particles_obj * obj) { + + unsigned int iParticle; + + for (iParticle = 0; iParticle < obj->nParticles; iParticle++) { + + printf("(%04u): x = (%+1.3f,%+1.3f,%+1.3f), v = (%+1.3f,%+1.3f,%+1.3f), w = %1.5f, s = %u\n", + iParticle, + obj->array[iParticle * 7 + 0], + obj->array[iParticle * 7 + 1], + obj->array[iParticle * 7 + 2], + obj->array[iParticle * 7 + 3], + obj->array[iParticle * 7 + 4], + obj->array[iParticle * 7 + 5], + obj->array[iParticle * 7 + 6], + obj->state[iParticle]); + + } + + } \ No newline at end of file diff --git a/src/signal/particle.h b/src/signal/particle.h new file mode 100644 index 0000000..3a08ff4 --- /dev/null +++ b/src/signal/particle.h @@ -0,0 +1,22 @@ +#ifndef __ODAS_SIGNAL_PARTICLE +#define __ODAS_SIGNAL_PARTICLE + + #include + #include + #include + + typedef struct particles_obj { + + unsigned int nParticles; + float * array; + unsigned char * state; + + } particles_obj; + + particles_obj * particles_construct_zero(const unsigned int nParticles); + + void particles_destroy(particles_obj * obj); + + void particles_printf(const particles_obj * obj); + +#endif \ No newline at end of file diff --git a/src/signal/point.c b/src/signal/point.c new file mode 100644 index 0000000..ee68ae4 --- /dev/null +++ b/src/signal/point.c @@ -0,0 +1,69 @@ + + #include "point.h" + + // +----------------------------------------------------------+ + // | Constructor | + // +----------------------------------------------------------+ + + points_obj * points_construct_zero(const unsigned int nPoints) { + + points_obj * obj; + + obj = (points_obj *) malloc(sizeof(points_obj)); + + obj->nPoints = nPoints; + obj->array = (float *) malloc(sizeof(float) * nPoints * 3); + memset(obj->array, 0x00, nPoints * 3 * sizeof(float)); + + return obj; + + } + + // +----------------------------------------------------------+ + // | Clone | + // +----------------------------------------------------------+ + + points_obj * points_clone(const points_obj * obj) { + + points_obj * clone; + + clone = (points_obj *) malloc(sizeof(points_obj)); + + clone->nPoints = obj->nPoints; + clone->array = (float *) malloc(sizeof(float) * obj->nPoints * 3); + memcpy(clone->array, obj->array, obj->nPoints * 3 * sizeof(float)); + + return clone; + + } + + // +----------------------------------------------------------+ + // | Destructor | + // +----------------------------------------------------------+ + + void points_destroy(points_obj * obj) { + + free((void *) obj->array); + free((void *) obj); + + } + + // +----------------------------------------------------------+ + // | Print | + // +----------------------------------------------------------+ + + void points_printf(const points_obj * obj) { + + unsigned int iPoint; + + for (iPoint = 0; iPoint < obj->nPoints; iPoint++) { + + printf("(%04u): (%+1.3f,%+1.3f,%+1.3f)\n", + iPoint, + obj->array[iPoint * 3 + 0], + obj->array[iPoint * 3 + 1], + obj->array[iPoint * 3 + 2]); + + } + + } \ No newline at end of file diff --git a/src/signal/point.h b/src/signal/point.h new file mode 100644 index 0000000..c6ea0da --- /dev/null +++ b/src/signal/point.h @@ -0,0 +1,23 @@ +#ifndef __ODAS_SIGNAL_POINT +#define __ODAS_SIGNAL_POINT + + #include + #include + #include + + typedef struct points_obj { + + unsigned int nPoints; + float * array; + + } points_obj; + + points_obj * points_construct_zero(const unsigned int nPoints); + + points_obj * points_clone(const points_obj * obj); + + void points_destroy(points_obj * obj); + + void points_printf(const points_obj * obj); + +#endif \ No newline at end of file diff --git a/src/signal/postprob.c b/src/signal/postprob.c new file mode 100644 index 0000000..2861cfd --- /dev/null +++ b/src/signal/postprob.c @@ -0,0 +1,64 @@ + + #include "postprob.h" + + postprobs_obj * postprobs_construct_zero(const unsigned int nPots, const unsigned int nTracks) { + + postprobs_obj * obj; + + obj = (postprobs_obj *) malloc(sizeof(postprobs_obj)); + + obj->nPots = nPots; + obj->nTracks = nTracks; + + obj->arrayNew = (float *) malloc(sizeof(float) * nPots); + memset(obj->arrayNew, 0x00, sizeof(float) * nPots); + + obj->arrayTrack = (float *) malloc(sizeof(float) * nTracks * nPots); + memset(obj->arrayTrack, 0x00, sizeof(float) * nTracks * nPots); + + obj->arrayTrackTotal = (float *) malloc(sizeof(float) * nTracks); + memset(obj->arrayTrackTotal, 0x00, sizeof(float) * nTracks); + + return obj; + + } + + void postprobs_destroy(postprobs_obj * obj) { + + free((void *) obj->arrayNew); + free((void *) obj->arrayTrack); + free((void *) obj->arrayTrackTotal); + free((void *) obj); + + } + + void postprobs_printf(const postprobs_obj * obj) { + + unsigned int iTrack; + unsigned int iPot; + + printf("p(new|E,z): "); + + for (iPot = 0; iPot < obj->nPots; iPot++) { + + printf("%+1.3e ",obj->arrayNew[iPot]); + + } + + printf("\n"); + + for (iTrack = 0; iTrack < obj->nTracks; iTrack++) { + + printf(" p(%u|E,z): ",iTrack); + + for (iPot = 0; iPot < obj->nPots; iPot++) { + + printf("%+1.3e ",obj->arrayTrack[iTrack * obj->nPots + iPot]); + + } + + printf("> %+1.3f\n",obj->arrayTrackTotal[iTrack]); + + } + + } \ No newline at end of file diff --git a/src/signal/postprob.h b/src/signal/postprob.h new file mode 100644 index 0000000..e70f7e0 --- /dev/null +++ b/src/signal/postprob.h @@ -0,0 +1,25 @@ +#ifndef __ODAS_SIGNAL_POSTPROB +#define __ODAS_SIGNAL_POSTPROB + + #include + #include + #include + + typedef struct postprobs_obj { + + unsigned int nTracks; + unsigned int nPots; + + float * arrayNew; + float * arrayTrack; + float * arrayTrackTotal; + + } postprobs_obj; + + postprobs_obj * postprobs_construct_zero(const unsigned int nPots, const unsigned int nTracks); + + void postprobs_destroy(postprobs_obj * obj); + + void postprobs_printf(const postprobs_obj * obj); + +#endif \ No newline at end of file diff --git a/src/signal/pot.c b/src/signal/pot.c new file mode 100644 index 0000000..0fd7523 --- /dev/null +++ b/src/signal/pot.c @@ -0,0 +1,69 @@ + + #include "pot.h" + + pots_obj * pots_construct_zero(const unsigned int nPots) { + + pots_obj * obj; + + obj = (pots_obj *) malloc(sizeof(pots_obj)); + + obj->nPots = nPots; + obj->array = (float *) malloc(sizeof(float) * 4 * nPots); + memset(obj->array, 0x00, sizeof(float) * 4 * nPots); + + return obj; + + } + + pots_obj * pots_clone(const pots_obj * obj) { + + pots_obj * clone; + + clone = (pots_obj *) malloc(sizeof(pots_obj)); + + clone->nPots = obj->nPots; + clone->array = (float *) malloc(sizeof(float) * 4 * obj->nPots); + memcpy(clone->array, obj->array, sizeof(float) * 4 * obj->nPots); + + return clone; + + } + + void pots_copy(pots_obj * dest, const pots_obj * src) { + + dest->nPots = src->nPots; + + memcpy(dest->array, src->array, sizeof(float) * 4 * src->nPots); + + } + + void pots_zero(pots_obj * obj) { + + obj->nPots = 0; + memset(obj->array, 0x00, sizeof(float) * 4 * obj->nPots); + + } + + void pots_destroy(pots_obj * obj) { + + free((void *) obj->array); + free((void *) obj); + + } + + void pots_printf(const pots_obj * obj) { + + unsigned int iPot; + + for (iPot = 0; iPot < obj->nPots; iPot++) { + + printf("(%02u): %+1.3f %+1.3f %+1.3f %+1.3f\n", + iPot, + obj->array[iPot * 4 + 0], + obj->array[iPot * 4 + 1], + obj->array[iPot * 4 + 2], + obj->array[iPot * 4 + 3]); + + } + + } diff --git a/src/signal/pot.h b/src/signal/pot.h new file mode 100644 index 0000000..1fff189 --- /dev/null +++ b/src/signal/pot.h @@ -0,0 +1,27 @@ +#ifndef __ODAS_SIGNAL_POT +#define __ODAS_SIGNAL_POT + + #include + #include + #include + + typedef struct pots_obj { + + unsigned int nPots; + float * array; + + } pots_obj; + + pots_obj * pots_construct_zero(const unsigned int nPots); + + pots_obj * pots_clone(const pots_obj * obj); + + void pots_copy(pots_obj * dest, const pots_obj * src); + + void pots_zero(pots_obj * obj); + + void pots_destroy(pots_obj * obj); + + void pots_printf(const pots_obj * obj); + +#endif \ No newline at end of file diff --git a/src/signal/scan.c b/src/signal/scan.c new file mode 100644 index 0000000..91c59d8 --- /dev/null +++ b/src/signal/scan.c @@ -0,0 +1,81 @@ + + #include "scan.h" + + // +----------------------------------------------------------+ + // | Constructor | + // +----------------------------------------------------------+ + + scans_obj * scans_construct_null(const unsigned int nLevels) { + + scans_obj * obj; + + obj = (scans_obj *) malloc(sizeof(scans_obj)); + + obj->nLevels = nLevels; + + obj->points = (points_obj **) malloc(sizeof(points_obj *) * nLevels); + memset(obj->points, 0x00, sizeof(points_obj *) * nLevels); + + obj->tdoas = (tdoas_obj **) malloc(sizeof(tdoas_obj *) * nLevels); + memset(obj->tdoas, 0x00, sizeof(tdoas_obj *) * nLevels); + + obj->deltas = (deltas_obj **) malloc(sizeof(deltas_obj *) * nLevels); + memset(obj->deltas, 0x00, sizeof(deltas_obj *) * nLevels); + + obj->spatialindexes = (spatialindexes_obj **) malloc(sizeof(spatialindexes_obj *) * nLevels); + memset(obj->spatialindexes, 0x00, sizeof(spatialindexes_obj *) * nLevels); + + obj->pairs = (pairs_obj *) NULL; + + obj->indexes = (indexes_obj **) malloc(sizeof(indexes_obj *) * nLevels); + memset(obj->indexes, 0x00, sizeof(indexes_obj *) * nLevels); + + return obj; + + } + + // +----------------------------------------------------------+ + // | Destructor | + // +----------------------------------------------------------+ + + void scans_destroy(scans_obj * obj) { + + unsigned int iLevel; + + for (iLevel = 0; iLevel < obj->nLevels; iLevel++) { + + if (obj->points[iLevel] != NULL) { + points_destroy(obj->points[iLevel]); + } + + if (obj->tdoas[iLevel] != NULL) { + tdoas_destroy(obj->tdoas[iLevel]); + } + + if (obj->deltas[iLevel] != NULL) { + deltas_destroy(obj->deltas[iLevel]); + } + + if (obj->spatialindexes[iLevel] != NULL) { + spatialindexes_destroy(obj->spatialindexes[iLevel]); + } + + if (obj->indexes[iLevel] != NULL) { + indexes_destroy(obj->indexes[iLevel]); + } + + } + + if (obj->pairs != NULL) { + pairs_destroy(obj->pairs); + } + + free((void *) obj->points); + free((void *) obj->tdoas); + free((void *) obj->deltas); + free((void *) obj->spatialindexes); + free((void *) obj->indexes); + + free((void *) obj); + + } diff --git a/src/signal/scan.h b/src/signal/scan.h new file mode 100644 index 0000000..5199f0b --- /dev/null +++ b/src/signal/scan.h @@ -0,0 +1,33 @@ +#ifndef __ODAS_SIGNAL_SCAN +#define __ODAS_SIGNAL_SCAN + + #include + #include + + #include "pair.h" + #include "point.h" + #include "tdoa.h" + #include "delta.h" + #include "index.h" + #include "spatialindex.h" + + //! Scan setup + typedef struct scans_obj { + + unsigned int nLevels; + + points_obj ** points; + tdoas_obj ** tdoas; + deltas_obj ** deltas; + spatialindexes_obj ** spatialindexes; + pairs_obj * pairs; + + indexes_obj ** indexes; + + } scans_obj; + + scans_obj * scans_construct_null(const unsigned int nLevels); + + void scans_destroy(scans_obj * obj); + +#endif \ No newline at end of file diff --git a/src/signal/shift.c b/src/signal/shift.c new file mode 100644 index 0000000..1e61c34 --- /dev/null +++ b/src/signal/shift.c @@ -0,0 +1,47 @@ + + #include "shift.h" + + shifts_obj * shifts_construct_zero(const unsigned int nSeps, const unsigned int nChannels) { + + shifts_obj * obj; + unsigned int iChannel; + + obj = (shifts_obj *) malloc(sizeof(shifts_obj)); + + obj->nSeps = nSeps; + obj->nChannels = nChannels; + + obj->array = (float *) malloc(sizeof(float) * nSeps * nChannels); + memset(obj->array, 0x00, sizeof(float) * nSeps * nChannels); + + return obj; + + } + + void shifts_destroy(shifts_obj * obj) { + + free((void *) obj->array); + free((void *) obj); + + } + + void shifts_printf(const shifts_obj * obj) { + + unsigned int iSep; + unsigned int iChannel; + + for (iSep = 0; iSep < obj->nSeps; iSep++) { + + printf("(%02u): ",iSep); + + for (iChannel = 0; iChannel < obj->nChannels; iChannel++) { + + printf("%+1.3f ",obj->array[iChannel]); + + } + + printf("\n"); + + } + + } \ No newline at end of file diff --git a/src/signal/shift.h b/src/signal/shift.h new file mode 100644 index 0000000..3613121 --- /dev/null +++ b/src/signal/shift.h @@ -0,0 +1,22 @@ +#ifndef __ODAS_SIGNAL_SHIFT +#define __ODAS_SIGNAL_SHIFT + + #include + #include + #include + + typedef struct shifts_obj { + + unsigned int nSeps; + unsigned int nChannels; + float * array; + + } shifts_obj; + + shifts_obj * shifts_construct_zero(const unsigned int nSeps, const unsigned int nChannels); + + void shifts_destroy(shifts_obj * obj); + + void shifts_printf(const shifts_obj * obj); + +#endif \ No newline at end of file diff --git a/src/signal/spatialgain.c b/src/signal/spatialgain.c new file mode 100644 index 0000000..bad6eb2 --- /dev/null +++ b/src/signal/spatialgain.c @@ -0,0 +1,78 @@ + + #include "spatialgain.h" + + // +----------------------------------------------------------+ + // | Constructor | + // +----------------------------------------------------------+ + + spatialgains_obj * spatialgains_construct_zero(const unsigned int nChannels, const unsigned int nPoints) { + + spatialgains_obj * obj; + + obj = (spatialgains_obj *) malloc(sizeof(spatialgains_obj)); + + obj->nChannels = nChannels; + obj->nPoints = nPoints; + + obj->array = (float *) malloc(sizeof(float) * nChannels * nPoints); + memset(obj->array, 0x00, sizeof(float) * nChannels * nPoints); + + return obj; + + } + + // +----------------------------------------------------------+ + // | Clone | + // +----------------------------------------------------------+ + + spatialgains_obj * spatialgains_clone(const spatialgains_obj * obj) { + + spatialgains_obj * clone; + + clone = (spatialgains_obj *) malloc(sizeof(spatialgains_obj)); + + clone->nChannels = obj->nChannels; + clone->nPoints = obj->nPoints; + + clone->array = (float *) malloc(sizeof(float) * obj->nChannels * obj->nPoints); + memcpy(clone->array, obj->array, sizeof(float) * obj->nChannels * obj->nPoints); + + return clone; + + } + + // +----------------------------------------------------------+ + // | Destructor | + // +----------------------------------------------------------+ + + void spatialgains_destroy(spatialgains_obj * obj) { + + free((void *) obj->array); + free((void *) obj); + + } + + // +----------------------------------------------------------+ + // | Print | + // +----------------------------------------------------------+ + + void spatialgains_printf(const spatialgains_obj * obj) { + + unsigned int iPoint; + unsigned int iChannel; + + for (iPoint = 0; iPoint < obj->nPoints; iPoint++) { + + printf("(%04u): ",iPoint); + + for (iChannel = 0; iChannel < obj->nChannels; iChannel++) { + + printf("%1.2f ",obj->array[iPoint * obj->nChannels + iChannel]); + + } + + printf("\n"); + + } + + } \ No newline at end of file diff --git a/src/signal/spatialgain.h b/src/signal/spatialgain.h new file mode 100644 index 0000000..9ec8dbf --- /dev/null +++ b/src/signal/spatialgain.h @@ -0,0 +1,25 @@ +#ifndef __ODAS_SIGNAL_SPATIALGAIN +#define __ODAS_SIGNAL_SPATIALGAIN + + #include + #include + #include + + typedef struct spatialgains_obj { + + unsigned int nChannels; + unsigned int nPoints; + + float * array; + + } spatialgains_obj; + + spatialgains_obj * spatialgains_construct_zero(const unsigned int nChannels, const unsigned int nPoints); + + spatialgains_obj * spatialgains_clone(const spatialgains_obj * obj); + + void spatialgains_destroy(spatialgains_obj * obj); + + void spatialgains_printf(const spatialgains_obj * obj); + +#endif \ No newline at end of file diff --git a/src/signal/spatialindex.c b/src/signal/spatialindex.c new file mode 100644 index 0000000..f2facf6 --- /dev/null +++ b/src/signal/spatialindex.c @@ -0,0 +1,95 @@ + + #include "spatialindex.h" + + // +----------------------------------------------------------+ + // | Constructor | + // +----------------------------------------------------------+ + + spatialindexes_obj * spatialindexes_construct_zero(const unsigned int nPoints, const unsigned int nPairs) { + + spatialindexes_obj * obj; + + obj = (spatialindexes_obj *) malloc(sizeof(spatialindexes_obj)); + + obj->nPoints = nPoints; + obj->nPairs = nPairs; + + obj->array = (unsigned int *) malloc(sizeof(unsigned int) * nPoints * nPairs); + memset(obj->array, 0x00, sizeof(unsigned int) * nPoints * nPairs); + + obj->count = (unsigned int *) malloc(sizeof(unsigned int) * nPoints); + memset(obj->count, 0x00, sizeof(unsigned int) * nPoints); + + return obj; + + } + + // +----------------------------------------------------------+ + // | Clone | + // +----------------------------------------------------------+ + + spatialindexes_obj * spatialindexes_clone(const spatialindexes_obj * obj) { + + spatialindexes_obj * clone; + + clone = (spatialindexes_obj *) malloc(sizeof(spatialindexes_obj)); + + clone->nPoints = obj->nPoints; + clone->nPairs = obj->nPairs; + + clone->array = (unsigned int *) malloc(sizeof(unsigned int) * obj->nPoints * obj->nPairs); + memcpy(clone->array, obj->array, sizeof(unsigned int) * obj->nPoints * obj->nPairs); + + clone->count = (unsigned int *) malloc(sizeof(unsigned int) * obj->nPoints); + memcpy(clone->count, obj->count, sizeof(unsigned int) * obj->nPoints); + + return clone; + + } + + // +----------------------------------------------------------+ + // | Destructor | + // +----------------------------------------------------------+ + + void spatialindexes_destroy(spatialindexes_obj * obj) { + + free((void *) obj->array); + free((void *) obj->count); + + free((void *) obj); + + } + + // +----------------------------------------------------------+ + // | Print | + // +----------------------------------------------------------+ + + void spatialindexes_printf(const spatialindexes_obj * obj) { + + unsigned int iPoint; + unsigned int iPair; + + for (iPoint = 0; iPoint < obj->nPoints; iPoint++) { + + printf("(%04u): ",iPoint); + + if (obj->count[iPoint] > 0) { + + for (iPair = 0; iPair < obj->count[iPoint]; iPair++) { + + printf("%03u ",obj->array[iPoint * obj->nPairs + iPair]); + + } + + } + else { + + printf("-"); + + } + + printf("\n"); + + } + + } \ No newline at end of file diff --git a/src/signal/spatialindex.h b/src/signal/spatialindex.h new file mode 100644 index 0000000..1ef38d9 --- /dev/null +++ b/src/signal/spatialindex.h @@ -0,0 +1,26 @@ +#ifndef __ODAS_SIGNAL_SPATIALINDEX +#define __ODAS_SIGNAL_SPATIALINDEX + + #include + #include + #include + + typedef struct spatialindexes_obj { + + unsigned int nPoints; + unsigned int nPairs; + + unsigned int * array; + unsigned int * count; + + } spatialindexes_obj; + + spatialindexes_obj * spatialindexes_construct_zero(const unsigned int nPoints, const unsigned int nPairs); + + spatialindexes_obj * spatialindexes_clone(const spatialindexes_obj * obj); + + void spatialindexes_destroy(spatialindexes_obj * obj); + + void spatialindexes_printf(const spatialindexes_obj * obj); + +#endif \ No newline at end of file diff --git a/src/signal/spatialmask.c b/src/signal/spatialmask.c new file mode 100644 index 0000000..db0c185 --- /dev/null +++ b/src/signal/spatialmask.c @@ -0,0 +1,87 @@ + + #include "spatialmask.h" + + // +----------------------------------------------------------+ + // | Constructor | + // +----------------------------------------------------------+ + + spatialmasks_obj * spatialmasks_construct_zero(const unsigned int nPoints, const unsigned int nPairs) { + + spatialmasks_obj * obj; + + obj = (spatialmasks_obj *) malloc(sizeof(spatialmasks_obj)); + + obj->nPoints = nPoints; + obj->nPairs = nPairs; + + obj->array = (char *) malloc(sizeof(char) * nPoints * nPairs); + memset(obj->array, 0x00, sizeof(char) * nPoints * nPairs); + + return obj; + + } + + // +----------------------------------------------------------+ + // | Clone | + // +----------------------------------------------------------+ + + spatialmasks_obj * spatialmasks_clone(const spatialmasks_obj * obj) { + + spatialmasks_obj * clone; + + clone = (spatialmasks_obj *) malloc(sizeof(spatialmasks_obj)); + + clone->nPoints = obj->nPoints; + clone->nPairs = obj->nPairs; + + clone->array = (char *) malloc(sizeof(char) * obj->nPoints * obj->nPairs); + memcpy(clone->array, obj->array, sizeof(char) * obj->nPoints * obj->nPairs); + + return clone; + + } + + // +----------------------------------------------------------+ + // | Destructor | + // +----------------------------------------------------------+ + + void spatialmasks_destroy(spatialmasks_obj * obj) { + + free((void *) obj->array); + free((void *) obj); + + } + + // +----------------------------------------------------------+ + // | Print | + // +----------------------------------------------------------+ + + void spatialmasks_printf(const spatialmasks_obj * obj) { + + unsigned int iPoint; + unsigned int iPair; + + for (iPoint = 0; iPoint < obj->nPoints; iPoint++) { + + printf("(%04u): ",iPoint); + + for (iPair = 0; iPair < obj->nPairs; iPair++) { + + if (obj->array[iPoint * obj->nPairs + iPair] != 0x00) { + + printf("1"); + + } + else { + + printf("0"); + + } + + } + + printf("\n"); + + } + + } \ No newline at end of file diff --git a/src/signal/spatialmask.h b/src/signal/spatialmask.h new file mode 100644 index 0000000..025e447 --- /dev/null +++ b/src/signal/spatialmask.h @@ -0,0 +1,25 @@ +#ifndef __ODAS_SIGNAL_SPATIALMASK +#define __ODAS_SIGNAL_SPATIALMASK + + #include + #include + #include + + typedef struct spatialmasks_obj { + + unsigned int nPoints; + unsigned int nPairs; + + char * array; + + } spatialmasks_obj; + + spatialmasks_obj * spatialmasks_construct_zero(const unsigned int nPoints, const unsigned int nPairs); + + spatialmasks_obj * spatialmasks_clone(const spatialmasks_obj * obj); + + void spatialmasks_destroy(spatialmasks_obj * obj); + + void spatialmasks_printf(const spatialmasks_obj * obj); + +#endif \ No newline at end of file diff --git a/src/signal/tau.c b/src/signal/tau.c new file mode 100644 index 0000000..15b112f --- /dev/null +++ b/src/signal/tau.c @@ -0,0 +1,51 @@ + + #include "tau.h" + + taus_obj * taus_construct_zero(const unsigned int nPoints, const unsigned int nPairs) { + + taus_obj * obj; + + obj = (taus_obj *) malloc(sizeof(taus_obj)); + + obj->nPoints = nPoints; + obj->nPairs = nPairs; + + obj->mu = (float *) malloc(sizeof(float) * nPoints * nPairs); + memset(obj->mu, 0x00, sizeof(float) * nPoints * nPairs); + + obj->sigma2 = (float *) malloc(sizeof(float) * nPoints * nPairs); + memset(obj->sigma2, 0x00, sizeof(float) * nPoints * nPairs); + + return obj; + + } + + void taus_destroy(taus_obj * obj) { + + free((void *) obj->mu); + free((void *) obj->sigma2); + + free((void *) obj); + + } + + void taus_printf(const taus_obj * obj) { + + unsigned int iPoint; + unsigned int iPair; + + for (iPoint = 0; iPoint < obj->nPoints; iPoint++) { + + printf("(%04u): ",iPoint); + + for (iPair = 0; iPair < obj->nPairs; iPair++) { + + printf("%03.3f (%03.3f) ",obj->mu[iPoint * obj->nPairs + iPair],obj->sigma2[iPoint * obj->nPairs + iPair]); + + } + + printf("\n"); + + } + + } \ No newline at end of file diff --git a/src/signal/tau.h b/src/signal/tau.h new file mode 100644 index 0000000..2b9118e --- /dev/null +++ b/src/signal/tau.h @@ -0,0 +1,23 @@ +#ifndef __ODAS_SIGNAL_TAU +#define __ODAS_SIGNAL_TAU + + #include + #include + #include + + typedef struct taus_obj { + + unsigned int nPoints; + unsigned int nPairs; + float * mu; + float * sigma2; + + } taus_obj; + + taus_obj * taus_construct_zero(const unsigned int nPoints, const unsigned int nPairs); + + void taus_destroy(taus_obj * obj); + + void taus_printf(const taus_obj * obj); + +#endif \ No newline at end of file diff --git a/src/signal/tdoa.c b/src/signal/tdoa.c new file mode 100644 index 0000000..2b12ebf --- /dev/null +++ b/src/signal/tdoa.c @@ -0,0 +1,74 @@ + + #include "tdoa.h" + + tdoas_obj * tdoas_construct_zero(const unsigned int nPoints, const unsigned int nPairs) { + + tdoas_obj * obj; + + obj = (tdoas_obj *) malloc(sizeof(tdoas_obj)); + + obj->nPoints = nPoints; + obj->nPairs = nPairs; + + obj->array = (unsigned int *) malloc(sizeof(unsigned int) * nPoints * nPairs); + memset(obj->array, 0x00, sizeof(unsigned int) * nPoints * nPairs); + + obj->min = (unsigned int *) malloc(sizeof(unsigned int) * nPairs); + memset(obj->min, 0x00, sizeof(unsigned int) * nPairs); + + obj->max = (unsigned int *) malloc(sizeof(unsigned int) * nPairs); + memset(obj->max, 0x00, sizeof(unsigned int) * nPairs); + + return obj; + + } + + void tdoas_destroy(tdoas_obj * obj) { + + free((void *) obj->array); + free((void *) obj->min); + free((void *) obj->max); + free((void *) obj); + + } + + void tdoas_printf(const tdoas_obj * obj) { + + unsigned int iPoint; + unsigned int iPair; + + for (iPoint = 0; iPoint < obj->nPoints; iPoint++) { + + printf("(%04u): ",iPoint); + + for (iPair = 0; iPair < obj->nPairs; iPair++) { + + printf("%04u ",obj->array[iPoint * obj->nPairs + iPair]); + + } + + printf("\n"); + + } + + printf("(min): "); + + for (iPair = 0; iPair < obj->nPairs; iPair++) { + + printf("%04u ",obj->min[iPair]); + + } + + printf("\n"); + + printf("(max): "); + + for (iPair = 0; iPair < obj->nPairs; iPair++) { + + printf("%04u ",obj->max[iPair]); + + } + + printf("\n"); + + } diff --git a/src/signal/tdoa.h b/src/signal/tdoa.h new file mode 100644 index 0000000..fe90a2b --- /dev/null +++ b/src/signal/tdoa.h @@ -0,0 +1,24 @@ +#ifndef __ODAS_SIGNAL_TDOA +#define __ODAS_SIGNAL_TDOA + + #include + #include + #include + + typedef struct tdoas_obj { + + unsigned int nPoints; + unsigned int nPairs; + unsigned int * array; + unsigned int * min; + unsigned int * max; + + } tdoas_obj; + + tdoas_obj * tdoas_construct_zero(const unsigned int nPoints, const unsigned int nPairs); + + void tdoas_destroy(tdoas_obj * obj); + + void tdoas_printf(const tdoas_obj * obj); + +#endif \ No newline at end of file diff --git a/src/signal/track.c b/src/signal/track.c new file mode 100644 index 0000000..7ea3366 --- /dev/null +++ b/src/signal/track.c @@ -0,0 +1,75 @@ + + #include "track.h" + + tracks_obj * tracks_construct_zero(const unsigned int nTracks) { + + tracks_obj * obj; + + obj = (tracks_obj *) malloc(sizeof(tracks_obj)); + + obj->nTracks = nTracks; + obj->array = (float *) malloc(sizeof(float) * 3 * nTracks); + memset(obj->array, 0x00, sizeof(float) * 3 * nTracks); + obj->ids = (unsigned long long *) malloc(sizeof(unsigned long long) * nTracks); + memset(obj->ids, 0x00, sizeof(unsigned long long) * nTracks); + + return obj; + + } + + void tracks_destroy(tracks_obj * obj) { + + free((void *) obj->array); + free((void *) obj->ids); + free((void *) obj); + + } + + tracks_obj * tracks_clone(const tracks_obj * obj) { + + tracks_obj * clone; + + clone = (tracks_obj *) malloc(sizeof(tracks_obj)); + + clone->nTracks = obj->nTracks; + clone->array = (float *) malloc(sizeof(float) * 3 * obj->nTracks); + memcpy(clone->array, obj->array, sizeof(float) * 3 * obj->nTracks); + clone->ids = (unsigned long long *) malloc(sizeof(unsigned long long) * obj->nTracks); + memcpy(clone->ids, obj->ids, sizeof(unsigned long long) * obj->nTracks); + + return clone; + + } + + void tracks_copy(tracks_obj * dest, const tracks_obj * src) { + + dest->nTracks = src->nTracks; + memcpy(dest->array, src->array, sizeof(float) * 3 * src->nTracks); + memcpy(dest->ids, src->ids, sizeof(unsigned long long) * src->nTracks); + + } + + void tracks_zero(tracks_obj * obj) { + + obj->nTracks = 0; + memset(obj->array, 0x00, sizeof(float) * 3 * obj->nTracks); + memset(obj->ids, 0x00, sizeof(unsigned long long) * obj->nTracks); + + } + + void tracks_printf(const tracks_obj * obj) { + + unsigned int iTrack; + + for (iTrack = 0; iTrack < obj->nTracks; iTrack++) { + + printf("(%04llu): %+1.3f %+1.3f %+1.3f\n", + obj->ids[iTrack], + obj->array[iTrack * 3 + 0], + obj->array[iTrack * 3 + 1], + obj->array[iTrack * 3 + 2]); + + } + + + } \ No newline at end of file diff --git a/src/signal/track.h b/src/signal/track.h new file mode 100644 index 0000000..2de20b9 --- /dev/null +++ b/src/signal/track.h @@ -0,0 +1,28 @@ +#ifndef __ODAS_SIGNAL_TRACK +#define __ODAS_SIGNAL_TRACK + + #include + #include + #include + + typedef struct tracks_obj { + + unsigned int nTracks; + unsigned long long * ids; + float * array; + + } tracks_obj; + + tracks_obj * tracks_construct_zero(const unsigned int nTracks); + + void tracks_destroy(tracks_obj * obj); + + tracks_obj * tracks_clone(const tracks_obj * obj); + + void tracks_copy(tracks_obj * dest, const tracks_obj * src); + + void tracks_zero(tracks_obj * obj); + + void tracks_printf(const tracks_obj * obj); + +#endif \ No newline at end of file diff --git a/src/signal/triangle.c b/src/signal/triangle.c new file mode 100644 index 0000000..78d693c --- /dev/null +++ b/src/signal/triangle.c @@ -0,0 +1,45 @@ + + #include "triangle.h" + + triangles_obj * triangles_construct_zero(const unsigned int nTriangles) { + + triangles_obj * obj; + + obj = (triangles_obj *) malloc(sizeof(triangles_obj)); + + obj->nTriangles = nTriangles; + obj->array = (float *) malloc(sizeof(float) * nTriangles * 9); + memset(obj->array, nTriangles * 9, sizeof(float)); + + return obj; + + } + + void triangles_destroy(triangles_obj * obj) { + + free((void *) obj->array); + free((void *) obj); + + } + + void triangles_printf(const triangles_obj * obj) { + + unsigned int iTriangle; + + for (iTriangle = 0; iTriangle < obj->nTriangles; iTriangle++) { + + printf("(%04u): (%+1.3f,%+1.3f,%+1.3f) - (%+1.3f,%+1.3f,%+1.3f) - (%+1.3f,%+1.3f,%+1.3f)\n", + iTriangle, + obj->array[iTriangle * 9 + 0], + obj->array[iTriangle * 9 + 1], + obj->array[iTriangle * 9 + 2], + obj->array[iTriangle * 9 + 3], + obj->array[iTriangle * 9 + 4], + obj->array[iTriangle * 9 + 5], + obj->array[iTriangle * 9 + 6], + obj->array[iTriangle * 9 + 7], + obj->array[iTriangle * 9 + 8]); + + } + + } \ No newline at end of file diff --git a/src/signal/triangle.h b/src/signal/triangle.h new file mode 100644 index 0000000..a20b964 --- /dev/null +++ b/src/signal/triangle.h @@ -0,0 +1,21 @@ +#ifndef __ODAS_SIGNAL_TRIANGLE +#define __ODAS_SIGNAL_TRIANGLE + + #include + #include + #include + + typedef struct triangles_obj { + + unsigned nTriangles; + float * array; + + } triangles_obj; + + triangles_obj * triangles_construct_zero(const unsigned int nTriangles); + + void triangles_destroy(triangles_obj * obj); + + void triangles_printf(const triangles_obj * obj); + +#endif \ No newline at end of file diff --git a/src/signal/window.c b/src/signal/window.c new file mode 100644 index 0000000..8d9022b --- /dev/null +++ b/src/signal/window.c @@ -0,0 +1,23 @@ + + #include "window.h" + + window_obj * window_construct_zero(const unsigned int frameSize) { + + window_obj * obj; + + obj = (window_obj *) malloc(sizeof(window_obj)); + + obj->frameSize = frameSize; + obj->array = (float *) malloc(sizeof(float) * frameSize); + memset(obj->array, frameSize, sizeof(float)); + + return obj; + + } + + void window_destroy(window_obj * obj) { + + free((void *) obj->array); + free((void *) obj); + + } \ No newline at end of file diff --git a/src/signal/window.h b/src/signal/window.h new file mode 100644 index 0000000..556a611 --- /dev/null +++ b/src/signal/window.h @@ -0,0 +1,18 @@ +#ifndef __ODAS_SIGNAL_WINDOW +#define __ODAS_SIGNAL_WINDOW + + #include + #include + + typedef struct window_obj { + + unsigned int frameSize; + float * array; + + } window_obj; + + window_obj * window_construct_zero(const unsigned int frameSize); + + void window_destroy(window_obj * obj); + +#endif \ No newline at end of file diff --git a/src/signal/xcorr.c b/src/signal/xcorr.c new file mode 100644 index 0000000..5221e97 --- /dev/null +++ b/src/signal/xcorr.c @@ -0,0 +1,80 @@ + + #include "xcorr.h" + + xcorrs_obj * xcorrs_construct_zero(const unsigned int nSignals, const unsigned int frameSize) { + + xcorrs_obj * obj; + unsigned int iSignal; + + obj = (xcorrs_obj *) malloc(sizeof(xcorrs_obj)); + + obj->nSignals = nSignals; + obj->frameSize = frameSize; + + obj->array = (float **) malloc(sizeof(float *) * nSignals); + for (iSignal = 0; iSignal < nSignals; iSignal++) { + obj->array[iSignal] = (float *) malloc(sizeof(float) * frameSize); + memset(obj->array[iSignal], 0x00, frameSize * sizeof(float)); + } + + return obj; + + } + + void xcorrs_destroy(xcorrs_obj * obj) { + + unsigned int iSignal; + + for (iSignal = 0; iSignal < obj->nSignals; iSignal++) { + free((void *) obj->array[iSignal]); + } + free((void *) obj->array); + + free((void *) obj); + + } + + void xcorrs_printf(const xcorrs_obj * obj) { + + unsigned int iSignal; + unsigned int iSample; + + for (iSignal = 0; iSignal < obj->nSignals; iSignal++) { + + printf("(%04u): ",iSignal); + + for (iSample = 0; iSample < obj->frameSize; iSample++) { + + printf("%+1.5f ",obj->array[iSignal][iSample]); + + if ((((iSample+1) % 16) == 0) && ((iSample+1)!=obj->frameSize)) { + printf("\n "); + } + + } + + printf("\n"); + + } + + } + + void xcorrs_printf_signal(const xcorrs_obj * obj, const unsigned int iSignal) { + + unsigned int iSample; + + printf("(%04u): ",iSignal); + + for (iSample = 0; iSample < obj->frameSize; iSample++) { + + printf("%+1.5f ",obj->array[iSignal][iSample]); + + if ((((iSample+1) % 16) == 0) && ((iSample+1)!=obj->frameSize)) { + printf("\n "); + } + + } + + printf("\n"); + + } \ No newline at end of file diff --git a/src/signal/xcorr.h b/src/signal/xcorr.h new file mode 100644 index 0000000..7bc7cec --- /dev/null +++ b/src/signal/xcorr.h @@ -0,0 +1,24 @@ +#ifndef __ODAS_SIGNAL_XCORR +#define __ODAS_SIGNAL_XCORR + + #include + #include + #include + + typedef struct xcorrs_obj { + + unsigned int nSignals; + unsigned int frameSize; + float ** array; + + } xcorrs_obj; + + xcorrs_obj * xcorrs_construct_zero(const unsigned int nSignals, const unsigned int frameSize); + + void xcorrs_destroy(xcorrs_obj * obj); + + void xcorrs_printf(const xcorrs_obj * obj); + + void xcorrs_printf_signal(const xcorrs_obj * obj, const unsigned int iSignal); + +#endif \ No newline at end of file -- 2.34.1