Wild Life: bi_math.c File Reference

Wild Life 2.30

- Main Page
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Macros
Functions
bi_math.c File Reference

math built in functions. More...

Go to the source code of this file.

## Functions
static long | c_mult ()
| multiplication More...
static long | c_div ()
| division More...
static long | c_intdiv ()
| integer division More...
static long | c_floor_ceiling (long floorflag)
| floor & ceiling More...
static long | c_floor ()
| floor More...
static long | c_ceiling ()
| ceiling More...
static long | c_sqrt ()
| square root More...
static long | c_trig (long trigflag)
| trig functions More...
static long | c_cos ()
| cosine More...
static long | c_sin ()
| sin Return the sine of the argument More...
static long | c_tan ()
| tangent More...
static long | c_bit_not ()
| bitwise not More...
static long | c_bit_and ()
| bitwise and More...
static long | c_bit_or ()
| bitwise or More...
static long | c_shift (long dir)
| bitwise shift More...
static long | c_shift_left ()
| bitwise shift left More...
static long | c_shift_right ()
static long | c_mod ()
| modulo More...
static long | c_add ()
| addition More...
static long | c_sub ()
| subtraction More...
static long | c_log ()
| natural logarithm More...
static long | c_exp ()
| exponential More...
void | insert_math_builtins ()
| insert math builtins into table More...

## Detailed Description

math built in functions.

Definition in file bi_math.c.

## Function Documentation

c_add | ( |  | ) |
| static

addition

Addition is considered as a 3-variable relation as in Prolog: arg1 + arg2 = arg3 Only it may residuate or curry. Addition is further complicated by the fact that it is both a unary and binary function.

Definition at line 1016 of file bi_math.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, FALSE, get_real_value(), get_two_args(), nonnum_warning(), NULL, push_goal(), REAL, residuate2(), residuate3(), set_1_2, TRUE, unify, and unify_real_result().

