public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c/4713: syntax error on #include commands
@ 2001-10-27 14:29 neil
0 siblings, 0 replies; 2+ messages in thread
From: neil @ 2001-10-27 14:29 UTC (permalink / raw)
To: dllau, gcc-bugs, gcc-prs, nobody
Synopsis: syntax error on #include commands
State-Changed-From-To: open->closed
State-Changed-By: neil
State-Changed-When: Sat Oct 27 14:29:52 2001
State-Changed-Why:
Please don't use high priority - it is reserved for GCC maintainers.
This is not a bug; #include directives must be on their
own line, and your file seems to have few, if any, line
breaks.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&pr=4713&database=gcc
^ permalink raw reply [flat|nested] 2+ messages in thread
* c/4713: syntax error on #include commands
@ 2001-10-27 14:16 dllau
0 siblings, 0 replies; 2+ messages in thread
From: dllau @ 2001-10-27 14:16 UTC (permalink / raw)
To: gcc-gnats
>Number: 4713
>Category: c
>Synopsis: syntax error on #include commands
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Oct 27 14:15:59 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Dr. Daniel L. Lau
>Release: 2.95.2 200002200 (Debian/GNU Linux)
>Organization:
>Environment:
PC running Linux
>Description:
bippcca: #include expects "FILENAME" or <FILENAME>
>How-To-Repeat:
just run using the gcc bippcca.c command
>Fix:
don't have one yet
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="bippcca.c"
Content-Disposition: inline; filename="bippcca.c"
/****************************************************************************************/\r/* */\r/* Daniel Leo Lau */\r/* Copyright February 14, 1998 */\r/* */\r/****************************************************************************************/ \r\r#include <stdlib.h>\r#include <math.h>\r#include "mex.h"\r\r#define pi 3.14159265358979\r#define TOL 1e-32\r#define max_num_pts 65536\r\rdouble *K_data;\rdouble *H_data;\rdouble VAR;\r\rint image_row;\rint image_col;\rint K_flag;\rint H_flag;\r\rint num_K_points;\rint num_H_points;\rint tot_num_ones;\rint max_pixel_list[max_num_pts];\rint num_pixels_in_list;\r\rtypedef struct { \r double row;\r double col;\r double cost;\r double angle;\r double fr;\r} cost_array_node;\r\r/********************************************************************************/\r/* */\r/********************************************************************************/\rdouble interp(double *Fx, double *x, int length_list, double s)\r{\r int m;\r double slope;\r\r for (m=0; m<length_list-1; m++){\r if ((x[m]<=s)&&(x[m+1]>s)){\r slope=(Fx[m]-Fx[m+1])/(x[m]-x[m+1]);\r return(Fx[m]+slope*(s-x[m]));\r }\r }\r return(1.0);\r}\r\r/********************************************************************************/\r/* */\r/********************************************************************************/\rvoid hpsort_cost_array(int n, cost_array_node *ra)\r{\r int i, ir, j, l;\r cost_array_node rra;\r\r if (n<2) return;\r l=(n >> 1)+1;\r ir=n;\r\r for( ; ; ){\r if (l>1){\r --l;\r rra=ra[l-1];\r }\r else {\r rra=ra[ir-1];\r ra[ir-1]=ra[0];\r if (--ir==1){\r ra[0]=rra;\r break;\r }\r }\r i=l;\r j=l+l;\r while(j<=ir){\r if (j < ir && ra[j-1].cost < ra[j].cost)j++;\r if (rra.cost < ra[j-1].cost){\r ra[i-1]=ra[j-1];\r i=j;\r j<<=1;\r }\r else j=ir+1;\r }\r ra[i-1]=rra;\r }\r return;\r}\r\r/********************************************************************************/\r/* */\r/********************************************************************************/\rint find_max_pixel(double *cost_matrix)\r{\r int m;\r double K, *pr;\r\r mxArray *array_ptr, *input_array[1];\r\r num_pixels_in_list=0;\r for (m=0; m<image_row*image_col; m++){\r if (cost_matrix[m]>TOL){\r if (num_pixels_in_list==0){\r num_pixels_in_list=1;\r max_pixel_list[0]=m;\r }\r else if (cost_matrix[m]>cost_matrix[max_pixel_list[0]]){\r num_pixels_in_list=1;\r max_pixel_list[0]=m;\r }\r else if (cost_matrix[m]==cost_matrix[max_pixel_list[0]]){\r max_pixel_list[num_pixels_in_list++]=m;\r if (num_pixels_in_list==max_num_pts) num_pixels_in_list=1;\r }\r }\r }\r if (num_pixels_in_list==0){\r array_ptr = mxCreateDoubleMatrix(image_row, image_col, mxREAL);\r pr=mxGetPr(array_ptr);\r input_array[0]=array_ptr;\r for (m=0; m<image_row*image_col; m++){\r pr[m]=cost_matrix[m];\r }\r mxSetName(array_ptr, "cost_matrix");\r mexPutArray(array_ptr, "base");\r mexErrMsgTxt("ERROR CODE 0: Improper pair correlation shaping function!");\r }\r m=max_pixel_list[(int)floor((double)rand()/(double)RAND_MAX*(double)num_pixels_in_list)];\r return(m);\r}\r\r/********************************************************************************/\r/* */\r/********************************************************************************/\rvoid create_cost_array0(cost_array_node **cost_array)\r{\r int i, j, m, n, index;\r\r m=-image_row/2+1;\r n=-image_col/2+1;\r for (j=0; j<image_col; j++){\r for (i=0; i<image_row; i++){\r index=i+j*image_row;\r (*cost_array)[index].row=m+i;\r (*cost_array)[index].col=n+j;\r }\r }\r return;\r}\r\r/********************************************************************************/\r/* */\r/********************************************************************************/\rvoid create_cost_array1(cost_array_node **cost_array)\r{\r int i,j,m,n, index;\r double d, *pr, ang;\r mxArray *array_ptr;\r\r array_ptr = mxCreateDoubleMatrix(image_row, image_col, mxREAL);\r pr=mxGetPr(array_ptr);\r\r m=-image_row/2+1;\r n=-image_col/2+1;\r for (j=0; j<image_col; j++){\r for (i=0; i<image_row; i++){\r index=i+j*image_row;\r (*cost_array)[index].row=m+i;\r (*cost_array)[index].col=n+j;\r (*cost_array)[index].cost=sqrt((m+i)*(m+i)+(n+j)*(n+j));\r (*cost_array)[index].angle=atan2(-1.0*(m+i), (n+j));\r if (K_flag==1)\r (*cost_array)[index].fr=interp(&K_data[0], &K_data[num_K_points], num_K_points,\r (*cost_array)[index].cost);\r else if (K_flag==2)\r (*cost_array)[index].fr=K_data[index];\r pr[index]=(*cost_array)[index].fr;\r }\r }\r hpsort_cost_array(image_row*image_col, *cost_array);\r mxSetName(array_ptr, "shaping_filter1");\r mexPutArray(array_ptr, "base");\r return;\r}\r\r/********************************************************************************/\r/* */\r/********************************************************************************/\rvoid create_cost_array2(cost_array_node **cost_array)\r{\r int i,j,m,n,index;\r double d, *pr, ang, cost, sum=0.0;\r mxArray *array_ptr;\r\r array_ptr = mxCreateDoubleMatrix(image_row, image_col, mxREAL);\r pr=mxGetPr(array_ptr);\r\r m=-image_row/2+1;\r n=-image_col/2+1;\r for (j=0; j<image_col; j++){\r for (i=0; i<image_row; i++){\r index=i+j*image_row;\r (*cost_array)[index].row=m+i;\r (*cost_array)[index].col=n+j;\r (*cost_array)[index].cost=sqrt((m+i)*(m+i)+(n+j)*(n+j));\r (*cost_array)[index].angle=atan2(-1.0*(m+i), (n+j));\r if (H_flag==1)\r (*cost_array)[index].fr=interp(&H_data[0], &H_data[num_H_points], num_H_points,\r (*cost_array)[index].cost);\r else if (H_flag==2){\r (*cost_array)[index].fr=exp(-1.0 * (*cost_array)[index].cost*\r (*cost_array)[index].cost*\r (1.0/VAR/VAR));\r sum+=(*cost_array)[i+j*image_row].fr;\r }\r else if (H_flag==3)\r (*cost_array)[index].fr=H_data[index];\r pr[index]=(*cost_array)[index].fr;\r }\r }\r if (H_flag==2)\r for (j=0; j<image_row*image_col; j++){\r (*cost_array)[j].fr*=(1.0/sum);\r }\r hpsort_cost_array(image_row*image_col, *cost_array);\r mxSetName(array_ptr, "shaping_filter2");\r mexPutArray(array_ptr, "base");\r return;\r}\r\r/********************************************************************************/\r/* */\r/********************************************************************************/\rint in_list(int M)\r{\r int m;\r\r for (m=0; m<num_pixels_in_list; m++){\r if (max_pixel_list[m]==M) return(1);\r }\r return(0);\r}\r\r/********************************************************************************/\r/* */\r/********************************************************************************/\rvoid calc_cost_matrix1(double *cost_matrix, cost_array_node *cost_array, int i, int j)\r{\r int m, x_coor, y_coor, index, k, n;\r\r index=i+j*image_row;\r cost_matrix[index]=0.0;\r for (m=0; m<image_row*image_col; m++){\r x_coor=i+cost_array[m].row;\r y_coor=j+cost_array[m].col;\r\r if (x_coor<0) x_coor+=image_row;\r else if (x_coor>=image_row) x_coor-=image_row;\r if (y_coor<0) y_coor+=image_col;\r else if (y_coor>=image_col) y_coor-=image_col;\r\r index=x_coor+y_coor*image_row;\r cost_matrix[index]*=cost_array[m].fr;\r }\r return;\r}\r\r/********************************************************************************/\r/* */\r/********************************************************************************/\rvoid calc_cost_matrix2(double *cost_matrix, cost_array_node *cost_array, int i, int j)\r{\r int m, x_coor, y_coor, M, k, n;\r\r for (m=0; m<image_row*image_col; m++){\r x_coor=i+cost_array[m].row;\r y_coor=j+cost_array[m].col;\r\r if (x_coor<0) x_coor+=image_row;\r else if (x_coor>=image_row) x_coor-=image_row;\r if (y_coor<0) y_coor+=image_col;\r else if (y_coor>=image_col) y_coor-=image_col;\r\r M=x_coor+y_coor*image_row;\r cost_matrix[M]+=cost_array[m].fr;\r }\r return;\r}\r\r/********************************************************************************/\r/* */\r/********************************************************************************/\rvoid bippcca(unsigned char *output_image,\r unsigned char *input_image, \r unsigned char *mask_image)\r{\r int m, i, j, k=0;\r double *cost_matrix1, *cost_matrix2, *cost_matrix3, *pr, pmin, pmax;\r cost_array_node *cost_array1, *cost_array2;\r mxArray *array_ptr, *output_array[1], *input_array[1];\r\r array_ptr = mxCreateDoubleMatrix(image_row, image_col, mxREAL);\r pr=mxGetPr(array_ptr);\r input_array[0]=array_ptr;\r\r cost_array1=(cost_array_node*)mxCalloc(image_row*image_col, sizeof(cost_array_node)); \r create_cost_array1(&cost_array1);\r cost_matrix1=(double*)mxCalloc(image_row*image_col, sizeof(double));\r \r if (H_flag!=0){\r cost_array2=(cost_array_node*)mxCalloc(image_row*image_col, sizeof(cost_array_node));\r create_cost_array2(&cost_array2);\r cost_matrix2=(double*)mxCalloc(image_row*image_col, sizeof(double));\r cost_matrix3=(double*)mxCalloc(image_row*image_col, sizeof(double));\r }\r \r for (m=0; m<image_row*image_col; m++){\r if (mask_image[m]==(unsigned char)0){\r cost_matrix1[m]=(double)rand()/(double)RAND_MAX;\r }\r else\r cost_matrix1[m]=-1.0;\r }\r for (i=0; i<image_row; i++){\r for (j=0; j<image_col; j++){\r if (input_image[i+j*image_row]==1){\r output_image[i+j*image_row]=1;\r calc_cost_matrix1(cost_matrix1, cost_array1, i, j);\r if (H_flag!=0) calc_cost_matrix2(cost_matrix2, cost_array2, i, j);\r k++;\r }\r }\r }\r \r while(k<tot_num_ones){\r if (H_flag!=0){\r pmin=cost_matrix2[0];\r pmax=cost_matrix2[0];\r for (j=0; j<image_row*image_col; j++){\r if (pmin > cost_matrix2[j]) pmin=cost_matrix2[j];\r if (pmax < cost_matrix2[j]) pmax=cost_matrix2[j];\r }\r if (pmax==0)\r for (j=0; j<image_row*image_col; j++){\r cost_matrix3[j]=cost_matrix1[j];\r }\r else\r for (j=0; j<image_row*image_col; j++){\r cost_matrix3[j]=1.0-(cost_matrix2[j]-pmin)/(pmax-pmin);\r cost_matrix3[j]*=cost_matrix1[j];\r }\r m=find_max_pixel(cost_matrix3);\r }\r else\r m=find_max_pixel(cost_matrix1);\r i=m%image_row;\r j=(m-i)/image_row;\r if (mask_image[i+j*image_row]==1){\r mexPrintf("M=%d, N=%d, COST=%f\n", i+1, j+1, cost_matrix3[i+j*image_row]);\r for (m=0; m<image_row*image_col; m++){\r pr[m]=(double)output_image[m];\r }\r /*mexCallMATLAB(0, output_array, 1, input_array, "imagesc");\r mexCallMATLAB(0, output_array, 0, input_array, "drawnow");*/\r mxSetName(array_ptr, "cost_matrix");\r mexPutArray(array_ptr, "base");\r mexErrMsgTxt("ERROR CODE 1!");}\r output_image[i+j*image_row]=1;\r calc_cost_matrix1(cost_matrix1, cost_array1, i, j);\r if (H_flag!=0) calc_cost_matrix2(cost_matrix2, cost_array2, i, j);\r k++;\r /*for (m=0; m<image_row*image_col; m++){\r pr[m]=(double)output_image[m];\r }\r mexCallMATLAB(0, output_array, 1, input_array, "imagesc");\r mexCallMATLAB(0, output_array, 0, input_array, "drawnow");\r mxSetName(array_ptr, "cost_matrix");\r mexPutArray(array_ptr, "base");*/\r }\r\r return;\r}\r\r/********************************************************************************/\r/* */\r/********************************************************************************/\rvoid GetRowColCooridinates(double row_pointer[], double col_pointer[])\r{\r int m, x_coor, y_coor;\r cost_array_node *cost_array;\r\r cost_array=(cost_array_node*)mxCalloc(image_row*image_col, sizeof(cost_array_node)); \r create_cost_array0(&cost_array);\r for (m=0; m<image_row*image_col; m++){\r x_coor=cost_array[m].row+image_row/2-1;\r y_coor=cost_array[m].col+image_col/2-1;\r row_pointer[x_coor+y_coor*image_row]=cost_array[m].row;\r col_pointer[x_coor+y_coor*image_row]=cost_array[m].col;\r }\r return;\r}\r\r/********************************************************************************/\r/* */\r/********************************************************************************/\rint mxIsScalar(const mxArray *input_array)\r{\r return(mxGetM(input_array)==1 && mxGetN(input_array)==1);\r}\r\r/********************************************************************************/\r/* */\r/********************************************************************************/\rint mxIsVector(const mxArray *input_array)\r{\r return((mxGetM(input_array)==1 && mxGetN(input_array)!=1) || \r (mxGetM(input_array)!=1 && mxGetN(input_array)==1));\r}\r\r/********************************************************************************/\r/* */\r/********************************************************************************/\rint mxIsMatrix(const mxArray *input_array)\r{\r return((mxGetM(input_array)!=1 && mxGetN(input_array)!=1));\r}\r\r/*******************************************************************************/ \r/* mexFUNCTION */\r/* Gateway routine for use with MATLAB. */\r/*******************************************************************************/ \rvoid mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])\r{\r unsigned char *input_image, *output_image, *mask_image;\r double gray_level, *row_pointer, *col_pointer, *image_size_data;\r int m, output_dims[2];\r \r\r /* ENSURE PROPER NUMBER OF ARGUMENTS SPECIFIED */\r if (!(nrhs==1 && nlhs==2) &&\r !(nrhs==3 && nlhs==1) &&\r !(nrhs==4 && nlhs==1) &&\r !(nrhs==5 && nlhs==1))\r mexErrMsgTxt("Improper number of arguments!");\r\r /* HANDLE THE FIRST INPUT ARGUMENT AS A BINARY IMAGE OR AS A VECTOR */\r /* SPECIFYING THE DIMENSIONS OF THE OUTPUT IMAGE */\r if (mxIsMatrix(prhs[0])){\r if (!mxIsNumeric(prhs[0]) ||\r mxIsComplex(prhs[0]) ||\r mxIsSparse(prhs[0]) ||\r !mxIsUint8(prhs[0]) ||\r !mxIsLogical(prhs[0])) \r mexErrMsgTxt("Input X must be a real matrix of type uint8 (logical)!");\r else {\r image_row=mxGetM(prhs[0]);\r image_col=mxGetN(prhs[0]);\r input_image=(unsigned char*)mxGetPr(prhs[0]);\r }\r }\r else if ((mxGetM(prhs[0])*mxGetN(prhs[0]))==2){\r if (!mxIsNumeric(prhs[0]) ||\r mxIsComplex(prhs[0]) ||\r mxIsSparse(prhs[0]))\r mexErrMsgTxt("Input [M N] must be a real vector!");\r else {\r image_size_data=mxGetPr(prhs[0]);\r image_row=(int)image_size_data[0];\r image_col=(int)image_size_data[1];\r input_image=(unsigned char*)mxCalloc(image_row*image_col, sizeof(unsigned char));\r }\r }\r \r /* IF ONLY ONE INPUT ARGUMENT IS SPECIFIED ALONG WITH TWO OUTPUT ARGUMENTS */\r /* THEN OUTPUT THE ROW AND COLUMN COORIDINATES FOR THE SHAPING FUNCTION */\r if (nrhs==1 && nlhs==2){\r plhs[0]=mxCreateDoubleMatrix(image_row, image_col, mxREAL);\r row_pointer=mxGetPr(plhs[0]);\r plhs[1]=mxCreateDoubleMatrix(image_row, image_col, mxREAL);\r col_pointer=mxGetPr(plhs[1]);\r GetRowColCooridinates(row_pointer, col_pointer);\r return;\r }\r\r /* SET THE GRAY LEVEL FOR THE RESULTING OUTPUT PATTERN */ \r if (!mxIsNumeric(prhs[1]) ||\r mxIsComplex(prhs[1]) ||\r mxIsSparse(prhs[1]) ||\r !mxIsScalar(prhs[1]))\r mexErrMsgTxt("Input g must be a real scalar!");\r else { \r gray_level=mxGetScalar(prhs[1]);\r if (gray_level<=0)\r mexErrMsgTxt("Input g must be greater than 1!");\r else if (gray_level < 0.5)\r tot_num_ones=(int)floor(image_row*image_col*gray_level+0.5);\r else if (gray_level < 1.0 && gray_level >= 0.5)\r tot_num_ones=(int)floor(image_row*image_col*(1.0-gray_level)+0.5);\r else\r tot_num_ones=(int)floor(gray_level);\r }\r\r /* SPECIFY THE SHAPING FUNCTION K*/\r if (mxGetN(prhs[2])==2){\r K_flag=1;\r if (!mxIsNumeric(prhs[2]) ||\r mxIsComplex(prhs[2]) ||\r mxIsSparse(prhs[2]))\r mexErrMsgTxt("Input [K, r] must be a real matrix!");\r num_K_points=mxGetM(prhs[2]);\r K_data=mxGetPr(prhs[2]);\r }\r else if (mxIsMatrix(prhs[2])){\r K_flag=2;\r if (!mxIsNumeric(prhs[2]) ||\r mxIsComplex(prhs[2]) ||\r mxIsSparse(prhs[2])) \r mexErrMsgTxt("Input K must be a real matrix of type double!");\r if (mxGetM(prhs[2])!=image_row || mxGetN(prhs[2])!=image_col)\r mexErrMsgTxt("Input K must be same size as H!");\r K_data=mxGetPr(prhs[2]);\r }\r else mexErrMsgTxt("Input K must be a matrix of type double!");\r\r /* SPECIFY THE STATIONARY FILTER Hlp*/\r if (nrhs>3 && !(mxGetN(prhs[3])*mxGetM(prhs[3])==0)){\r if (mxGetN(prhs[3])==2 && mxGetM(prhs[3])>1){\r H_flag=1;\r if (!mxIsNumeric(prhs[3]) ||\r mxIsComplex(prhs[3]) ||\r mxIsSparse(prhs[3]))\r mexErrMsgTxt("Input [Hlp, r] must be a real matrix!");\r num_H_points=mxGetM(prhs[2]);\r }\r else if (mxIsScalar(prhs[3])){\r H_flag=2;\r if (!mxIsNumeric(prhs[3]) ||\r mxIsComplex(prhs[3]) ||\r mxIsSparse(prhs[3])) \r mexErrMsgTxt("Input Hlp must be a scalar of type double!");\r VAR=mxGetScalar(prhs[3]);\r }\r else if (mxIsMatrix(prhs[3])){\r H_flag=3;\r if (!mxIsNumeric(prhs[3]) ||\r mxIsComplex(prhs[3]) ||\r mxIsSparse(prhs[3])) \r mexErrMsgTxt("Input Hlp must be a real matrix of type double!");\r if (mxGetM(prhs[3])!=image_row || mxGetN(prhs[2])!=image_col)\r mexErrMsgTxt("Input Hlp must be same size as H!");\r H_data=mxGetPr(prhs[3]);\r }\r else mexErrMsgTxt("Input Hlp must be a matrix of type double!");\r }\r else {\r H_flag=0;\r }\r\r /* SPECIFY THE MASK M */\r if (nrhs==5){\r if (!mxIsNumeric(prhs[4]) ||\r mxIsComplex(prhs[4]) ||\r mxIsSparse(prhs[4]) ||\r !mxIsUint8(prhs[4]) ||\r !mxIsLogical(prhs[4])) \r mexErrMsgTxt("Input M must be a real matrix of type uint8 (logical)!");\r if (mxGetM(prhs[4])!=image_row || mxGetN(prhs[4])!=image_col)\r mexErrMsgTxt("Input M must be same size as H!");\r mask_image=(unsigned char*)mxGetPr(prhs[4]);\r }\r else mask_image=(unsigned char*)mxCalloc(image_row*image_col, sizeof(unsigned char));\r\r output_dims[0]=image_row; output_dims[1]=image_col;\r plhs[0]=mxCreateNumericArray(2, output_dims, mxUINT8_CLASS, mxREAL);\r mxSetLogical(plhs[0]);\r output_image=(unsigned char*)mxGetPr(plhs[0]);\r bippcca(output_image, input_image, mask_image);\r if (gray_level < 1.0 && gray_level > 0.5){\r for (m=0; m<image_row*image_col; m++){\r output_image[m]=!output_image[m];\r }\r }\r return;\r}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-10-27 14:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-27 14:29 c/4713: syntax error on #include commands neil
-- strict thread matches above, loose matches on Subject: below --
2001-10-27 14:16 dllau
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).