Changeset 12060
- Timestamp:
- 04/19/12 15:55:42 (13 years ago)
- Location:
- issm/trunk-jpl/src/modules
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified issm/trunk-jpl/src/modules/Chaco/Chaco.cpp ¶
r12050 r12060 18 18 19 19 /*Inputs: */ 20 int nvtxs; /* number of vertices in graph*/21 int *start; /* start of edge list for each vertex*/22 int *adjacency; /* edge list data*/23 int *vwgts=NULL; /* weights for all vertices*/24 int 25 float *ewgts=NULL; /* weights for all edges*/26 float *x=NULL;27 float *y=NULL;28 float *z=NULL; /* coordinates for inertial method*/29 double options[10]={1,1,0,0,1,1,50,0,.001,7654321}; /* architecture and partitioning options */30 double* in_options=NULL;31 int *nparts=NULL; /* number of parts options*/32 int 33 double *goal=NULL; /* desired set sizes*/20 int nvtxs; /* number of vertices in graph */ 21 int *start; /* start of edge list for each vertex */ 22 int *adjacency; /* edge list data */ 23 int *vwgts = NULL; /* weights for all vertices */ 24 int nedges; 25 float *ewgts = NULL; /* weights for all edges */ 26 float *x = NULL; 27 float *y = NULL; 28 float *z = NULL; /* coordinates for inertial method */ 29 double options[10] = {1,1,0,0,1,1,50,0,.001,7654321}; /* architecture and partitioning options */ 30 double *in_options = NULL; 31 int *nparts = NULL; /* number of parts options */ 32 int npart; 33 double *goal = NULL; /* desired set sizes */ 34 34 35 35 /*intermediary pointers: */ … … 38 38 39 39 /*output: */ 40 short *assignment=NULL; /* set number of each vtx (length nvtxs+1) */ 41 double *doubleassignment=NULL; /*holds assignment, in double format, to return to matlab*/ 42 40 short *assignment = NULL; /* set number of each vtx (length nvtxs+1) */ 41 double *doubleassignment = NULL; /*holds assignment, in double format, to return to matlab */ 43 42 44 43 #ifndef _HAVE_CHACO_ //only works if dakota library has been compiled in. 45 44 _error_(" Chaco not available! Cannot carry out Chaco partitioning!"); 46 45 #endif 47 48 46 49 47 /*Boot module: */ … … 53 51 CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&ChacoUsage); 54 52 55 56 53 /*Fetch adjacency matrix: */ 57 54 nvtxs = mxGetN(A_IN); 58 59 55 mwstart = mxGetJc(A_IN); 60 start=(int*) mxMalloc(nvtxs*sizeof(int));56 start=(int*)xmalloc(nvtxs*sizeof(int)); 61 57 for (i=0; i<nvtxs+1;i++)start[i]=(int)mwstart[i]; 62 58 63 59 mwadjacency = mxGetIr(A_IN); 64 adjacency = (int*) mxMalloc(mxGetNzmax(A_IN)*sizeof(int));60 adjacency = (int*)xmalloc(mxGetNzmax(A_IN)*sizeof(int)); 65 61 for (i=0; i<mxGetNzmax(A_IN); i++) adjacency[i]= (int)mwadjacency[i]; 66 62 67 63 nedges = start[nvtxs]; 68 64 if(!mxIsEmpty(EWGTS_IN)){ 69 ewgts = (float *) mxCalloc(nedges, sizeof(float));65 ewgts = (float*)xcalloc(nedges, sizeof(float)); 70 66 doublepointer=mxGetPr(A_IN); 71 67 for (i = 0; i < nedges; i++)ewgts[i] = (float)doublepointer[i]; … … 75 71 /*Fetch rest of data: */ 76 72 FetchData(&vwgts,&nterms,VWGTS_IN); 77 78 73 FetchData(&x,&nterms,X_IN); 79 74 FetchData(&y,&nterms,Y_IN); 80 75 FetchData(&z,&nterms,Z_IN); 81 82 76 FetchData(&in_options,&nterms,OPTNS_IN); 83 77 for (i=0;i<(nterms<10?nterms:10);i++) options[i]=in_options[i]; //copy in_options into default options 84 85 78 FetchData(&npart,NPARTS_IN); 86 nparts=(int*)mxMalloc(sizeof(int)); nparts[0]=npart; //weird Chacox interface ain't it? 87 79 nparts=(int*)xmalloc(sizeof(int)); nparts[0]=npart; //weird Chacox interface ain't it? 88 80 FetchData(&goal,&nterms,GOAL_IN); 89 81 … … 112 104 113 105 /*Allocate output: */ 114 assignment = (short *) mxCalloc(nvtxs, sizeof(short));106 assignment = (short*)xcalloc(nvtxs, sizeof(short)); 115 107 116 108 /*Call core: */ … … 118 110 119 111 /*Output data: */ 120 doubleassignment=(double*) mxMalloc(nvtxs*sizeof(double));121 for 112 doubleassignment=(double*)xmalloc(nvtxs*sizeof(double)); 113 for(i=0;i<nvtxs;i++) doubleassignment[i]=(double)assignment[i]; 122 114 WriteData(ASSGN_OUT,doubleassignment,nvtxs); 123 115 … … 133 125 xfree((void**)&adjacency); 134 126 xfree((void**)&start); 127 xfree((void**)&doubleassignment); 135 128 136 129 /*end module: */ … … 138 131 } 139 132 140 void ChacoUsage( void ) 141 { 133 void ChacoUsage(void){ 142 134 _printf_(true,"\n"); 143 135 _printf_(true,"Usage: [assgn] = Chaco(A,vwgts,ewgts,x,y,z,options,nparts,goal);\n"); 144 136 _printf_(true,"\n"); 145 137 } 146 -
TabularUnified issm/trunk-jpl/src/modules/ContourToMesh/ContourToMesh.cpp ¶
r12050 r12060 26 26 27 27 /* required input: */ 28 double* index=NULL;29 double* x=NULL;30 double* y=NULL;31 28 int edgevalue; 32 char* interptype=NULL; 29 double *index = NULL; 30 double *x = NULL; 31 double *y = NULL; 32 char *interptype = NULL; 33 33 34 34 /* output: */ 35 Vector * in_nod=NULL;36 int nods;37 Vector * in_elem=NULL;38 int nel;35 Vector *in_nod = NULL; 36 int nods; 37 Vector *in_elem = NULL; 38 int nel; 39 39 40 40 //contours 41 mxArray * matlabstructure=NULL;42 int numcontours;43 Contour ** contours=NULL;44 Contour * contouri=NULL;41 mxArray *matlabstructure = NULL; 42 int numcontours; 43 Contour **contours = NULL; 44 Contour *contouri = NULL; 45 45 46 46 /*Boot module: */ … … 65 65 //Fetch contours 66 66 numcontours=mxGetNumberOfElements(matlabstructure); 67 contours=(Contour**) mxMalloc(numcontours*sizeof(Contour*));67 contours=(Contour**)xmalloc(numcontours*sizeof(Contour*)); 68 68 for(i=0;i<numcontours;i++){ 69 69 //allocate 70 contouri=(Contour*) mxMalloc(sizeof(Contour));70 contouri=(Contour*)xmalloc(sizeof(Contour)); 71 71 //retrieve dimension of this contour. 72 72 contouri->nods=(int)mxGetScalar(mxGetField(matlabstructure,i,"nods")); -
TabularUnified issm/trunk-jpl/src/modules/ContourToNodes/ContourToNodes.cpp ¶
r12050 r12060 68 68 69 69 numcontours=mxGetNumberOfElements(matlabstructure); 70 contours=(Contour**) mxMalloc(numcontours*sizeof(Contour*));70 contours=(Contour**)xmalloc(numcontours*sizeof(Contour*)); 71 71 for(i=0;i<numcontours;i++){ 72 72 //allocate 73 contouri=(Contour*) mxMalloc(sizeof(Contour));73 contouri=(Contour*)xmalloc(sizeof(Contour)); 74 74 //retrieve dimension of this contour. 75 75 contouri->nods=(int)mxGetScalar(mxGetField(matlabstructure,i,"nods")); -
TabularUnified issm/trunk-jpl/src/modules/InternalFront/InternalFront.cpp ¶
r12050 r12060 36 36 /*Allocate and initialize all variables*/ 37 37 numberofsegments=0; 38 front=(int*) mxMalloc(3*numberofelements*4*sizeof(int));38 front=(int*)xmalloc(3*numberofelements*4*sizeof(int)); 39 39 40 40 /*Loop over all elements on water*/ … … 81 81 /*Now that we know how many segments there is we can allocate the final matrix*/ 82 82 if(numberofsegments){ 83 front2=(double*) mxMalloc(4*numberofsegments*sizeof(double));83 front2=(double*)xmalloc(4*numberofsegments*sizeof(double)); 84 84 for(i=0;i<4*numberofsegments;i++) front2[i]=(double)front[i]; 85 85 } -
TabularUnified issm/trunk-jpl/src/modules/InterpFromMesh2d/InterpFromMesh2d.cpp ¶
r12050 r12060 100 100 /*contours: */ 101 101 numcontours=mxGetNumberOfElements(matlabstructure); 102 contours=(Contour**) mxMalloc(numcontours*sizeof(Contour*));102 contours=(Contour**)xmalloc(numcontours*sizeof(Contour*)); 103 103 for(i=0;i<numcontours;i++){ 104 104 //allocate 105 contouri=(Contour*) mxMalloc(sizeof(Contour));105 contouri=(Contour*)xmalloc(sizeof(Contour)); 106 106 //retrieve dimension of this contour. 107 107 contouri->nods=(int)mxGetScalar(mxGetField(matlabstructure,i,"nods")); -
TabularUnified issm/trunk-jpl/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp ¶
r12050 r12060 78 78 /*contours: */ 79 79 numcontours=mxGetNumberOfElements(matlabstructure); 80 contours=(Contour**) mxMalloc(numcontours*sizeof(Contour*));80 contours=(Contour**)xmalloc(numcontours*sizeof(Contour*)); 81 81 for(i=0;i<numcontours;i++){ 82 82 //allocate 83 contouri=(Contour*) mxMalloc(sizeof(Contour));83 contouri=(Contour*)xmalloc(sizeof(Contour)); 84 84 //retrieve dimension of this contour. 85 85 contouri->nods=(int)mxGetScalar(mxGetField(matlabstructure,i,"nods")); -
TabularUnified issm/trunk-jpl/src/modules/KMLMeshWrite/KMLMeshWrite.cpp ¶
r12050 r12060 55 55 if (notesi && mxIsChar(notesi) && mxGetNumberOfElements(notesi)) { 56 56 if (!notes) { 57 notes=(char *) mxMalloc((mxGetNumberOfElements(notesi)+1)*sizeof(char));57 notes=(char *) xmalloc((mxGetNumberOfElements(notesi)+1)*sizeof(char)); 58 58 mxGetString(notesi,notes,mxGetNumberOfElements(notesi)+1); 59 59 } 60 60 else { 61 61 /* note that strlen does not include trailing null */ 62 notes=(char *) mxRealloc(notes,(strlen(notes)+1+mxGetNumberOfElements(notesi)+1)*sizeof(char));62 notes=(char*)xrealloc(notes,(strlen(notes)+1+mxGetNumberOfElements(notesi)+1)*sizeof(char)); 63 63 strcat(notes,"\n"); 64 64 mxGetString(notesi,¬es[strlen(notes)],mxGetNumberOfElements(notesi)+1); -
TabularUnified issm/trunk-jpl/src/modules/MeshPartition/MeshPartition.cpp ¶
r12050 r12060 74 74 75 75 /*Post process node_partitioning and element_partitioning to be in double format. Metis needed them in int* format: */ 76 element_partitioning=(double*) mxMalloc(numberofelements*sizeof(double));76 element_partitioning=(double*)xmalloc(numberofelements*sizeof(double)); 77 77 for (i=0;i<numberofelements;i++){ 78 78 element_partitioning[i]=(double)int_element_partitioning[i]+1; //Metis indexing from 0, matlab from 1. 79 79 } 80 80 81 node_partitioning=(double*) mxMalloc(numberofvertices*sizeof(double));81 node_partitioning=(double*)xmalloc(numberofvertices*sizeof(double)); 82 82 for (i=0;i<numberofvertices;i++){ 83 83 node_partitioning[i]=(double)int_node_partitioning[i]+1; //Metis indexing from 0, matlab from 1. -
TabularUnified issm/trunk-jpl/src/modules/MeshProfileIntersection/MeshProfileIntersection.cpp ¶
r12050 r12060 55 55 FetchData(&double_index,&nel,&dummy,INDEX); 56 56 if(dummy!=3 && dummy!=6)_error_(" element triangulation should be of 3 or 6 column width!"); 57 index=(int*) mxMalloc(nel*3*sizeof(int));57 index=(int*)xmalloc(nel*3*sizeof(int)); 58 58 for(i=0;i<nel;i++){ 59 59 for(j=0;j<3;j++){ … … 67 67 //contours 68 68 numcontours=mxGetNumberOfElements(matlabstructure); 69 contours=(Contour**) mxMalloc(numcontours*sizeof(Contour*));69 contours=(Contour**)xmalloc(numcontours*sizeof(Contour*)); 70 70 for(i=0;i<numcontours;i++){ 71 71 //allocate 72 contouri=(Contour*) mxMalloc(sizeof(Contour));72 contouri=(Contour*)xmalloc(sizeof(Contour)); 73 73 //retrieve dimension of this contour. 74 74 contouri->nods=(int)mxGetScalar(mxGetField(matlabstructure,i,"nods")); -
TabularUnified issm/trunk-jpl/src/modules/TriMeshProcessRifts/TriMeshProcessRifts.cpp ¶
r12050 r12060 74 74 nel=mxGetM(prhs[0]); 75 75 tindex_in=mxGetPr(prhs[0]); 76 index_in=(double*) mxMalloc(nel*3*sizeof(double));76 index_in=(double*)xmalloc(nel*3*sizeof(double)); 77 77 for (i=0;i<nel;i++){ 78 78 for (j=0;j<3;j++){ … … 90 90 nods=mxGetM(prhs[1]); 91 91 x_inm=mxGetPr(prhs[1]); 92 x_in=(double*) mxMalloc(nods*sizeof(double));92 x_in=(double*)xmalloc(nods*sizeof(double)); 93 93 for (i=0;i<nods;i++){ 94 94 x_in[i]=x_inm[i]; … … 103 103 if(mxIsDouble(prhs[2])){ 104 104 y_inm=mxGetPr(prhs[2]); 105 y_in=(double*) mxMalloc(nods*sizeof(double));105 y_in=(double*)xmalloc(nods*sizeof(double)); 106 106 for (i=0;i<nods;i++){ 107 107 y_in[i]=y_inm[i]; … … 117 117 num_seg=mxGetM(prhs[3]); 118 118 tsegments_in=mxGetPr(prhs[3]); 119 segments_in=(double*) mxMalloc(num_seg*3*sizeof(double));119 segments_in=(double*)xmalloc(num_seg*3*sizeof(double)); 120 120 for (i=0;i<num_seg;i++){ 121 121 for (j=0;j<3;j++){ … … 132 132 if(mxIsDouble(prhs[4])){ 133 133 tsegmentmarkers_in=mxGetPr(prhs[4]); 134 segmentmarkers_in=(double*) mxMalloc(num_seg*sizeof(double));134 segmentmarkers_in=(double*)xmalloc(num_seg*sizeof(double)); 135 135 for (i=0;i<num_seg;i++){ 136 136 segmentmarkers_in[i]=tsegmentmarkers_in[i]; … … 270 270 pmxa_array2= mxCreateDoubleMatrix(0,0,mxREAL); 271 271 mxSetM(pmxa_array2,1); 272 pair=(double*) mxMalloc(2*sizeof(double));272 pair=(double*)xmalloc(2*sizeof(double)); 273 273 pair[0]=*(out_riftstips+2*i+0); 274 274 pair[1]=*(out_riftstips+2*i+1); … … 293 293 294 294 /*State: */ 295 state=(double*) mxMalloc(out_riftsnumpenaltypairs[i]*sizeof(double));295 state=(double*)xmalloc(out_riftsnumpenaltypairs[i]*sizeof(double)); 296 296 for(j=0;j<out_riftsnumpenaltypairs[i];j++)state[j]=FreeEnum; 297 297 pmxa_array2= mxCreateDoubleMatrix(0,0,mxREAL); … … 306 306 else{ 307 307 /*output NaN :*/ 308 pNaN=(double*) mxMalloc(sizeof(double));308 pNaN=(double*)xmalloc(sizeof(double)); 309 309 *pNaN=NAN; 310 310 pmxa_array= mxCreateDoubleMatrix(0,0,mxREAL); -
TabularUnified issm/trunk-jpl/src/modules/TriMeshRefine/TriMeshRefine.cpp ¶
r12050 r12060 65 65 nel=mxGetM(prhs[0]); 66 66 tindex_in=mxGetPr(prhs[0]); 67 index_in=(double*) mxMalloc(nel*3*sizeof(double));67 index_in=(double*)xmalloc(nel*3*sizeof(double)); 68 68 for (i=0;i<nel;i++){ 69 69 for (j=0;j<3;j++){ … … 81 81 nods=mxGetM(prhs[1]); 82 82 x_inm=mxGetPr(prhs[1]); 83 x_in=(double*) mxMalloc(nods*sizeof(double));83 x_in=(double*)xmalloc(nods*sizeof(double)); 84 84 for (i=0;i<nods;i++){ 85 85 x_in[i]=x_inm[i]; … … 94 94 if(mxIsDouble(prhs[2])){ 95 95 y_inm=mxGetPr(prhs[2]); 96 y_in=(double*) mxMalloc(nods*sizeof(double));96 y_in=(double*)xmalloc(nods*sizeof(double)); 97 97 for (i=0;i<nods;i++){ 98 98 y_in[i]=y_inm[i]; … … 108 108 num_seg=mxGetM(prhs[3]); 109 109 tsegments_in=mxGetPr(prhs[3]); 110 segments_in=(double*) mxMalloc(num_seg*3*sizeof(double));110 segments_in=(double*)xmalloc(num_seg*3*sizeof(double)); 111 111 for (i=0;i<num_seg;i++){ 112 112 for (j=0;j<3;j++){ … … 123 123 if(mxIsDouble(prhs[4])){ 124 124 tsegmentmarkers_in=mxGetPr(prhs[4]); 125 segmentmarkers_in=(double*) mxMalloc(num_seg*sizeof(double));125 segmentmarkers_in=(double*)xmalloc(num_seg*sizeof(double)); 126 126 for (i=0;i<num_seg;i++){ 127 127 segmentmarkers_in[i]=tsegmentmarkers_in[i]; … … 152 152 mexErrMsgTxt(" "); 153 153 } 154 order = (char *) mxMalloc((mxGetN(prhs[6])+1)*sizeof(char));154 order = (char *) xmalloc((mxGetN(prhs[6])+1)*sizeof(char)); 155 155 mxGetString(prhs[6],order,mxGetN(prhs[6])+1); 156 156 } … … 186 186 in.numberofcorners=3; 187 187 188 in.trianglelist = (int *) mxMalloc(3*in.numberoftriangles * sizeof(int));188 in.trianglelist = (int *) xmalloc(3*in.numberoftriangles * sizeof(int)); 189 189 for(i=0;i<in.numberoftriangles;i++){ 190 190 for(j=0;j<3;j++){ … … 192 192 } 193 193 } 194 in.triangleattributelist = (REAL *) mxMalloc(in.numberoftriangles * in.numberoftriangleattributes * sizeof(REAL));194 in.triangleattributelist = (REAL *) xmalloc(in.numberoftriangles * in.numberoftriangleattributes * sizeof(REAL)); 195 195 for(i=0;i<in.numberoftriangles;i++){ 196 196 in.triangleattributelist[i]=0.0; 197 197 } 198 in.trianglearealist = (REAL *) mxMalloc(in.numberoftriangles * sizeof(REAL));198 in.trianglearealist = (REAL *) xmalloc(in.numberoftriangles * sizeof(REAL)); 199 199 for(i=0;i<in.numberoftriangles;i++){ 200 200 in.trianglearealist[i]=area[i]; … … 203 203 in.numberofpoints=nods; 204 204 in.numberofpointattributes=1; 205 in.pointlist = (REAL *) mxMalloc(in.numberofpoints * 2 * sizeof(REAL));205 in.pointlist = (REAL *) xmalloc(in.numberofpoints * 2 * sizeof(REAL)); 206 206 for (i=0;i<nods;i++){ 207 207 in.pointlist[2*i+0]=x_in[i]; 208 208 in.pointlist[2*i+1]=y_in[i]; 209 209 } 210 in.pointattributelist = (REAL *) mxMalloc(in.numberofpoints * in.numberofpointattributes * sizeof(REAL));210 in.pointattributelist = (REAL *) xmalloc(in.numberofpoints * in.numberofpointattributes * sizeof(REAL)); 211 211 for (i=0;i<nods;i++){ 212 212 in.pointattributelist[i] = 0.0; … … 214 214 215 215 in.numberofsegments = num_seg; 216 in.segmentlist = (int *) mxMalloc(in.numberofsegments * 2 * sizeof(REAL));216 in.segmentlist = (int *) xmalloc(in.numberofsegments * 2 * sizeof(REAL)); 217 217 in.segmentmarkerlist = (int *) mxCalloc(in.numberofsegments,sizeof(int)); 218 218 for (i=0;i<num_seg;i++){ … … 250 250 251 251 /*Allocate index, x and y: */ 252 index=(double*) mxMalloc(3*out.numberoftriangles*sizeof(double));253 x=(double*) mxMalloc(out.numberofpoints*sizeof(double));254 y=(double*) mxMalloc(out.numberofpoints*sizeof(double));255 segments=(double*) mxMalloc(3*out.numberofsegments*sizeof(double));256 segmentmarkerlist=(double*) mxMalloc(out.numberofsegments*sizeof(double));252 index=(double*)xmalloc(3*out.numberoftriangles*sizeof(double)); 253 x=(double*)xmalloc(out.numberofpoints*sizeof(double)); 254 y=(double*)xmalloc(out.numberofpoints*sizeof(double)); 255 segments=(double*)xmalloc(3*out.numberofsegments*sizeof(double)); 256 segmentmarkerlist=(double*)xmalloc(out.numberofsegments*sizeof(double)); 257 257 258 258 for (i = 0; i < out.numberoftriangles; i++) {
Note:
See TracChangeset
for help on using the changeset viewer.