1017 {
1018 long success=TRUE;
1019 ptr_psi_term arg1,arg2,arg3,t;
1020 long num1,num2,num3;
1021 REAL val1,val2,val3;
1022
1023 t=aim->aaaa_1;
1024 deref_ptr(t);
1025 get_two_args(t->attr_list,&arg1,&arg2);
1026 arg3=aim->bbbb_1;
1027
1028 if(arg1) {
1029 deref(arg1);
1030 success=get_real_value(arg1,&val1,&num1);
1031 if(success && arg2) {
1032 deref(arg2);
1033 deref_args(t,set_1_2);
1034 success=get_real_value(arg2,&val2,&num2);
1035 }
1036 }
1037
1038 if(success)
1039 if(arg1 && arg2) {
1040 deref(arg3);
1041 success=get_real_value(arg3,&val3,&num3);
1042 if(success)
1043 switch(num1+num2*2+num3*4) {
1044 case 0:
1045 if (arg1==arg3)
1046 success=unify_real_result(arg2,(REAL)0);
1047 else if (arg2==arg3)
1048 success=unify_real_result(arg1,(REAL)0);
1049 else
1050 residuate3(arg1,arg2,arg3);
1051 break;
1052 case 1:
1053 if (val1) {
1054 if (arg2==arg3) /* 8.9 */
1055 success=FALSE;
1056 else
1057 residuate2(arg2,arg3);
1058 }
1059 else
1060 push_goal(unify,arg2,arg3,NULL);
1061 break;
1062 case 2:
1063 if (val2) {
1064 if (arg1==arg3) /* 8.9 */
1065 success=FALSE;
1066 else
1067 residuate2(arg1,arg3);
1068 }
1069 else
1070 push_goal(unify,arg1,arg3,NULL);
1071 break;
1072 case 3:
1073 success=unify_real_result(arg3,val1+val2);
1074 break;
1075 case 4:
1076 if (arg1==arg2)
1077 success=unify_real_result(arg1,val3/2);
1078 else
1079 residuate2(arg1,arg2);
1080 break;
1081 case 5:
1082 success=unify_real_result(arg2,val3-val1);
1083 break;
1084 case 6:
1085 success=unify_real_result(arg1,val3-val2);
1086 break;
1087 case 7:
1088 success=(val3==val1+val2);
1089 break;
1090 }
1091 }
1092 else
1093 curry();
1094 /*
1095 '+' is no longer a function of a single argument:
1096 if(arg1) {
1097 deref(arg3);
1098 success=get_real_value(arg3,&val3,&num3);
1099 if(success)
1100 switch(num1+4*num3) {
1101 case 0:
1102 residuate2(arg1,arg3);
1103 break;
1104 case 1:
1105 success=unify_real_result(arg3,val1);
1106 break;
1107 case 4:
1108 success=unify_real_result(arg1,val3);
1109 break;
1110 case 5:
1111 success=(val1==val3);
1112 }
1113 }
1114 else
1115 curry();
1116 */
1117
1118 nonnum_warning(t,arg1,arg2);
1119 return success;
1120 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:239
get_two_args
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
push_goal
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
get_real_value
long get_real_value(ptr_psi_term t, REAL *v, long *n)
get_real_value
Definition: built_ins.c:261
wl_psi_term
Definition: def_struct.h:177
nonnum_warning
void nonnum_warning(ptr_psi_term t, ptr_psi_term arg1, ptr_psi_term arg2)
nonnum_warning
Definition: error.c:953
curry
void curry()
curry
Definition: lefun.c:174
NULL
#define NULL
Definition: def_const.h:533
REAL
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
set_1_2
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
residuate2
void residuate2(ptr_psi_term u, ptr_psi_term v)
residuate2
Definition: lefun.c:144
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:100
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
FALSE
#define FALSE
Standard boolean.
Definition: def_const.h:275
deref
#define deref(P)
Definition: def_macro.h:147
aim
ptr_goal aim
Definition: def_glob.h:1024
residuate3
void residuate3(ptr_psi_term u, ptr_psi_term v, ptr_psi_term w)
residuate3
Definition: lefun.c:159
unify
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
deref_args
#define deref_args(P, S)
Definition: def_macro.h:150
unify_real_result
long unify_real_result(ptr_psi_term t, REAL v)
unify_real_result
Definition: built_ins.c:386
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:240
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:187

c_bit_and | ( |  | ) |
| static

bitwise and

Return the bitwise operation: ARG1 and ARG2.

Definition at line 703 of file bi_math.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, bit_and_warning(), curry(), deref, deref_args, deref_ptr, FALSE, get_real_value(), get_two_args(), nonnum_warning(), REAL, residuate(), residuate2(), set_1_2, TRUE, and unify_real_result().

704 {
705 long success=TRUE;
706 ptr_psi_term arg1,arg2,arg3,t;
707 long num1,num2,num3;
708 REAL val1,val2,val3;
709
710 t=aim->aaaa_1;
711 deref_ptr(t);
712 get_two_args(t->attr_list,&arg1,&arg2);
713 arg3=aim->bbbb_1;
714
715 if(arg1) {
716 deref(arg1);
717 success=get_real_value(arg1,&val1,&num1);
718 if(success && arg2) {
719 deref(arg2);
720 deref_args(t,set_1_2);
721 success=get_real_value(arg2,&val2,&num2);
722 }
723 }
724
725 if(success)
726 if(arg1 && arg2) {
727 deref(arg3);
728 success=get_real_value(arg3,&val3,&num3);
729 if(success)
730 switch(num1+num2*2+num3*4) {
731 case 0:
732 residuate2(arg1,arg2);
733 break;
734 case 1:
735 if (bit_and_warning(arg1,val1)) return FALSE;
736 if(val1)
737 residuate(arg2);
738 else
739 success=unify_real_result(arg3,(REAL)0);
740 break;
741 case 2:
742 if (bit_and_warning(arg2,val2)) return FALSE;
743 if(val2)
744 residuate(arg1);
745 else
746 success=unify_real_result(arg3,(REAL)0);
747 break;
748 case 3:
749 if (bit_and_warning(arg1,val1)||bit_and_warning(arg2,val2))
750 return FALSE;
751 success=unify_real_result(arg3,(REAL)(((unsigned long)val1) & ((unsigned long)val2)));
752 break;
753 case 4:
754 residuate2(arg1,arg2);
755 break;
756 case 5:
757 if (bit_and_warning(arg1,val1)) return FALSE;
758 residuate(arg2);
759 break;
760 case 6:
761 if (bit_and_warning(arg2,val2)) return FALSE;
762 residuate(arg1);
763 break;
764 case 7:
765 if (bit_and_warning(arg1,val1)||bit_and_warning(arg2,val2))
766 return FALSE;
767 success=(val3==(REAL)(((unsigned long)val1) & ((unsigned long)val2)));
768 break;
769 }
770
771 }
772 else
773 curry();
774
775 nonnum_warning(t,arg1,arg2);
776 return success;
777 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:239
get_two_args
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
residuate
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
get_real_value
long get_real_value(ptr_psi_term t, REAL *v, long *n)
get_real_value
Definition: built_ins.c:261
wl_psi_term
Definition: def_struct.h:177
nonnum_warning
void nonnum_warning(ptr_psi_term t, ptr_psi_term arg1, ptr_psi_term arg2)
nonnum_warning
Definition: error.c:953
curry
void curry()
curry
Definition: lefun.c:174
REAL
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
set_1_2
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
residuate2
void residuate2(ptr_psi_term u, ptr_psi_term v)
residuate2
Definition: lefun.c:144
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:100
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
FALSE
#define FALSE
Standard boolean.
Definition: def_const.h:275
deref
#define deref(P)
Definition: def_macro.h:147
aim
ptr_goal aim
Definition: def_glob.h:1024
deref_args
#define deref_args(P, S)
Definition: def_macro.h:150
unify_real_result
long unify_real_result(ptr_psi_term t, REAL v)
unify_real_result
Definition: built_ins.c:386
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:240
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:187
bit_and_warning
long bit_and_warning(ptr_psi_term arg, REAL val)
bit_and_warning
Definition: error.c:992

c_bit_not | ( |  | ) |
| static

bitwise not

Return the bitwise not of the argument

Definition at line 649 of file bi_math.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, bit_not_warning(), curry(), deref, deref_args, deref_ptr, FALSE, get_one_arg(), get_real_value(), nonnum_warning(), NULL, REAL, residuate2(), set_1, TRUE, and unify_real_result().

650 {
651 long success=TRUE;
652 ptr_psi_term arg1,arg3,t; /* arg3 is result */
653 long num1,num3;
654 REAL val1,val3;
655
656 t=aim->aaaa_1;
657 deref_ptr(t);
658 get_one_arg(t->attr_list,&arg1);
659 arg3=aim->bbbb_1;
660
661 if (arg1) {
662 deref(arg1);
663 deref_args(t,set_1);
664 success=get_real_value(arg1,&val1,&num1);
665 if (success) {
666 deref(arg3);
667 success=get_real_value(arg3,&val3,&num3);
668 if (success)
669 switch(num1+num3*4) {
670 case 0:
671 if (arg1==arg3) return FALSE;
672 residuate2(arg1,arg3);
673 break;
674 case 1:
675 if (bit_not_warning(arg1,val1)) return FALSE;
676 success=unify_real_result(arg3,(REAL)~(long)val1);
677 break;
678 case 4:
679 if (bit_not_warning(arg3,val3)) return FALSE;
680 success=unify_real_result(arg1,(REAL)~(long)val3);
681 break;
682 case 5:
683 if (bit_not_warning(arg1,val1)) return FALSE;
684 if (bit_not_warning(arg3,val3)) return FALSE;
685 success=(val3==val1);
686 break;
687 }
688 }
689 }
690 else
691 curry();
692
693 nonnum_warning(t,arg1,NULL);
694 return success;
695 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:239
get_real_value
long get_real_value(ptr_psi_term t, REAL *v, long *n)
get_real_value
Definition: built_ins.c:261
wl_psi_term
Definition: def_struct.h:177
nonnum_warning
void nonnum_warning(ptr_psi_term t, ptr_psi_term arg1, ptr_psi_term arg2)
nonnum_warning
Definition: error.c:953
get_one_arg
void get_one_arg(ptr_node t, ptr_psi_term *a)
get_one_arg
Definition: login.c:99
bit_not_warning
long bit_not_warning(ptr_psi_term arg, REAL val)
bit_not_warning
Definition: error.c:1016
set_1
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
curry
void curry()
curry
Definition: lefun.c:174
NULL
#define NULL
Definition: def_const.h:533
REAL
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
residuate2
void residuate2(ptr_psi_term u, ptr_psi_term v)
residuate2
Definition: lefun.c:144
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:100
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
FALSE
#define FALSE
Standard boolean.
Definition: def_const.h:275
deref
#define deref(P)
Definition: def_macro.h:147
aim
ptr_goal aim
Definition: def_glob.h:1024
deref_args
#define deref_args(P, S)
Definition: def_macro.h:150
unify_real_result
long unify_real_result(ptr_psi_term t, REAL v)
unify_real_result
Definition: built_ins.c:386
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:240
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:187

c_bit_or | ( |  | ) |
| static

bitwise or

Return the bitwise operation: ARG1 or ARG2.

Definition at line 785 of file bi_math.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, bit_or_warning(), curry(), deref, deref_args, deref_ptr, FALSE, get_real_value(), get_two_args(), nonnum_warning(), REAL, residuate(), residuate2(), set_1_2, TRUE, and unify_real_result().

786 {
787 long success=TRUE;
788 ptr_psi_term arg1,arg2,arg3,t;
789 long num1,num2,num3;
790 REAL val1,val2,val3;
791
792 t=aim->aaaa_1;
793 deref_ptr(t);
794 get_two_args(t->attr_list,&arg1,&arg2);
795 arg3=aim->bbbb_1;
796
797 if(arg1) {
798 deref(arg1);
799 success=get_real_value(arg1,&val1,&num1);
800 if(success && arg2) {
801 deref(arg2);
802 deref_args(t,set_1_2);
803 success=get_real_value(arg2,&val2,&num2);
804 }
805 }
806
807 if(success)
808 if(arg1 && arg2) {
809 deref(arg3);
810 success=get_real_value(arg3,&val3,&num3);
811 if(success)
812 switch(num1+num2*2+num3*4) {
813 case 0:
814 case 4:
815 residuate2(arg1,arg2);
816 break;
817 case 1:
818 case 5:
819 if (bit_or_warning(arg1,val1)) return FALSE;
820 residuate(arg2);
821 break;
822 case 2:
823 case 6:
824 if (bit_or_warning(arg2,val2)) return FALSE;
825 residuate(arg1);
826 break;
827 case 3:
828 if (bit_or_warning(arg1,val1)||bit_or_warning(arg2,val2))
829 return FALSE;
830 success=unify_real_result(arg3,(REAL)(((unsigned long)val1) | ((unsigned long)val2)));
831 break;
832 case 7:
833 if (bit_or_warning(arg1,val1)||bit_or_warning(arg2,val2))
834 return FALSE;
835 success=(val3==(REAL)(((unsigned long)val1) | ((unsigned long)val2)));
836 break;
837 }
838 }
839 else
840 curry();
841
842 nonnum_warning(t,arg1,arg2);
843 return success;
844 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:239
get_two_args
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
residuate
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
get_real_value
long get_real_value(ptr_psi_term t, REAL *v, long *n)
get_real_value
Definition: built_ins.c:261
wl_psi_term
Definition: def_struct.h:177
nonnum_warning
void nonnum_warning(ptr_psi_term t, ptr_psi_term arg1, ptr_psi_term arg2)
nonnum_warning
Definition: error.c:953
curry
void curry()
curry
Definition: lefun.c:174
REAL
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
set_1_2
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
residuate2
void residuate2(ptr_psi_term u, ptr_psi_term v)
residuate2
Definition: lefun.c:144
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:100
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
FALSE
#define FALSE
Standard boolean.
Definition: def_const.h:275
deref
#define deref(P)
Definition: def_macro.h:147
aim
ptr_goal aim
Definition: def_glob.h:1024
bit_or_warning
long bit_or_warning(ptr_psi_term arg, REAL val)
bit_or_warning
Definition: error.c:1004
deref_args
#define deref_args(P, S)
Definition: def_macro.h:150
unify_real_result
long unify_real_result(ptr_psi_term t, REAL v)
unify_real_result
Definition: built_ins.c:386
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:240
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:187

c_ceiling | ( |  | ) |
| static

ceiling

Return the smallest integer larger or equal to the argument

Definition at line 490 of file bi_math.c.

References c_floor_ceiling(), and FALSE.

491 {
492 return c_floor_ceiling(FALSE);
493 }
FALSE
#define FALSE
Standard boolean.
Definition: def_const.h:275
c_floor_ceiling
static long c_floor_ceiling(long floorflag)
floor & ceiling
Definition: bi_math.c:431

c_cos | ( |  | ) |
| static

cosine

Return the cosine of the argument (in radians).

Definition at line 617 of file bi_math.c.

References c_trig(), and COSFLAG.

618 {
619 return (c_trig(COSFLAG));
620 }
COSFLAG
#define COSFLAG
flag to c_trig to compute cos
Definition: def_const.h:1180
c_trig
static long c_trig(long trigflag)
trig functions
Definition: bi_math.c:556

c_div | ( |  | ) |
| static

division

Division is considered as a 3-variable relation as in Prolog: arg1 / arg2 = arg3 Only it may residuate or curry.

Definition at line 138 of file bi_math.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, Errorline(), FALSE, get_real_value(), get_two_args(), nonnum_warning(), NULL, push_goal(), REAL, residuate(), residuate2(), residuate3(), set_1_2, TRUE, unify, and unify_real_result().

139 {
140 long success=TRUE;
141 ptr_psi_term arg1,arg2,arg3,t;
142 long num1,num2,num3;
143 REAL val1,val2,val3;
144
145 t=aim->aaaa_1;
146 deref_ptr(t);
147 get_two_args(t->attr_list,&arg1,&arg2);
148 arg3=aim->bbbb_1;
149
150 if (arg1) {
151 deref(arg1);
152 success=get_real_value(arg1,&val1,&num1);
153 if (success && arg2) {
154 deref(arg2);
155 deref_args(t,set_1_2);
156 success=get_real_value(arg2,&val2,&num2);
157 }
158 }
159
160 if (success)
161 if (arg1 && arg2) {
162 deref(arg3);
163 success=get_real_value(arg3,&val3,&num3);
164 if (success)
165 switch(num1+num2*2+num3*4) {
166 case 0:
167 residuate3(arg1,arg2,arg3);
168 break;
169 case 1:
170 if (val1) {
171 if (arg2==arg3) {
172 if (val1>0.0)
173 residuate(arg2);
174 else
175 success=FALSE; /* A/B=B where A<0 */
176 }
177 else
178 residuate2(arg2,arg3);
179 }
180 else if (arg2==arg3) /* 9.9 */
181 success=unify_real_result(arg2,(REAL)0);
182 else
183 residuate2(arg2,arg3);
184 break;
185 case 2:
186 if (val2) {
187 if (val2==1.0) /* 8.9 */
188 push_goal(unify,arg1,arg3,NULL);
189 else if (arg1==arg3) /* 9.9 */
190 success=unify_real_result(arg1,(REAL)0);
191 else
192 residuate2(arg1,arg3);
193 }
194 else {
195 success=FALSE;
196 Errorline("division by zero in %P.\n",t); /* 8.9 */
197 }
198 break;
199 case 3:
200 if (val2)
201 success=unify_real_result(arg3,val1/val2);
202 else {
203 success=FALSE;
204 Errorline("division by zero in %P.\n",t); /* 8.9 */
205 }
206 break;
207 case 4:
208 if (val3) {
209 if (val3==1.0 && arg1!=arg2) { /* 9.9 */
210 push_goal(unify,arg1,arg2,NULL);
211 }
212 else if (val3!=1.0 && arg1==arg2) /* 9.9 */
213 success=unify_real_result(arg1,(REAL)0);
214 else
215 residuate2(arg1,arg2);
216 }
217 else
218 success=unify_real_result(arg1,(REAL)0);
219 break;
220 case 5:
221 if (val3)
222 success=unify_real_result(arg2,val1/val3);
223 else
224 success=(val1==0);
225 break;
226 case 6:
227 if (val2)
228 success=unify_real_result(arg1,val3*val2);
229 else {
230 if (val3) {
231 success=FALSE;
232 Errorline("division by zero in %P.\n",t); /* 8.9 */
233 }
234 else
235 success=unify_real_result(arg1,(REAL)0);
236 }
237 break;
238 case 7:
239 if (val2)
240 success=(val3==val1/val2);
241 else {
242 success=FALSE;
243 Errorline("division by zero in %P.\n",t); /* 8.9 */
244 }
245 break;
246 }
247
248 }
249 else
250 curry();
251
252 nonnum_warning(t,arg1,arg2);
253 return success;
254 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:239
get_two_args
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
residuate
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
push_goal
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
get_real_value
long get_real_value(ptr_psi_term t, REAL *v, long *n)
get_real_value
Definition: built_ins.c:261
wl_psi_term
Definition: def_struct.h:177
nonnum_warning
void nonnum_warning(ptr_psi_term t, ptr_psi_term arg1, ptr_psi_term arg2)
nonnum_warning
Definition: error.c:953
curry
void curry()
curry
Definition: lefun.c:174
NULL
#define NULL
Definition: def_const.h:533
REAL
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
Errorline
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
set_1_2
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
residuate2
void residuate2(ptr_psi_term u, ptr_psi_term v)
residuate2
Definition: lefun.c:144
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:100
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
FALSE
#define FALSE
Standard boolean.
Definition: def_const.h:275
deref
#define deref(P)
Definition: def_macro.h:147
aim
ptr_goal aim
Definition: def_glob.h:1024
residuate3
void residuate3(ptr_psi_term u, ptr_psi_term v, ptr_psi_term w)
residuate3
Definition: lefun.c:159
unify
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
deref_args
#define deref_args(P, S)
Definition: def_macro.h:150
unify_real_result
long unify_real_result(ptr_psi_term t, REAL v)
unify_real_result
Definition: built_ins.c:386
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:240
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:187

c_exp | ( |  | ) |
| static

exponential

Exponential.

Definition at line 1295 of file bi_math.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, FALSE, get_real_value(), get_two_args(), nonnum_warning(), NULL, REAL, residuate2(), set_1, TRUE, and unify_real_result().

1296 {
1297 long success=TRUE;
1298 ptr_psi_term arg1,arg2,arg3,t;
1299 long num1,num3;
1300 REAL val1,val3;
1301
1302 t=aim->aaaa_1;
1303 deref_ptr(t);
1304 get_two_args(t->attr_list,&arg1,&arg2);
1305 arg3=aim->bbbb_1;
1306
1307 if(arg1) {
1308 deref(arg1);
1309 deref_args(t,set_1);
1310 success=get_real_value(arg1,&val1,&num1);
1311 if(success) {
1312 deref(arg3);
1313 success=get_real_value(arg3,&val3,&num3);
1314 if(success)
1315 switch(num1+num3*4) {
1316 case 0:
1317 residuate2(arg1,arg3);
1318 break;
1319 case 1:
1320 success=unify_real_result(arg3,exp(val1));
1321 break;
1322 case 4:
1323 if(val3>0)
1324 success=unify_real_result(arg1,log(val3));
1325 else
1326 success=FALSE;
1327 break;
1328 case 5:
1329 success=(exp(val1)==val3 || (val3>0 && val1==log(val3)));
1330 }
1331 }
1332 }
1333 else
1334 curry();
1335
1336 nonnum_warning(t,arg1,NULL);
1337 return success;
1338 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:239
get_two_args
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
get_real_value
long get_real_value(ptr_psi_term t, REAL *v, long *n)
get_real_value
Definition: built_ins.c:261
wl_psi_term
Definition: def_struct.h:177
nonnum_warning
void nonnum_warning(ptr_psi_term t, ptr_psi_term arg1, ptr_psi_term arg2)
nonnum_warning
Definition: error.c:953
set_1
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
curry
void curry()
curry
Definition: lefun.c:174
NULL
#define NULL
Definition: def_const.h:533
REAL
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
residuate2
void residuate2(ptr_psi_term u, ptr_psi_term v)
residuate2
Definition: lefun.c:144
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:100
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
FALSE
#define FALSE
Standard boolean.
Definition: def_const.h:275
deref
#define deref(P)
Definition: def_macro.h:147
aim
ptr_goal aim
Definition: def_glob.h:1024
deref_args
#define deref_args(P, S)
Definition: def_macro.h:150
unify_real_result
long unify_real_result(ptr_psi_term t, REAL v)
unify_real_result
Definition: built_ins.c:386
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:240
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:187

c_floor | ( |  | ) |
| static

floor

Return the largest integer inferior or equal to the argument

Definition at line 479 of file bi_math.c.

References c_floor_ceiling(), and TRUE.

480 {
481 return c_floor_ceiling(TRUE);
482 }
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
c_floor_ceiling
static long c_floor_ceiling(long floorflag)
floor & ceiling
Definition: bi_math.c:431

c_floor_ceiling | ( | long | floorflag | ) |
| static

floor & ceiling

Parameters

  floorflag | TRUE for floor - FALSE for ceiling

Main routine for floor & ceiling functions

Definition at line 431 of file bi_math.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, get_real_value(), get_two_args(), nonnum_warning(), NULL, REAL, residuate(), set_1, TRUE, and unify_real_result().

432 {
433 long success=TRUE;
434 ptr_psi_term arg1,arg2,arg3,t;
435 long num1,num3;
436 REAL val1,val3;
437
438 t=aim->aaaa_1;
439 deref_ptr(t);
440 get_two_args(t->attr_list,&arg1,&arg2);
441 arg3=aim->bbbb_1;
442
443 if(arg1) {
444 deref(arg1);
445 deref_args(t,set_1);
446 success=get_real_value(arg1,&val1,&num1);
447 if(success) {
448 deref(arg3);
449 success=get_real_value(arg3,&val3,&num3);
450 if(success)
451 switch(num1+num3*4) {
452 case 0:
453 residuate(arg1);
454 break;
455 case 1:
456 success=unify_real_result(arg3,(floorflag?floor(val1):ceil(val1)));
457 break;
458 case 4:
459 residuate(arg1);
460 break;
461 case 5:
462 success=(val3==(floorflag?floor(val1):ceil(val1)));
463 }
464 }
465 }
466 else
467 curry();
468
469 nonnum_warning(t,arg1,NULL);
470 return success;
471 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:239
get_two_args
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
residuate
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
get_real_value
long get_real_value(ptr_psi_term t, REAL *v, long *n)
get_real_value
Definition: built_ins.c:261
wl_psi_term
Definition: def_struct.h:177
nonnum_warning
void nonnum_warning(ptr_psi_term t, ptr_psi_term arg1, ptr_psi_term arg2)
nonnum_warning
Definition: error.c:953
set_1
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
curry
void curry()
curry
Definition: lefun.c:174
NULL
#define NULL
Definition: def_const.h:533
REAL
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:100
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
deref
#define deref(P)
Definition: def_macro.h:147
aim
ptr_goal aim
Definition: def_glob.h:1024
deref_args
#define deref_args(P, S)
Definition: def_macro.h:150
unify_real_result
long unify_real_result(ptr_psi_term t, REAL v)
unify_real_result
Definition: built_ins.c:386
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:240
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:187

c_intdiv | ( |  | ) |
| static

integer division

Similar to division, but arguments and result must be integers. Does all deterministic local inversions that can be determined in constant-time independent of argument values.

Definition at line 264 of file bi_math.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, Errorline(), FALSE, get_real_value(), get_two_args(), int_div_warning(), nonnum_warning(), NULL, push_goal(), REAL, residuate(), residuate2(), residuate3(), set_1_2, TRUE, unify, and unify_real_result().

265 {
266 long success=TRUE;
267 ptr_psi_term arg1,arg2,arg3,t;
268 long num1,num2,num3;
269 REAL val1,val2,val3;
270
271 t=aim->aaaa_1;
272 deref_ptr(t);
273 get_two_args(t->attr_list,&arg1,&arg2);
274 arg3=aim->bbbb_1;
275
276 if (arg1) {
277 deref(arg1);
278 success=get_real_value(arg1,&val1,&num1);
279 if (success && arg2) {
280 deref(arg2);
281 deref_args(t,set_1_2);
282 success=get_real_value(arg2,&val2,&num2);
283 }
284 }
285
286 if (success)
287 if (arg1 && arg2) {
288 deref(arg3);
289 success=get_real_value(arg3,&val3,&num3);
290 if (success)
291 switch(num1+num2*2+num3*4) {
292 case 0:
293 residuate3(arg1,arg2,arg3);
294 break;
295 case 1:
296 if (val1) {
297 if (int_div_warning(arg1,val1)) return FALSE;
298 if (arg2==arg3) {
299 if (val1>0.0)
300 residuate(arg2);
301 else
302 success=FALSE; /* A/B=B where A<0 */
303 }
304 else
305 residuate2(arg2,arg3);
306 }
307 else if (arg2==arg3) /* 9.9 */
308 success=unify_real_result(arg2,(REAL)0);
309 else
310 residuate2(arg2,arg3);
311 break;
312 case 2:
313 if (val2) {
314 if (int_div_warning(arg2,val2)) return FALSE;
315 if (val2==1.0) /* 8.9 */
316 push_goal(unify,arg1,arg3,NULL);
317 else if (arg1==arg3) /* 9.9 */
318 success=unify_real_result(arg1,(REAL)0);
319 else
320 residuate2(arg1,arg3);
321 }
322 else {
323 success=FALSE;
324 Errorline("division by zero in %P.\n",t); /* 8.9 */
325 }
326 break;
327 case 3:
328 if (int_div_warning(arg1,val1)) return FALSE;
329 if (int_div_warning(arg2,val2)) return FALSE;
330 if (val2)
331 success=unify_real_result(arg3,trunc(val1/val2));
332 else {
333 success=FALSE;
334 Errorline("division by zero in %P.\n",t); /* 8.9 */
335 }
336 break;
337 case 4:
338 if (val3) {
339 /* if (int_div_warning(arg3,val3)) return FALSE; */
340 if (val3!=floor(val3)) return FALSE;
341 if (val3==1.0 && arg1!=arg2) { /* 9.9 */
342 push_goal(unify,arg1,arg2,NULL);
343 }
344 else if (val3!=1.0 && arg1==arg2) /* 9.9 */
345 success=unify_real_result(arg1,(REAL)0);
346 else
347 residuate2(arg1,arg2);
348 }
349 else
350 success=unify_real_result(arg1,(REAL)0);
351 break;
352 case 5:
353 if (int_div_warning(arg1,val1)) return FALSE;
354 if (val3) {
355 /* if (int_div_warning(arg3,val3)) return FALSE; */
356 if (val3!=floor(val3)) return FALSE;
357 if (arg1==arg3) {
358 success=unify_real_result(arg2,(REAL)1);
359 }
360 else if (val1==0) {
361 success=unify_real_result(arg2,(REAL)0);
362 }
363 else {
364 double tmp;
365 tmp=trunc(val1/val3); /* Possible solution */
366 if (tmp==0)
367 success=FALSE;
368 else if (val3==trunc(val1/tmp)) { /* It is a solution */
369 /* Check uniqueness */
370 if ((tmp> 1 && val3==trunc(val1/(tmp-1))) ||
371 (tmp< -1 && val3==trunc(val1/(tmp+1))))
372 /* Solution is not unique */
373 residuate(arg2);
374 else /* Solution is unique */
375 success=unify_real_result(arg2,tmp);
376 }
377 else
378 success=FALSE;
379 }
380 }
381 else
382 success=(val1==0);
383 break;
384 case 6:
385 if (int_div_warning(arg2,val2)) return FALSE;
386 /* if (int_div_warning(arg3,val3)) return FALSE; */
387 if (val3!=floor(val3)) return FALSE;
388 if (val2) {
389 if (val3)
390 residuate(arg1);
391 else
392 success=unify_real_result(arg1,(REAL)0);
393 }
394 else {
395 if (val3) {
396 success=FALSE;
397 Errorline("division by zero in %P.\n",t); /* 8.9 */
398 }
399 else
400 success=unify_real_result(arg1,(REAL)0);
401 }
402 break;
403 case 7:
404 if (int_div_warning(arg1,val1)) return FALSE;
405 if (int_div_warning(arg2,val2)) return FALSE;
406 /* if (int_div_warning(arg3,val3)) return FALSE; */
407 if (val2)
408 success=(val3==trunc(val1/val2));
409 else {
410 success=FALSE;
411 Errorline("division by zero in %P.\n",t); /* 8.9 */
412 }
413 break;
414 }
415
416 }
417 else
418 curry();
419
420 nonnum_warning(t,arg1,arg2);
421 return success;
422 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:239
get_two_args
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
residuate
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
push_goal
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
get_real_value
long get_real_value(ptr_psi_term t, REAL *v, long *n)
get_real_value
Definition: built_ins.c:261
wl_psi_term
Definition: def_struct.h:177
nonnum_warning
void nonnum_warning(ptr_psi_term t, ptr_psi_term arg1, ptr_psi_term arg2)
nonnum_warning
Definition: error.c:953
curry
void curry()
curry
Definition: lefun.c:174
NULL
#define NULL
Definition: def_const.h:533
REAL
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
Errorline
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
set_1_2
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
residuate2
void residuate2(ptr_psi_term u, ptr_psi_term v)
residuate2
Definition: lefun.c:144
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:100
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
FALSE
#define FALSE
Standard boolean.
Definition: def_const.h:275
deref
#define deref(P)
Definition: def_macro.h:147
aim
ptr_goal aim
Definition: def_glob.h:1024
residuate3
void residuate3(ptr_psi_term u, ptr_psi_term v, ptr_psi_term w)
residuate3
Definition: lefun.c:159
unify
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
deref_args
#define deref_args(P, S)
Definition: def_macro.h:150
unify_real_result
long unify_real_result(ptr_psi_term t, REAL v)
unify_real_result
Definition: built_ins.c:386
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:240
int_div_warning
long int_div_warning(ptr_psi_term arg, REAL val)
int_div_warning
Definition: error.c:1028
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:187

c_log | ( |  | ) |
| static

natural logarithm

Natural logarithm.

Definition at line 1238 of file bi_math.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, Errorline(), FALSE, get_one_arg(), get_real_value(), nonnum_warning(), NULL, REAL, residuate2(), set_1, TRUE, and unify_real_result().

1239 {
1240 long success=TRUE;
1241 ptr_psi_term arg1,arg3,t;
1242 long num1,num3;
1243 REAL val1,val3;
1244
1245 t=aim->aaaa_1;
1246 deref_ptr(t);
1247 get_one_arg(t->attr_list,&arg1);
1248 arg3=aim->bbbb_1;
1249
1250 if(arg1) {
1251 deref(arg1);
1252 deref_args(t,set_1);
1253 success=get_real_value(arg1,&val1,&num1);
1254 if(success) {
1255 deref(arg3);
1256 success=get_real_value(arg3,&val3,&num3);
1257 if(success)
1258 switch(num1+num3*4) {
1259 case 0:
1260 residuate2(arg1,arg3);
1261 break;
1262 case 1:
1263 if (val1>0)
1264 success=unify_real_result(arg3,log(val1));
1265 else {
1266 success=FALSE;
1267 Errorline("logarithm of %s in %P.\n",
1268 (val1==0)?"zero":"a negative number",t);
1269 }
1270 break;
1271 case 4:
1272 success=unify_real_result(arg1,exp(val3));
1273 break;
1274 case 5:
1275 success=(exp(val3)==val1 || (val1>0 && val3==log(val1)));
1276 if (val1<=0)
1277 Errorline("logarithm of %s in %P.\n",
1278 (val1==0)?"zero":"a negative number",t);
1279 }
1280 }
1281 }
1282 else
1283 curry();
1284
1285 nonnum_warning(t,arg1,NULL);
1286 return success;
1287 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:239
get_real_value
long get_real_value(ptr_psi_term t, REAL *v, long *n)
get_real_value
Definition: built_ins.c:261
wl_psi_term
Definition: def_struct.h:177
nonnum_warning
void nonnum_warning(ptr_psi_term t, ptr_psi_term arg1, ptr_psi_term arg2)
nonnum_warning
Definition: error.c:953
get_one_arg
void get_one_arg(ptr_node t, ptr_psi_term *a)
get_one_arg
Definition: login.c:99
set_1
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
curry
void curry()
curry
Definition: lefun.c:174
NULL
#define NULL
Definition: def_const.h:533
REAL
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
Errorline
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
residuate2
void residuate2(ptr_psi_term u, ptr_psi_term v)
residuate2
Definition: lefun.c:144
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:100
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
FALSE
#define FALSE
Standard boolean.
Definition: def_const.h:275
deref
#define deref(P)
Definition: def_macro.h:147
aim
ptr_goal aim
Definition: def_glob.h:1024
deref_args
#define deref_args(P, S)
Definition: def_macro.h:150
unify_real_result
long unify_real_result(ptr_psi_term t, REAL v)
unify_real_result
Definition: built_ins.c:386
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:240
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:187

c_mod | ( |  | ) |
| static

modulo

The modulo operation.

Definition at line 945 of file bi_math.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, FALSE, get_real_value(), get_two_args(), mod_warning(), nonnum_warning(), REAL, residuate(), residuate2(), set_1_2, TRUE, and unify_real_result().

946 {
947 long success=TRUE;
948 ptr_psi_term arg1,arg2,arg3,t;
949 long num1,num2,num3;
950 REAL val1,val2,val3;
951
952 t=aim->aaaa_1;
953 deref_ptr(t);
954 get_two_args(t->attr_list,&arg1,&arg2);
955 arg3=aim->bbbb_1;
956
957 if(arg1) {
958 deref(arg1);
959 success=get_real_value(arg1,&val1,&num1);
960 if(success && arg2) {
961 deref(arg2);
962 deref_args(t,set_1_2);
963 success=get_real_value(arg2,&val2,&num2);
964 }
965 }
966
967 if(success)
968 if(arg1 && arg2) {
969 deref(arg3);
970 success=get_real_value(arg3,&val3,&num3);
971 if(success)
972 switch(num1+num2*2+num3*4) {
973 case 0:
974 case 4:
975 residuate2(arg1,arg2);
976 break;
977 case 1:
978 case 5:
979 if (mod_warning(arg1,val1,0)) return FALSE;
980 residuate(arg2);
981 break;
982 case 2:
983 case 6:
984 if (mod_warning(arg2,val2,1)) return FALSE;
985 residuate(arg1);
986 break;
987 case 3:
988 if (mod_warning(arg1,val1,0)||mod_warning(arg2,val2,1))
989 return FALSE;
990 success=unify_real_result(arg3,(REAL)((unsigned long)val1 % (unsigned long)val2));
991 break;
992 case 7:
993 if (mod_warning(arg1,val1,0)||mod_warning(arg2,val2,1))
994 return FALSE;
995 success=(val3==(REAL)((unsigned long)val1 % (unsigned long)val2));
996 break;
997 }
998 }
999 else
1000 curry();
1001
1002 nonnum_warning(t,arg1,arg2);
1003 return success;
1004 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:239
get_two_args
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
residuate
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
get_real_value
long get_real_value(ptr_psi_term t, REAL *v, long *n)
get_real_value
Definition: built_ins.c:261
wl_psi_term
Definition: def_struct.h:177
nonnum_warning
void nonnum_warning(ptr_psi_term t, ptr_psi_term arg1, ptr_psi_term arg2)
nonnum_warning
Definition: error.c:953
curry
void curry()
curry
Definition: lefun.c:174
REAL
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
set_1_2
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
residuate2
void residuate2(ptr_psi_term u, ptr_psi_term v)
residuate2
Definition: lefun.c:144
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:100
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
FALSE
#define FALSE
Standard boolean.
Definition: def_const.h:275
deref
#define deref(P)
Definition: def_macro.h:147
aim
ptr_goal aim
Definition: def_glob.h:1024
deref_args
#define deref_args(P, S)
Definition: def_macro.h:150
unify_real_result
long unify_real_result(ptr_psi_term t, REAL v)
unify_real_result
Definition: built_ins.c:386
mod_warning
long mod_warning(ptr_psi_term arg, REAL val, int zero)
mod_warning
Definition: error.c:1041
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:240
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:187

c_mult | ( |  | ) |
| static

multiplication

Multiplication is considered as a 3-variable relation as in Prolog: arg1 * arg2 = arg3 Only it may residuate or curry.

Definition at line 28 of file bi_math.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, FALSE, get_real_value(), get_two_args(), nonnum_warning(), NULL, push_goal(), REAL, residuate(), residuate2(), residuate3(), set_1_2, TRUE, unify, and unify_real_result().

29 {
30 long success=TRUE; // changed from FALSE 2.16 (diff check) increased match to 263 from 257
31 ptr_psi_term arg1,arg2,arg3,t;
32 long num1,num2,num3;
33 REAL val1,val2,val3;
34
35 t=aim->aaaa_1;
36 deref_ptr(t);
37 get_two_args(t->attr_list,&arg1,&arg2);
38 arg3=aim->bbbb_1;
39
40 if(arg1) {
41 deref(arg1);
42 success=get_real_value(arg1,&val1,&num1);
43 if(success && arg2) {
44 deref(arg2);
45 deref_args(t,set_1_2);
46 success=get_real_value(arg2,&val2,&num2);
47 }
48 }
49
50 if(success)
51 if(arg1 && arg2) {
52 deref(arg3);
53 success=get_real_value(arg3,&val3,&num3);
54 if(success)
55 switch(num1+num2*2+num3*4) {
56 case 0:
57 residuate3(arg1,arg2,arg3);
58
59 /* if(arg1==arg3)
60 success=unify_real_result(arg2,(REAL)1);
61 else
62 if(arg2==arg3)
63 success=unify_real_result(arg1,(REAL)1);
64 else
65 residuate2(arg1,arg3);
66 */
67 break;
68 case 1:
69 if (val1==1.0)
70 push_goal(unify,arg2,arg3,NULL);
71 else if (val1==0.0)
72 success=unify_real_result(arg3,(REAL)0);
73 else if (val1!=1.0 && arg2==arg3) /* 9.9 */
74 success=unify_real_result(arg3,(REAL)0);
75 else
76 residuate2(arg2,arg3);
77 break;
78 case 2:
79 if (val2==1.0)
80 push_goal(unify,arg1,arg3,NULL);
81 else if (val2==0.0)
82 success=unify_real_result(arg3,(REAL)0);
83 else if (val2!=1.0 && arg1==arg3) /* 9.9 */
84 success=unify_real_result(arg3,(REAL)0);
85 else
86 residuate2(arg1,arg3);
87 break;
88 case 3:
89 success=unify_real_result(arg3,val1*val2);
90 break;
91 case 4:
92 if (arg1==arg2) {
93 if (val3==0.0) /* 8.9 */
94 success=unify_real_result(arg1,(REAL)0);
95 else if (val3>0.0)
96 residuate(arg1);
97 else
98 success=FALSE;
99 }
100 else {
101 /* Case A*B=0 is not dealt with because it is nondeterministic */
102 residuate2(arg1,arg2);
103 }
104 break;
105 case 5:
106 if(val1)
107 success=unify_real_result(arg2,val3/val1);
108 else
109 success=(val3==0);
110 break;
111 case 6:
112 if(val2)
113 success=unify_real_result(arg1,val3/val2);
114 else
115 success=(val3==0);
116 break;
117 case 7:
118 success=(val3==val1*val2);
119 break;
120 }
121
122 }
123 else
124 curry();
125
126 nonnum_warning(t,arg1,arg2);
127 return success;
128 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:239
get_two_args
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
residuate
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
push_goal
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
get_real_value
long get_real_value(ptr_psi_term t, REAL *v, long *n)
get_real_value
Definition: built_ins.c:261
wl_psi_term
Definition: def_struct.h:177
nonnum_warning
void nonnum_warning(ptr_psi_term t, ptr_psi_term arg1, ptr_psi_term arg2)
nonnum_warning
Definition: error.c:953
curry
void curry()
curry
Definition: lefun.c:174
NULL
#define NULL
Definition: def_const.h:533
REAL
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
set_1_2
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
residuate2
void residuate2(ptr_psi_term u, ptr_psi_term v)
residuate2
Definition: lefun.c:144
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:100
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
FALSE
#define FALSE
Standard boolean.
Definition: def_const.h:275
deref
#define deref(P)
Definition: def_macro.h:147
aim
ptr_goal aim
Definition: def_glob.h:1024
residuate3
void residuate3(ptr_psi_term u, ptr_psi_term v, ptr_psi_term w)
residuate3
Definition: lefun.c:159
unify
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
deref_args
#define deref_args(P, S)
Definition: def_macro.h:150
unify_real_result
long unify_real_result(ptr_psi_term t, REAL v)
unify_real_result
Definition: built_ins.c:386
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:240
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:187

static long c_shift | ( | long | dir | ) |
| static

bitwise shift

Parameters

  dir | FALSE = left TRUE = right

Return the bitwise shift dir.

Definition at line 876 of file bi_math.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, FALSE, get_real_value(), get_two_args(), nonnum_warning(), REAL, residuate(), residuate2(), set_1_2, shift_warning(), TRUE, and unify_real_result().

877 {
878 long success=TRUE;
879 ptr_psi_term arg1,arg2,arg3,t;
880 long num1,num2,num3;
881 REAL val1,val2,val3,ans;
882
883 t=aim->aaaa_1;
884 deref_ptr(t);
885 get_two_args(t->attr_list,&arg1,&arg2);
886 arg3=aim->bbbb_1;
887
888 if(arg1) {
889 deref(arg1);
890 success=get_real_value(arg1,&val1,&num1);
891 if(success && arg2) {
892 deref(arg2);
893 deref_args(t,set_1_2);
894 success=get_real_value(arg2,&val2,&num2);
895 }
896 }
897
898 if(success)
899 if(arg1 && arg2) {
900 deref(arg3);
901 success=get_real_value(arg3,&val3,&num3);
902 if (success)
903 switch(num1+num2*2+num3*4) {
904 case 0:
905 case 4:
906 residuate2(arg1,arg2);
907 break;
908 case 1:
909 case 5:
910 if (shift_warning(dir,arg1,val1)) return FALSE;
911 residuate(arg2);
912 break;
913 case 2:
914 case 6:
915 if (shift_warning(dir,arg2,val2)) return FALSE;
916 residuate(arg1);
917 break;
918 case 3:
919 if (shift_warning(dir,arg1,val1)||shift_warning(dir,arg2,val2))
920 return FALSE;
921 ans=(REAL)(dir?(long)val1>>(long)val2:(long)val1<<(long)val2);
922 success=unify_real_result(arg3,ans);
923 break;
924 case 7:
925 if (shift_warning(dir,arg1,val1)||shift_warning(dir,arg2,val2))
926 return FALSE;
927 ans=(REAL)(dir?(long)val1>>(long)val2:(long)val1<<(long)val2);
928 success=(val3==ans);
929 break;
930 }
931 }
932 else
933 curry();
934
935 nonnum_warning(t,arg1,arg2);
936 return success;
937 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:239
get_two_args
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
residuate
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
get_real_value
long get_real_value(ptr_psi_term t, REAL *v, long *n)
get_real_value
Definition: built_ins.c:261
wl_psi_term
Definition: def_struct.h:177
nonnum_warning
void nonnum_warning(ptr_psi_term t, ptr_psi_term arg1, ptr_psi_term arg2)
nonnum_warning
Definition: error.c:953
curry
void curry()
curry
Definition: lefun.c:174
REAL
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
set_1_2
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
residuate2
void residuate2(ptr_psi_term u, ptr_psi_term v)
residuate2
Definition: lefun.c:144
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:100
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
FALSE
#define FALSE
Standard boolean.
Definition: def_const.h:275
deref
#define deref(P)
Definition: def_macro.h:147
shift_warning
long shift_warning(long dir, ptr_psi_term arg, REAL val)
shift_warning
Definition: error.c:1061
aim
ptr_goal aim
Definition: def_glob.h:1024
deref_args
#define deref_args(P, S)
Definition: def_macro.h:150
unify_real_result
long unify_real_result(ptr_psi_term t, REAL v)
unify_real_result
Definition: built_ins.c:386
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:240
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:187

c_shift_left | ( |  | ) |
| static

bitwise shift left

Return the bitwise shift left.

Definition at line 853 of file bi_math.c.

References c_shift(), and FALSE.

854 {
855 return (c_shift(FALSE));
856 }
c_shift
static long c_shift(long dir)
bitwise shift
Definition: bi_math.c:876
FALSE
#define FALSE
Standard boolean.
Definition: def_const.h:275

c_shift_right | ( |  | ) |
| static

brief bitwise shift right

Return the bitwise shift right.

Definition at line 864 of file bi_math.c.

References c_shift(), and TRUE.

865 {
866 return (c_shift(TRUE));
867 }
c_shift
static long c_shift(long dir)
bitwise shift
Definition: bi_math.c:876
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268

c_sin | ( |  | ) |
| static

sin Return the sine of the argument

Definition at line 627 of file bi_math.c.

References c_trig(), and SINFLAG.

628 {
629 return (c_trig(SINFLAG));
630 }
SINFLAG
#define SINFLAG
flag to c_trig to compute sin
Definition: def_const.h:1173
c_trig
static long c_trig(long trigflag)
trig functions
Definition: bi_math.c:556

static long c_sqrt | ( |  | ) |
| static

square root

c_sqrt() Return the square root of the argument

Definition at line 501 of file bi_math.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, Errorline(), FALSE, get_one_arg(), get_real_value(), nonnum_warning(), NULL, REAL, residuate2(), set_1, TRUE, and unify_real_result().

502 {
503 long success=TRUE;
504 ptr_psi_term arg1,arg3,t;
505 long num1,num3;
506 REAL val1,val3;
507
508 t=aim->aaaa_1;
509 deref_ptr(t);
510 get_one_arg(t->attr_list,&arg1);
511 arg3=aim->bbbb_1;
512
513 if (arg1) {
514 deref(arg1);
515 deref_args(t,set_1);
516 success=get_real_value(arg1,&val1,&num1);
517 if (success) {
518 deref(arg3);
519 success=get_real_value(arg3,&val3,&num3);
520 if (success)
521 switch(num1+num3*4) {
522 case 0:
523 residuate2(arg1,arg3);
524 break;
525 case 1:
526 if (val1>=0)
527 success=unify_real_result(arg3,sqrt(val1));
528 else {
529 success=FALSE;
530 Errorline("square root of negative number in %P.\n",t);
531 }
532 break;
533 case 4:
534 success=unify_real_result(arg1,val3*val3);
535 break;
536 case 5:
537 success=(val3*val3==val1 || (val1>=0 && val3==sqrt(val1)));
538 if (val1<0) Errorline("square root of negative number in %P.\n",t);
539 }
540 }
541 }
542 else
543 curry();
544
545 nonnum_warning(t,arg1,NULL);
546 return success;
547 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:239
get_real_value
long get_real_value(ptr_psi_term t, REAL *v, long *n)
get_real_value
Definition: built_ins.c:261
wl_psi_term
Definition: def_struct.h:177
nonnum_warning
void nonnum_warning(ptr_psi_term t, ptr_psi_term arg1, ptr_psi_term arg2)
nonnum_warning
Definition: error.c:953
get_one_arg
void get_one_arg(ptr_node t, ptr_psi_term *a)
get_one_arg
Definition: login.c:99
set_1
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
curry
void curry()
curry
Definition: lefun.c:174
NULL
#define NULL
Definition: def_const.h:533
REAL
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
Errorline
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
residuate2
void residuate2(ptr_psi_term u, ptr_psi_term v)
residuate2
Definition: lefun.c:144
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:100
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
FALSE
#define FALSE
Standard boolean.
Definition: def_const.h:275
deref
#define deref(P)
Definition: def_macro.h:147
aim
ptr_goal aim
Definition: def_glob.h:1024
deref_args
#define deref_args(P, S)
Definition: def_macro.h:150
unify_real_result
long unify_real_result(ptr_psi_term t, REAL v)
unify_real_result
Definition: built_ins.c:386
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:240
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:187

c_sub | ( |  | ) |
| static

subtraction

Subrtaction is considered as a 3-variable relation as in Prolog: arg1 - arg2 = arg3 Only it may residuate or curry. Subtraction is further complicated by the fact that it is both a unary and binary function.

Definition at line 1132 of file bi_math.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, FALSE, get_real_value(), get_two_args(), nonnum_warning(), NULL, push_goal(), REAL, residuate2(), residuate3(), set_1_2, TRUE, unify, and unify_real_result().

1133 {
1134 long success=TRUE;
1135 ptr_psi_term arg1,arg2,arg3,t;
1136 long num1,num2,num3;
1137 REAL val1,val2,val3;
1138
1139 t=aim->aaaa_1;
1140 deref_ptr(t);
1141 get_two_args(t->attr_list,&arg1,&arg2);
1142 arg3=aim->bbbb_1;
1143
1144 if(arg1) {
1145 deref(arg1);
1146 success=get_real_value(arg1,&val1,&num1);
1147 if(success && arg2) {
1148 deref(arg2);
1149 deref_args(t,set_1_2);
1150 success=get_real_value(arg2,&val2,&num2);
1151 }
1152 }
1153
1154 if(success)
1155 if(arg1 && arg2) {
1156 deref(arg3);
1157 success=get_real_value(arg3,&val3,&num3);
1158 if(success)
1159 switch(num1+num2*2+num3*4) {
1160 case 0:
1161 if (arg1==arg3)
1162 success=unify_real_result(arg2,(REAL)0);
1163 else if (arg1==arg2)
1164 success=unify_real_result(arg3,(REAL)0);
1165 else
1166 residuate3(arg1,arg2,arg3);
1167 break;
1168 case 1:
1169 if (arg2==arg3)
1170 success=unify_real_result(arg3,val1/2);
1171 else
1172 residuate2(arg2,arg3);
1173 break;
1174 case 2:
1175 if (val2) {
1176 if (arg1==arg3) /* 9.9 */
1177 success=FALSE;
1178 else
1179 residuate2(arg1,arg3);
1180 }
1181 else
1182 push_goal(unify,arg1,arg3,NULL);
1183 break;
1184 case 3:
1185 success=unify_real_result(arg3,val1-val2);
1186 break;
1187 case 4:
1188 if (arg1==arg2)
1189 success=(val3==0);
1190 else if (val3)
1191 residuate2(arg1,arg2);
1192 else
1193 push_goal(unify,arg1,arg2,NULL);
1194 break;
1195 case 5:
1196 success=unify_real_result(arg2,val1-val3);
1197 break;
1198 case 6:
1199 success=unify_real_result(arg1,val3+val2);
1200 break;
1201 case 7:
1202 success=(val3==val1-val2);
1203 break;
1204 }
1205 }
1206 else
1207 if(arg1) {
1208 deref(arg3);
1209 success=get_real_value(arg3,&val3,&num3);
1210 if(success)
1211 switch(num1+4*num3) {
1212 case 0:
1213 residuate2(arg1,arg3);
1214 break;
1215 case 1:
1216 success=unify_real_result(arg3,-val1);
1217 break;
1218 case 4:
1219 success=unify_real_result(arg1,-val3);
1220 break;
1221 case 5:
1222 success=(val1== -val3);
1223 }
1224 }
1225 else
1226 curry();
1227
1228 nonnum_warning(t,arg1,arg2);
1229 return success;
1230 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:239
get_two_args
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
push_goal
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
get_real_value
long get_real_value(ptr_psi_term t, REAL *v, long *n)
get_real_value
Definition: built_ins.c:261
wl_psi_term
Definition: def_struct.h:177
nonnum_warning
void nonnum_warning(ptr_psi_term t, ptr_psi_term arg1, ptr_psi_term arg2)
nonnum_warning
Definition: error.c:953
curry
void curry()
curry
Definition: lefun.c:174
NULL
#define NULL
Definition: def_const.h:533
REAL
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
set_1_2
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
residuate2
void residuate2(ptr_psi_term u, ptr_psi_term v)
residuate2
Definition: lefun.c:144
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:100
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
FALSE
#define FALSE
Standard boolean.
Definition: def_const.h:275
deref
#define deref(P)
Definition: def_macro.h:147
aim
ptr_goal aim
Definition: def_glob.h:1024
residuate3
void residuate3(ptr_psi_term u, ptr_psi_term v, ptr_psi_term w)
residuate3
Definition: lefun.c:159
unify
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
deref_args
#define deref_args(P, S)
Definition: def_macro.h:150
unify_real_result
long unify_real_result(ptr_psi_term t, REAL v)
unify_real_result
Definition: built_ins.c:386
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:240
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:187

c_tan | ( |  | ) |
| static

tangent

Return the tangent of the argument

Definition at line 638 of file bi_math.c.

References c_trig(), and TANFLAG.

639 {
640 return (c_trig(TANFLAG));
641 }
c_trig
static long c_trig(long trigflag)
trig functions
Definition: bi_math.c:556
TANFLAG
#define TANFLAG
flag to c_trig to compute tan
Definition: def_const.h:1187

c_trig | ( | long | trigflag | ) |
| static

trig functions

Parameters

  trigflag | SINFLAG, COSFLAG or TANFLAG

Main routine for sine and cosine

Definition at line 556 of file bi_math.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, COSFLAG, curry(), deref, deref_args, deref_ptr, FALSE, get_one_arg(), get_real_value(), nonnum_warning(), NULL, REAL, residuate2(), set_1, SINFLAG, TANFLAG, TRUE, and unify_real_result().

557 {
558 long success=TRUE;
559 ptr_psi_term arg1,arg3,t; /* arg3 is result */
560 long num1,num3;
561 REAL val1,val3,ans;
562
563 t=aim->aaaa_1;
564 deref_ptr(t);
565 get_one_arg(t->attr_list,&arg1);
566 arg3=aim->bbbb_1;
567
568 if (arg1) {
569 deref(arg1);
570 deref_args(t,set_1);
571 success=get_real_value(arg1,&val1,&num1);
572 if (success) {
573 deref(arg3);
574 success=get_real_value(arg3,&val3,&num3);
575 if (success)
576 switch(num1+num3*4) {
577 case 0:
578 residuate2(arg1,arg3);
579 break;
580 case 1:
581 ans=(trigflag==SINFLAG?sin(val1):
582 (trigflag==COSFLAG?cos(val1):
583 (trigflag==TANFLAG?tan(val1):0.0)));
584 success=unify_real_result(arg3,ans);
585 break;
586 case 4:
587 if (trigflag==TANFLAG || (val3>= -1 && val3<=1)) {
588 ans=(trigflag==SINFLAG?asin(val3):
589 (trigflag==COSFLAG?acos(val3):
590 (trigflag==TANFLAG?atan(val3):0.0)));
591 success=unify_real_result(arg1,ans);
592 }
593 else
594 success=FALSE;
595 break;
596 case 5:
597 ans=(trigflag==SINFLAG?asin(val1):
598 (trigflag==COSFLAG?acos(val1):
599 (trigflag==TANFLAG?atan(val1):0.0)));
600 success=(val3==ans);
601 }
602 }
603 }
604 else
605 curry();
606
607 nonnum_warning(t,arg1,NULL);
608 return success;
609 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:239
get_real_value
long get_real_value(ptr_psi_term t, REAL *v, long *n)
get_real_value
Definition: built_ins.c:261
wl_psi_term
Definition: def_struct.h:177
nonnum_warning
void nonnum_warning(ptr_psi_term t, ptr_psi_term arg1, ptr_psi_term arg2)
nonnum_warning
Definition: error.c:953
get_one_arg
void get_one_arg(ptr_node t, ptr_psi_term *a)
get_one_arg
Definition: login.c:99
set_1
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
curry
void curry()
curry
Definition: lefun.c:174
NULL
#define NULL
Definition: def_const.h:533
REAL
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
residuate2
void residuate2(ptr_psi_term u, ptr_psi_term v)
residuate2
Definition: lefun.c:144
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:100
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
FALSE
#define FALSE
Standard boolean.
Definition: def_const.h:275
deref
#define deref(P)
Definition: def_macro.h:147
SINFLAG
#define SINFLAG
flag to c_trig to compute sin
Definition: def_const.h:1173
COSFLAG
#define COSFLAG
flag to c_trig to compute cos
Definition: def_const.h:1180
aim
ptr_goal aim
Definition: def_glob.h:1024
deref_args
#define deref_args(P, S)
Definition: def_macro.h:150
unify_real_result
long unify_real_result(ptr_psi_term t, REAL v)
unify_real_result
Definition: built_ins.c:386
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:240
TANFLAG
#define TANFLAG
flag to c_trig to compute tan
Definition: def_const.h:1187
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:187

insert_math_builtins | ( |  | ) |

insert math builtins into table

insert functions into table

Definition at line 1346 of file bi_math.c.

References bi_module, c_add(), c_bit_and(), c_bit_not(), c_bit_or(), c_ceiling(), c_cos(), c_div(), c_exp(), c_floor(), c_intdiv(), c_log(), c_mod(), c_mult(), c_shift_left(), c_shift_right(), c_sin(), c_sqrt(), c_sub(), c_tan(), function_it, new_built_in(), and syntax_module.

1347 {
1348 new_built_in(syntax_module,"*",(def_type)function_it,c_mult);
1349 new_built_in(syntax_module,"+",(def_type)function_it,c_add);
1350 new_built_in(syntax_module,"-",(def_type)function_it,c_sub);
1351 new_built_in(syntax_module,"/",(def_type)function_it,c_div);
1352 new_built_in(syntax_module,"//",(def_type)function_it,c_intdiv);
1353 new_built_in(syntax_module,"mod",(def_type)function_it,c_mod); /* PVR 24.2.94 */
1354 new_built_in(syntax_module,"/\\",(def_type)function_it,c_bit_and);
1355 new_built_in(syntax_module,"\\/",(def_type)function_it,c_bit_or);
1356 new_built_in(syntax_module,"\\",(def_type)function_it,c_bit_not);
1357 new_built_in(syntax_module,">>",(def_type)function_it,c_shift_right);
1358 new_built_in(syntax_module,"<<",(def_type)function_it,c_shift_left);
1359 new_built_in(bi_module,"floor",(def_type)function_it,c_floor);
1360 new_built_in(bi_module,"ceiling",(def_type)function_it,c_ceiling);
1361 new_built_in(bi_module,"exp",(def_type)function_it,c_exp);
1362 new_built_in(bi_module,"log",(def_type)function_it,c_log);
1363 new_built_in(bi_module,"cos",(def_type)function_it,c_cos);
1364 new_built_in(bi_module,"sin",(def_type)function_it,c_sin);
1365 new_built_in(bi_module,"tan",(def_type)function_it,c_tan);
1366 new_built_in(bi_module,"sqrt",(def_type)function_it,c_sqrt);
1367 }
c_mult
static long c_mult()
multiplication
Definition: bi_math.c:28
new_built_in
void new_built_in(ptr_module m, char *s, def_type t, long(*r)())
new_built_in
Definition: built_ins.c:5375
function_it
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
c_shift_right
static long c_shift_right()
Definition: bi_math.c:864
c_log
static long c_log()
natural logarithm
Definition: bi_math.c:1238
c_shift_left
static long c_shift_left()
bitwise shift left
Definition: bi_math.c:853
c_sub
static long c_sub()
subtraction
Definition: bi_math.c:1132
c_bit_not
static long c_bit_not()
bitwise not
Definition: bi_math.c:649
syntax_module
ptr_module syntax_module
Module for minimal Prolog syntax.
Definition: def_glob.h:715
c_div
static long c_div()
division
Definition: bi_math.c:138
c_floor
static long c_floor()
floor
Definition: bi_math.c:479
c_intdiv
static long c_intdiv()
integer division
Definition: bi_math.c:264
c_bit_or
static long c_bit_or()
bitwise or
Definition: bi_math.c:785
c_bit_and
static long c_bit_and()
bitwise and
Definition: bi_math.c:703
c_ceiling
static long c_ceiling()
ceiling
Definition: bi_math.c:490
c_exp
static long c_exp()
exponential
Definition: bi_math.c:1295
c_cos
static long c_cos()
cosine
Definition: bi_math.c:617
wl_definition
Definition: def_struct.h:145
bi_module
ptr_module bi_module
Module for public built-ins.
Definition: def_glob.h:687
c_sin
static long c_sin()
sin Return the sine of the argument
Definition: bi_math.c:627
c_add
static long c_add()
addition
Definition: bi_math.c:1016
c_sqrt
static long c_sqrt()
square root
Definition: bi_math.c:501
c_tan
static long c_tan()
tangent
Definition: bi_math.c:638
c_mod
static long c_mod()
modulo
Definition: bi_math.c:945