Home | Develop | Download | Contact
data_work.h
1 /*
2  * data_work.h
3  *
4  * Copyright 2011 Fernando Pujaico Rivera <fernando.pujaico.rivera@gmail.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19  * MA 02110-1301, USA.
20  *
21  */
22 
23 
31 #ifndef __DATA_WORK_H__
32 #define __DATA_WORK_H__
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 #include <time.h>
38 #include <pds/pdsrv.h>
39 int function_data_work_init_data0(PdsVector *X,PdsVector *Y)
40 {
41  if(X==NULL) return FALSE;
42 
44  if(Y!=NULL) pds_vector_init_value(Y,-1.0);
45 
47  PdsUniform *RV=pds_uniform_new(-128,128);
48  if(RV==NULL) return FALSE;
49  pds_uniform_init(RV,1.0*(clock()%128));
50 
51  pds_uniform_get_vector(RV,X);
52 
53  pds_uniform_free(RV);
54 
55  return TRUE;
56 }
57 int function_data_work_init_data1(PdsVector *X,PdsVector *Y)
58 {
59  PdsRaNatural i;
60  PdsRvReal m,phase;
61  float Ciclos=3;
62 
63  if(X==NULL) return FALSE;
64 
66  if(Y!=NULL) pds_vector_init_value(Y,+1.0);
67 
69  PdsUniform *RV=pds_uniform_new(-128,128);
70  if(RV==NULL) return FALSE;
71 
72  pds_uniform_init(RV,1.0*(clock()%128));
73 
74  pds_uniform_get_value(RV,&phase);
75  phase=M_PI*phase/128.0;
76 
77  for(i=0;i<X->Nel;i++)
78  {
79  pds_uniform_get_value(RV,&m);
80  X->V[i]=128*sin(2*M_PI*Ciclos*i/(1.0*X->Nel)+phase)+0.1*m;
81  }
82 
83  pds_uniform_free(RV);
84  return TRUE;
85 }
86 
87 
88 #ifdef __cplusplus
89 }
90 #endif
91 
92 
93 #endif /* __DATA_WORK_H__ */
94 

Enlaces de interés

HomePage Bazaar Download Bug report Ayuda Developer Feed