version 1.4, 2018/04/06 10:44:51 |
version 1.7, 2018/04/18 08:31:51 |
|
|
/* $OpenXM: OpenXM/src/ox_gsl/ox_eval.c,v 1.3 2018/04/05 13:02:39 ohara Exp $ */ |
/* $OpenXM: OpenXM/src/ox_gsl/ox_eval.c,v 1.6 2018/04/17 02:50:07 ohara Exp $ */ |
|
|
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
Line 50 static double op_negative(double x) |
|
Line 50 static double op_negative(double x) |
|
return -x; |
return -x; |
} |
} |
|
|
|
static double op_parentheses(double x) |
|
{ |
|
return x; |
|
} |
|
|
/* 定数は引数なしの関数として実現する。*/ |
/* 定数は引数なしの関数として実現する。*/ |
typedef struct { |
typedef struct { |
char *name; |
char *name; |
Line 90 entry global_dic[512] = { |
|
Line 95 entry global_dic[512] = { |
|
{"j1",0,j1,1}, |
{"j1",0,j1,1}, |
{"y0",0,y0,1}, |
{"y0",0,y0,1}, |
{"y1",0,y1,1}, |
{"y1",0,y1,1}, |
|
{"()", 0,op_parentheses,1}, |
{"-", 0,op_negative,1}, |
{"-", 0,op_negative,1}, |
{"+", 0,op_add,2}, |
{"+", 0,op_add,2}, |
{"-", 0,op_sub,2}, |
{"-", 0,op_sub,2}, |
Line 112 int register_entry(char *s, double v) |
|
Line 118 int register_entry(char *s, double v) |
|
{ |
{ |
entry *e = &local_dic[local_dic_counter]; |
entry *e = &local_dic[local_dic_counter]; |
if(local_dic_counter<LOCAL_DIC_SIZE-1) { |
if(local_dic_counter<LOCAL_DIC_SIZE-1) { |
e->name = s; |
e->name = (char *)malloc(strlen(s)+1); |
|
strcpy(e->name, s); |
e->v = v; |
e->v = v; |
e->f = NULL; |
e->f = NULL; |
local_dic_counter++; |
local_dic_counter++; |
return 1; |
return 1; |
} |
} |
Line 328 int eval_cmo(cmo *c, double *retval) |
|
Line 335 int eval_cmo(cmo *c, double *retval) |
|
{ |
{ |
int tag = c->tag; |
int tag = c->tag; |
switch(c->tag) { |
switch(c->tag) { |
|
case CMO_NULL: |
case CMO_ZERO: |
case CMO_ZERO: |
*retval = 0; |
*retval = 0; |
break; |
break; |