void extreme(int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[]) { dd_PolyhedraPtr P; dd_ErrorType err; dd_MatrixPtr H,V; dd_SetFamilyPtr GI, GA; if (nrhs == 1 && nlhs <=2 && mxIsStruct(prhs[0])) { dd_set_global_constants(); /* First, this must be called. */ H = FT_get_H_MatrixPtr(prhs[0]); P = dd_DDMatrix2Poly(H, &err); /* compute the second representation */ if (err == dd_NoError) { V = dd_CopyGenerators(P); GI=dd_CopyInputIncidence(P); GA=dd_CopyAdjacency(P); plhs[0] = FT_set_V_MatrixPtr(V); plhs[1] = ZH_set_Vlist(GI,GA); dd_FreeSetFamily(GA); dd_FreeSetFamily(GI); dd_FreeMatrix(V); } else { dd_WriteErrorMessages(stdout,err); mexErrMsgTxt("CDD returned an error, see above(!) for details"); } dd_FreeMatrix(H); dd_FreePolyhedra(P); return; } else { mexErrMsgTxt("extreme expects an H input struct and produces a V output struct"); } }
void file_ine(int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[]) /* Ine file input, V output, similar to extreme */ { dd_PolyhedraPtr poly; dd_MatrixPtr M; dd_ErrorType err; char *inputfile; FILE *reading=NULL; dd_MatrixPtr A, G; dd_SetFamilyPtr GI,GA; int buflen, status; dd_set_global_constants(); /* First, this must be called. */ if (nrhs == 1 && nlhs <=2 && mxIsChar(prhs[0])) { /* dd_SetInputFile(&reading,inputfile, &err); */ buflen = mxGetN(prhs[0]) + 1; inputfile= mxCalloc(buflen, sizeof(char)); status = mxGetString(prhs[0], inputfile, buflen); if ( (reading = fopen(inputfile,"r") )== NULL) { mxErrMsgTxt("Input file not found\n"); return; } printf(" Input file opened. \n"); M=dd_PolyFile2Matrix(reading, &err); if (err==dd_NoError) { poly=dd_DDMatrix2Poly(M, &err); /* compute the second representation */ if (err!=dd_NoError) { dd_WriteErrorMessages(stdout,err); mxErrMsgTxt("CDD internal error\n"); return; } A=dd_CopyInequalities(poly); G=dd_CopyGenerators(poly); GI=dd_CopyInputIncidence(poly); GA=dd_CopyAdjacency(poly); plhs[0] = FT_set_V_MatrixPtr(G); plhs[1] = ZH_set_Vlist(GI,GA); dd_FreePolyhedra(poly); dd_FreeMatrix(M); return; } } else { mexErrMsgTxt("file-ine expects an file input"); } return; }
void allfacets2(int n_input, int d_input, double *g_input) /* output facets, incidences and adjacency */ { dd_PolyhedraPtr poly; dd_MatrixPtr A=NULL,G=NULL; dd_SetFamilyPtr AI=NULL, AA=NULL; dd_SetFamilyPtr GI=NULL, GA=NULL; dd_rowrange i,n; dd_colrange j,d; dd_ErrorType err; n=(dd_rowrange)n_input; d=(dd_colrange)d_input; G=dd_CreateMatrix(n,d); for (i=0; i<n; i++){ for (j=0; j<d; j++) dd_set_d(G->matrix[i][j],g_input[i*d+j]); } G->representation=dd_Generator; poly=dd_DDMatrix2Poly(G, &err); /* compute the second (inequality) representation */ if (err==dd_NoError){ A=dd_CopyInequalities(poly); AI=dd_CopyIncidence(poly); AA=dd_CopyAdjacency(poly); GI=dd_CopyInputIncidence(poly); GA=dd_CopyInputAdjacency(poly); MLPutFunction(stdlink,"List",5); dd_MLWriteMatrix(A); dd_MLWriteSetFamily(AI); dd_MLWriteSetFamily(AA); dd_MLWriteSetFamily(GI); dd_MLWriteSetFamily(GA); } else { dd_MLWriteError(poly); } dd_FreeMatrix(A); dd_FreeMatrix(G); dd_FreeSetFamily(AI); dd_FreeSetFamily(AA); dd_FreeSetFamily(GI); dd_FreeSetFamily(GA); }
void allvertices2(int m_input, int d_input, double *a_input) /* output vertices, incidences and adjacency */ { dd_PolyhedraPtr poly; dd_MatrixPtr A=NULL,G=NULL; dd_SetFamilyPtr GI=NULL,GA=NULL; dd_SetFamilyPtr AI=NULL,AA=NULL; dd_rowrange i,m; dd_colrange j,d; dd_ErrorType err; m=(dd_rowrange)m_input; d=(dd_colrange)d_input; A=dd_CreateMatrix(m,d); for (i=0; i<m; i++){ for (j=0; j<d; j++) dd_set_d(A->matrix[i][j],a_input[i*d+j]); } A->representation=dd_Inequality; poly=dd_DDMatrix2Poly(A, &err); /* compute the second (generator) representation */ if (err==dd_NoError){ G=dd_CopyGenerators(poly); GI=dd_CopyIncidence(poly); GA=dd_CopyAdjacency(poly); AI=dd_CopyInputIncidence(poly); AA=dd_CopyInputAdjacency(poly); MLPutFunction(stdlink,"List",5); dd_MLWriteMatrix(G); dd_MLWriteSetFamily(GI); dd_MLWriteSetFamily(GA); dd_MLWriteSetFamily(AI); dd_MLWriteSetFamily(AA); } else { dd_MLWriteError(poly); } dd_FreeMatrix(A); dd_FreeMatrix(G); dd_FreeSetFamily(GI); dd_FreeSetFamily(GA); dd_FreeSetFamily(AI); dd_FreeSetFamily(AA); }