OSDN Git Service

Please enter the commit message for your changes. Lines starting
[eos/base.git] / src / Tools / eosMath / eosMathAverage / src / eosMathAverage.c
1 /*
2 # eosMathAverage : $Revision$  
3 # $Date$ 
4 # Created by $Author$
5 # Usage : eosMathAverage
6 # Attention
7 #   $Loccker$
8 #       $State$ 
9 #
10 */
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <string.h>
14 #include <math.h>                  
15 #define GLOBAL_DECLARATION
16 #include "../inc/config.h"
17
18 #define DEBUG
19 #include "genUtil.h"
20 #include "Array.h"
21 #include "Memory.h"
22 #include "eosMath.h"
23
24 /*
25 Example:
26 typedef struct leosMathAverageInfo {
27         float a;
28         int   b;
29 } leosMathAverageInfo;
30
31 typedef enum leosMathAverageMode {
32         a=0,
33         b=1
34 } leosMathAverageMode;
35 */
36
37 int
38 main(int argc, char* argv[]) 
39 {
40         eosMathAverageInfo info;
41   Array in;
42   int n, i;
43   double* v;
44   double avg;
45
46         init0(&info);
47   argCheck(&info, argc, argv);
48   init1(&info);
49
50         DEBUGPRINT("Program Start\n");
51
52  arrayReadFromFile(info.fptIn, &in, "in main");
53
54   if(1<in.dim) {
55     fprintf(stderr, "Not supported dim: %ld\n", in.dim);
56     exit(EXIT_FAILURE);
57   }
58   n = in.n[0];
59   v = memoryAllocate(sizeof(double)*n, "in main");
60   for(i=0; i<n; i++) {
61     v[i] = in.A[i];
62   }
63
64   if(info.flagTrim) {
65     avg = eosMathTrimmedAverage(v, n, info.Trim);
66   } else {
67     avg = eosMathAverage(v, n);
68   }
69
70   fprintf(info.fptOut, "%f\n", avg);
71         exit(EXIT_SUCCESS);
72 }
73
74 void
75 additionalUsage()
76 {
77         fprintf(stderr, "----- Additional Usage -----\n");
78 }