Home | Develop | Download | Contact
testprog2.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 void init_matriz(PdsBMatrix *M1)
36 {
37  PdsBaNatural i,j,k;
38 
39  for(i=0,k=0;i<M1->Nlin;i++)
40  for(j=0 ;j<M1->Ncol;j++,k++)
41  {
42  if( ((k%3)==0)||((k%5)==0) ) pds_bmatrix_set_bit(M1,i,j,1);
43  else pds_bmatrix_set_bit(M1,i,j,0);
44  }
45 }
46 
47 int main(int argc, char** argv)
48 {
50  PdsBMatrix *M1=NULL;
51  PdsBVector *V2=NULL;
52  PdsBaNatural m;
53  PdsBaByte B;
54  PdsBaBit b;
55  PdsBMatrix *M2=NULL;
56 
57  //creo e inicializo la matriz
58  M1=pds_bmatrix_new(4,10);
59  init_matriz(M1); pds_bmatrix_printf(M1);
60 
61  //Cuento unos por fila y columna
62  pds_bmatrix_row_weight(M1,0,&m); printf("\nfila 0:\tpeso=%d\n",m);
63  pds_bmatrix_column_weight(M1,0,&m); printf("colu 0:\tpeso=%d\n\n",m);
64 
65  //Creo un archivo en formato alist
66  pds_bmatrix_alist_save(M1,"Archivo.alist");
67 
68  //Creo una nueva matriz sistemática
69  printf("Sistematica:\n");
71 
72 
73  return EXIT_SUCCESS;
74 }
PdsBMatrix * pds_bmatrix_new(PdsBaNatural Nlin, PdsBaNatural Ncol)
Crea una matriz de tipo PdsBMatrix.
PdsBaNatural Nlin
Definition: pdsbmatrix.h:69
unsigned char PdsBaByte
Definition: pdsbaglobal.h:43
int pds_bmatrix_row_weight(const PdsBMatrix *BMatrix, PdsBaNatural lin, PdsBaNatural *m)
Retorna la cantidad de unos en la linea lin de la matriz BMatrix.
int pds_bmatrix_alist_save(const PdsBMatrix *m, const char *filename)
Escribe la matriz en un archivo con nombre filename en formato Alist. Mackay,.
PdsBMatrix * pds_bmatrix_systematize(const PdsBMatrix *S, PdsBaNatural *pos)
Retorna una matriz systemática o hasta donde se pueda sistematizar, carga en pos la linea del ultimo ...
int pds_bmatrix_printf(const PdsBMatrix *BMatrix)
Imprime en pantallala la matriz BMatrix.
PdsBaNatural Ncol
Definition: pdsbmatrix.h:73
La estructura tipo PdsBMatrix . Esta estructura genera una matriz binaria de Nel bits. Para usar incluir pds/pdsbmatrix.h.
Definition: pdsbmatrix.h:66
unsigned char PdsBaBit
Definition: pdsbaglobal.h:49
unsigned int PdsBaNatural
Definition: pdsbaglobal.h:55
int pds_bmatrix_column_weight(const PdsBMatrix *BMatrix, PdsBaNatural col, PdsBaNatural *m)
Retorna la cantidad de unos en la columna col de la matriz BMatrix.
int pds_bmatrix_set_bit(PdsBMatrix *BMatrix, PdsBaNatural lin, PdsBaNatural col, PdsBaBit value)
Escribe el valor binario value en la posición (lin,col) de la matriz BMatrix.
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