Home | Develop | Download | Contact
testpdsrv3.c
1 /*
2  * testpdsrv3.c
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 
34 #include <config.h>
35 #include <stdlib.h>
36 #include <math.h>
37 #include <pds/pdsrv.h>
38 
39 
40 double pds_inc( unsigned long int t3,unsigned long int t5,
41  unsigned long int t7,unsigned long int t11,
42  unsigned long int t13,unsigned long int t17);
43 
44 
45 void pds_next_inc( unsigned long int *t3 ,unsigned long int *t5,
46  unsigned long int *t7 ,unsigned long int *t11,
47  unsigned long int *t13,unsigned long int *t17);
48 
49 int main(int argc, char** argv)
50 {
51  unsigned long int i;
52  unsigned long int t3=0;
53  unsigned long int t5=0;
54  unsigned long int t7=0;
55  unsigned long int t11=0;
56  unsigned long int t13=0;
57  unsigned long int t17=0;
58 
59  PdsRvReal C0,C1;
60 
61  i=0;
62  C0=pds_inc(t3,t5,t7,t11,t13,t17);
63  printf("%10lu:::%10lu:%10lu:{%3lu,%3lu,%3lu,%3lu,%3lu,%3lu}\n",i,PDS_RAND_MAX,(unsigned long int)C0,t3,t5,t7,t11,t13,t17);
64  pds_next_inc(&t3,&t5,&t7,&t11,&t13,&t17);
65 
66  do
67  {
68  i++;
69  C1=pds_inc(t3,t5,t7,t11,t13,t17);
70  printf("%10lu:::%10lu:%10lu:{%3lu,%3lu,%3lu,%3lu,%3lu,%3lu}\n",i,PDS_RAND_MAX,(unsigned long int)C1,t3,t5,t7,t11,t13,t17);
71  pds_next_inc(&t3,&t5,&t7,&t11,&t13,&t17);
72  //getchar();
73 
74  }while(C0!=C1);
75 
76  printf("<<Numero total de variables aleatorias distintas : %lu>>\n",i);
77 
78  return EXIT_SUCCESS;
79 }
80 
81 
95 double pds_inc( unsigned long int t3,unsigned long int t5,
96  unsigned long int t7,unsigned long int t11,
97  unsigned long int t13,unsigned long int t17)
98 {
99  return pow(3.0,t3)*pow(5.0,t5)*pow(7.0,t7)*pow(11.0,t11)*pow(13.0,t13)*pow(17.0,t17);
100 }
101 
116 void pds_next_inc( unsigned long int *t3 ,unsigned long int *t5,
117  unsigned long int *t7 ,unsigned long int *t11,
118  unsigned long int *t13,unsigned long int *t17)
119 {
120 
121  if(pds_inc((*t3)+1,*t5,*t7,*t11,*t13,*t17)<(PDS_RAND_MAX*1.0)) {*t3=(*t3)+1;}
122  else
123  { *t3=1;
124  if(pds_inc(*t3,(*t5)+1,*t7,*t11,*t13,*t17)<(PDS_RAND_MAX*1.0)) {*t5=(*t5)+1;}
125  else
126  { *t5=0;
127  if(pds_inc(*t3,*t5,(*t7)+1,*t11,*t13,*t17)<(PDS_RAND_MAX*1.0)) {*t7=(*t7)+1;}
128  else
129  { *t7=0;
130  if(pds_inc(*t3,*t5,*t7,(*t11)+1,*t13,*t17)<(PDS_RAND_MAX*1.0)) {*t11=(*t11)+1;}
131  else
132  { *t11=0;
133  if(pds_inc(*t3,*t5,*t7,*t11,(*t13)+1,*t17)<(PDS_RAND_MAX*1.0)) {*t13=(*t13)+1;}
134  else
135  { *t13=0;
136  if(pds_inc(*t3,*t5,*t7,*t11,*t13,(*t17)+1)<(PDS_RAND_MAX*1.0)) {*t17=(*t17)+1;}
137  else {*t17=0;*t3=0;*t5=0;*t7=0;*t11=0;*t13=0;}
138  }
139  }
140  }
141  }
142  }
143 
144 }
#define PDS_RAND_MAX
float PdsRvReal
Definition: pdsrvglobal.h:59

Enlaces de interés

HomePage Bazaar Download Bug report Ayuda Developer Feed