annotate src/delta.c @ 152:07aa4d2af390

removed extraneous files
author Jamie Bullock <jamie@jamiebullock.com>
date Wed, 09 Jan 2013 23:22:07 +0000
parents baaa9d8b4d10
children 71870680f7c1
rev   line source
jamie@141 1 /*
jamie@141 2 * Copyright (C) 2012 Jamie Bullock
jamie@140 3 *
jamie@141 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
jamie@141 5 * of this software and associated documentation files (the "Software"), to
jamie@141 6 * deal in the Software without restriction, including without limitation the
jamie@141 7 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
jamie@141 8 * sell copies of the Software, and to permit persons to whom the Software is
jamie@141 9 * furnished to do so, subject to the following conditions:
jamie@1 10 *
jamie@141 11 * The above copyright notice and this permission notice shall be included in
jamie@141 12 * all copies or substantial portions of the Software.
jamie@1 13 *
jamie@141 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
jamie@141 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
jamie@141 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
jamie@141 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
jamie@141 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
jamie@141 19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
jamie@141 20 * IN THE SOFTWARE.
jamie@1 21 *
jamie@1 22 */
jamie@1 23
jamie@1 24 /* xtract_delta.c: defines functions that extract a feature as a single value from more than one input vector */
jamie@1 25
jamie@106 26 #include <math.h>
jamie@106 27
jamie@38 28 #include "xtract/libxtract.h"
jamie@1 29
jamie@146 30 int xtract_flux(const double *data, const int N, const void *argv , double *result)
jamie@140 31 {
jamie@1 32
jamie@117 33 /* FIX: don't be lazy -- take the lnorm of the difference vector! */
jamie@106 34 return xtract_lnorm(data, N, argv, result);
jamie@105 35
jamie@106 36 }
jamie@106 37
jamie@146 38 int xtract_lnorm(const double *data, const int N, const void *argv , double *result)
jamie@140 39 {
jamie@106 40
jamie@107 41 int n,
jamie@106 42 type;
jamie@106 43
jamie@146 44 double order;
jamie@106 45
jamie@146 46 order = *(double *)argv;
jamie@146 47 type = *((double *)argv+1);
jamie@106 48
jamie@146 49 order = order > 0 ? order : 2.0;
jamie@106 50
jamie@146 51 *result = 0.0;
jamie@111 52
jamie@140 53 switch(type)
jamie@140 54 {
jamie@106 55
jamie@140 56 case XTRACT_POSITIVE_SLOPE:
jamie@140 57 for(n = 0; n < N; n++)
jamie@140 58 {
jamie@140 59 if(data[n] > 0)
jamie@146 60 *result += pow(data[n], order);
jamie@140 61 }
jamie@140 62 break;
jamie@140 63 default:
jamie@140 64 for(n = 0; n < N; n++)
jamie@146 65 *result += pow(data[n], order);
jamie@140 66 break;
jamie@106 67
jamie@106 68 }
jamie@106 69
jamie@146 70 *result = pow(*result, 1.0 / order);
jamie@106 71
jamie@106 72 return XTRACT_SUCCESS;
jamie@1 73
jamie@1 74 }
jamie@1 75
jamie@146 76 int xtract_attack_time(const double *data, const int N, const void *argv , double *result)
jamie@140 77 {
jamie@1 78
jamie@56 79 return XTRACT_FEATURE_NOT_IMPLEMENTED;
jamie@1 80
jamie@1 81 }
jamie@1 82
jamie@146 83 int xtract_decay_time(const double *data, const int N, const void *argv, double *result)
jamie@140 84 {
jamie@1 85
jamie@56 86 return XTRACT_FEATURE_NOT_IMPLEMENTED;
jamie@1 87
jamie@1 88 }
jamie@1 89
jamie@146 90 int xtract_difference_vector(const double *data, const int N, const void *argv, double *result)
jamie@140 91 {
jamie@1 92
jamie@146 93 const double *frame1,
jamie@106 94 *frame2;
jamie@106 95
jamie@106 96 int n;
jamie@106 97
jamie@106 98 n = N >> 1;
jamie@106 99
jamie@106 100 frame1 = data;
jamie@106 101 frame2 = data + n;
jamie@106 102
jamie@106 103 while(n--)
jamie@106 104 result[n] = frame1[n] - frame2[n];
jamie@106 105
jamie@106 106 return XTRACT_SUCCESS;
jamie@1 107
jamie@1 108 }