int main(){ /*------------------------------------------ *------------VARIÁVEIS GLOGBAIS------------ *------------------------------------------ */ a =(float *)malloc(7*sizeof(float)); a[0] = 1.0; a[1] = 0.0705230784; a[2] = 0.0422820123; a[3] = 0.0092705272; a[4] = 0.0001520143; a[5] = 0.0002765672; a[6] = 0.0000430638; alpha = 1.0; q = 1.0; Ti = 10; Tf = 50; x0 = 1 ; q = 1; /*------------------------------------------ *------------VARIÁVEIS LOCAIS------------ *------------------------------------------ */ float u, v, w; float a, b; int n, k; FILE *f_out; f_out = fopen("./data/9-2.dat", "w+"); n = 500; for(alpha = 1; alpha <=10; alpha += 0.5) { check_f(&a, &b); if(f(a)*f(b) >= 0) { printf("Método da Bisseção não aplicável! \n"); return(0); } u = a; v = b; for(k = 0; k < n; k++) { w = (u + v)/2.0; if(f(w) == 0) break; if(f(u)*f(w) < 0) v = w; else u = w; } if(k != 500)fprintf(f_out, "%f\t %f \t %d\n", alpha, w, k); } fclose(f_out); return(0); }
static int cdf_df (lua_State *L) { /* stack should contain f, dfn, dfd */ lua_Number f = luaL_checknumber(L, 1); lua_Number dfn = luaL_checknumber(L, 2); lua_Number dfd = luaL_checknumber(L, 3); lua_Number df1, df2, r, d; check_f(L, 1, f, dfn, dfd); df1 = dfn/2; df2 = dfd/2; r = dfn/dfd; d = df1*log(r)+(df1-1)*log(f); d -= (df1+df2)*log(1+r*f); d -= dlnbet(&df1, &df2); lua_pushnumber(L, exp(d)); return 1; }
static int cdf_pf (lua_State *L) { /* stack should contain f, dfn, dfd and opt. phonc */ lua_Number f = luaL_checknumber(L, 1); lua_Number dfn = luaL_checknumber(L, 2); lua_Number dfd = luaL_checknumber(L, 3); lua_Number phonc = luaL_optnumber(L, 4, 0); lua_Number p, q, bound; int which = 1; int status; check_f(L, 1, f, dfn, dfd); if (phonc == 0) /* central? */ cdff(&which, &p, &q, &f, &dfn, &dfd, &status, &bound); else /* non-central */ cdffnc(&which, &p, &q, &f, &dfn, &dfd, &phonc, &status, &bound); check_status(status, bound); lua_pushnumber(L, p); return 1; }
int main (int argc, char *argv[]) { if (argc > 1 && strcmp (argv[1], "-s") == 0) option_libc_scanf = 1; tests_start (); mp_trace_base = 16; check_z (); check_q (); check_f (); check_n (); check_misc (); unlink (TEMPFILE); tests_end (); exit (0); }
int main (int argc, char *argv[]) { if (argc > 1 && strcmp (argv[1], "-s") == 0) option_check_printf = 1; tests_start (); check_vfprintf_fp = fopen (CHECK_VFPRINTF_FILENAME, "w+"); ASSERT_ALWAYS (check_vfprintf_fp != NULL); check_z (); check_q (); check_f (); check_limb (); check_n (); check_misc (); ASSERT_ALWAYS (fclose (check_vfprintf_fp) == 0); unlink (CHECK_VFPRINTF_FILENAME); tests_end (); exit (0); }
static int cdf_qf (lua_State *L) { /* stack should contain p, dfn, dfd and opt. phonc */ lua_Number p = luaL_checknumber(L, 1); lua_Number dfn = luaL_checknumber(L, 2); lua_Number dfd = luaL_checknumber(L, 3); lua_Number phonc = luaL_optnumber(L, 4, 0); lua_Number f; check_f(L, 2, p, dfn, dfd); if (p==0 || p==1) f = (p==0) ? 0 : HUGE_VAL; else { lua_Number q = 1-p; lua_Number bound; int which = 2; int status; if (phonc == 0) /* central? */ cdff(&which, &p, &q, &f, &dfn, &dfd, &status, &bound); else /* non-central */ cdffnc(&which, &p, &q, &f, &dfn, &dfd, &phonc, &status, &bound); check_status(status, bound); } lua_pushnumber(L, f); return 1; }
void execution(int argc,char* argv[]) { int in=0 ,io=0 ,copy_flag=0 , flag_fname=0; char f[6]; in_len=argc; flag_h=0; flag_d=0; d_value=0; flag_f=0; for(in=0; in< in_len ;in++) { strcpy(input_arra[in],argv[in]); } // printf("val of srgasdc is %d \n",in_len); flag_f=check_f(in_len); flag_h=check_h(in_len); flag_d=check_d(in_len); // printf("h is %d\n",flag_h); if(flag_h == 1) { printf("help karo\n"); return ; } if(in_len < 2) { printf("\n usage ./a.out inputfile<test.cap>\n"); return ; } if(flag_d == 0) { strcpy(inputfile,argv[in_len-1]); } else { d_value=atoi(argv[in_len-1]); //printf("d_value is %d \n\n",d_value); strcpy(inputfile,argv[in_len-3]); } //check filename exists or not //printf("filename is %s",inputfile); flag_fname=check_filename(); if(flag_fname == 1 ) { printf("\n input file name is wrong\n"); return; } for(in=0;in<30;in++) strcpy(runtimecmd[in]," "); cmd_flag=0; int len=0; //printf("number is %d \n\n",in_len); if(flag_d==1) len=in_len-3; else len=in_len-1; if(flag_f != 0) { cmd_flag=1; // printf("cmd is jgjnade %d us %d jhkj \n",flag_f,in_len); io=0; for(in=flag_f;in<len;in++) { //printf("insied "); strcpy(runtimecmd[io],input_arra[in]); io++; } // for(in=0;in<in_len;in++) // printf("runtime is %s ",runtimecmd[in]); }// printf("\n"); int ret, check_ret=0; check_ret=get_data(); //return 1; if(check_ret==1) return; int checkt =-1, checkf=0; int checkfst=0; //number of words in input int inputsize=in_len; strcpy(user_input,input_arra[1]); printdata(); while(1) { //printf("inside while"); checkt=-1; checkf=0; //checkf=check_f(inputsize); if(checkfst==1) { strcpy(user_input,""); //checkfst=1; printf(" \n enter the new commnad \n "); //scanf(" %s ",input_value); int j=0,m=0; for(m=0;m<100;m++) { for(j=0;j<100;j++) input_arra[m][j]='\0'; } char c; for (m=0;m<100;) { for(j=0;j<100;j++) { scanf("%c",&c); if(c==' ') { m++; break; } if(c=='\n') break; input_arra[m][j]=c; } if(c=='\n')break; } inputsize=m; //for( j=0;j<=m;j++) // printf("in put is %s \n",input_arra[j]); strcpy(user_input,input_arra[0]); } checkt=check_t(inputsize); if(!strcmp(user_input,"exit")) break; else if(!strcmp(user_input,"help")) { printf("\n am in help \n"); } else if(checkt !=-1 && checkfst == 1) { // printf("t is present at pos %ddsf and in put size is %d \n",checkt , inputsize); testcase(checkt,inputsize); } else { if(checkfst==1) { printf("wrong command entered \n"); } } checkfst=1; } }