float eval_branch(struct node *node, float x, float y, float z, float a) { switch (node->token) { case token_x: return x; case token_y: return y; case token_z: return z; case token_a: return a; case token_num: return node->value; case token_pow: return func_pow(eval_branch(node->left, x, y, z, a), node->value); case token_mul: return func_mul(eval_branch(node->left, x, y, z, a), eval_branch(node->right, x, y, z, a)); case token_div: return func_div(eval_branch(node->left, x, y, z, a), eval_branch(node->right, x, y, z, a)); case token_add: return func_add(eval_branch(node->left, x, y, z, a), eval_branch(node->right, x, y, z, a)); case token_sub: return func_sub(eval_branch(node->left, x, y, z, a), eval_branch(node->right, x, y, z, a)); case token_neg: return func_neg(0, eval_branch(node->right, x, y, z, a)); case token_sqrt: return func_sqrt(0, eval_branch(node->right, x, y, z, a)); case token_sin: return func_sin(0, eval_branch(node->right, x, y, z, a)); case token_cos: return func_cos(0, eval_branch(node->right, x, y, z, a)); default: return 0; } }
func_t *func_diff_atanh_pow1(func_t *f, int var) { func_t *fx=NULL,*g=NULL,*gx=NULL,*h=NULL; if(!func_is(f,"atanh") || func_power(f)!=1){ FUNC_ERROR_ARG1("func_diff_atanh",f); } g=f->a[0]; gx=func_diff(FR(g),func_var1(var,1)); h=func_pow_n(FR(g),2); h=func_sub(func_one(),h); fx=func_div(gx,h); f=func_del(f); return fx; }
void main() { int a,b,add,sub; clock_t start,stop,over_time; a = 200; b = 100; start = clock(); add = func_add(a,b); sub = func_sub(a,b); stop = clock(); printf("\na+b = %d, a-b = %d, time=%d\n",add,sub,stop-start); }