int main ( int argc, char * argv [] ){ matrix_t A=matinit(); matrix_t B=matinit(); matrix_t C=matinit(); loadByName("testfiles/input.mat", "a", &A); loadByName("testfiles/input.mat", "b", &B); printf("Matriz A:\n"); matprint(A); putchar('\n'); printf("Matriz B:\n"); matprint(B); putchar('\n'); C=convolution(A,B); if( C.height==0 ){ return 1; } printf("\nMatriz C:\n"); matprint(C); putchar('\n'); saveByName("testfiles/output.mat", "c", &C); //TEST probar si funciona el copiar: matrix_t D = matinit(); D.height=0; D.width=0; matcpy(&D, &C); printf("\nMatriz D:\n"); matprint(D); matfree(&D); matfree(&C); matfree(&A); matfree(&B); return 0; }
static void recompute_mask(tdflippo_instance_t* inst) { float xpos=(float)inst->width*inst->center[0]; float ypos=(float)inst->height*inst->center[1]; float **mat=mat_translate(xpos,ypos,0.0); if(inst->flip[0]!=0.5) mat=matmult(mat,mat_rotate(AXIS_X,(inst->flip[0]-0.5)*TWO_PI)); if(inst->flip[1]!=0.5) mat=matmult(mat,mat_rotate(AXIS_Y,(inst->flip[1]-0.5)*TWO_PI)); if(inst->flip[2]!=0.5) mat=matmult(mat,mat_rotate(AXIS_Z,(inst->flip[2]-0.5)*TWO_PI)); mat=matmult(mat,mat_translate(-xpos,-ypos,0.0)); #if 0 fprintf(stderr,"Resarra %.2f %.2f %.2f %.2f | %.2f %.2f %.2f %.2f | %.2f %.2f %.2f %.2f | %.2f %.2f %.2f %.2f\n", mat[0][0],mat[0][1],mat[0][2],mat[0][3], mat[1][0],mat[1][1],mat[1][2],mat[1][3], mat[2][0],mat[2][1],mat[2][2],mat[2][3], mat[3][0],mat[3][1],mat[3][2],mat[3][3]); #endif int x,y,nx,ny,pos; float xf,yf,zf; if(!inst->dontblank) memset(inst->mask,0xff,sizeof(int)*inst->fsize); for(y=0,pos=0;y<inst->height;y++) for(x=0;x<inst->width;x++,pos++) { xf=x; yf=y; zf=0.0; vetmat(mat,&xf,&yf,&zf); nx=(int)(xf+0.5); ny=(int)(yf+0.5); if(nx>=0 && nx<inst->width && ny>=0 && ny<inst->height) { if(!inst->invertrot) inst->mask[ny*inst->width+nx]=pos; else inst->mask[pos]=ny*inst->width+nx; } } matfree(mat); }