Home | Develop | Download | Contact
testprog1.c
1 /*
2  * testprog1.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 
23 
31 #include <config.h>
32 #include <stdlib.h>
33 #include <pds/pdsba.h>
34 
35 int main(int argc, char** argv)
36 {
38  PdsBVector *V1=NULL;
39  PdsBVector *V2=NULL;
40  PdsBaNatural n;
41  PdsBaByte B;
42  PdsBaBit b;
43 
44  V1=pds_bvector_new(100);
45  V2=pds_bvector_new(100);
46 
47  pds_bvector_init(V1,1);
49 
50  pds_bvector_init_rand(V2,0.5);
52 
53  pds_bvector_cmp(V1,V2,&n);
54 
55  printf("Diferencias:%d\n",n);
56 
57  pds_bvector_get_byte(V2,12,&B);
58  printf("V2[BYTE{12}]=%X\n",B);
59 
60  pds_bvector_set_byte(V2,12,250);
61  printf("V2[BYTE{12}] <-- %X\n",250);
63 
64  pds_bvector_get_byte(V2,12,&B);
65  printf("V2[BYTE{12}]=%X\n",B);
66 
67  pds_bvector_get_bit(V2,10,&b);
68  printf("V2[BIT{10}]=%X\n",b);
69 
70  pds_bvector_set_bit(V2,13,1);
71  printf("V2[BIT{13}] <-- %X\n",1);
73 
74  pds_bvector_free(V1);
75  pds_bvector_free(V2);
76 
77  return EXIT_SUCCESS;
78 }
int pds_bvector_set_bit(PdsBVector *BVector, PdsBaNatural n, PdsBaBit m)
Escribe el bit de la posición n del vector BVector y lo carga desde m.
unsigned char PdsBaByte
Definition: pdsbaglobal.h:43
int pds_bvector_get_byte(const PdsBVector *BVector, PdsBaNatural n, PdsBaByte *m)
Obtiene el byte de la posición n del vector BVector y lo carga en m.
int pds_bvector_init(PdsBVector *BVector, PdsBaBit Bit)
Inicia con el valor Bit los Nel bits del vector.
int pds_bvector_printf(const PdsBVector *BVector)
Imprime en pantalla todos los elementos del vector;.
void pds_bvector_free(PdsBVector *BVector)
Libera un vector de tipo puntero PdsBVector.
int pds_bvector_init_rand(PdsBVector *BVector, PdsBaReal p)
Inicia el vector con algunos "1"s, cada bit tiene una probabilidad p de ser "1" (P{V_i=1}=p).
int pds_bvector_cmp(const PdsBVector *BVector1, const PdsBVector *BVector2, PdsBaNatural *n)
Encuentra el número de elementos distintos entre los dos vectores.
unsigned char PdsBaBit
Definition: pdsbaglobal.h:49
int pds_bvector_get_bit(const PdsBVector *BVector, PdsBaNatural n, PdsBaBit *m)
Obtiene el bit de la posición n del vector BVector y lo carga en m.
int pds_bvector_set_byte(PdsBVector *BVector, PdsBaNatural n, PdsBaByte m)
Escribe en el byte de la posición n del vector BVector, desde m.
PdsBVector * pds_bvector_new(PdsBaNatural Nel)
Crea una matriz de tipo PdsBVector.
unsigned int PdsBaNatural
Definition: pdsbaglobal.h:55
La estructura tipo PdsBVector . Esta estructura genera un vector binario de Nel bits. Para usar incluir pds/pdsbvector.h.
Definition: pdsbvector.h:66

Enlaces de interés

HomePage Bazaar Download Bug report Ayuda Developer Feed