version 1.5, 2018/04/13 16:51:42 |
version 1.7, 2018/04/18 08:31:51 |
|
|
/* $OpenXM: OpenXM/src/ox_gsl/ox_eval.c,v 1.4 2018/04/06 10:44:51 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; |
} |
} |