11 p1
->u
.str
=(char *)malloc(strlen(s
)+1);
12 memcpy(p1
->u
.str
,s
,strlen(s
)+1);
20 stop("out of memory");
24 push_zero_matrix(int i
, int j
)
26 push(alloc_tensor(i
* j
));
27 stack
[tos
- 1]->u
.tensor
->ndim
= 2;
28 stack
[tos
- 1]->u
.tensor
->dim
[0] = i
;
29 stack
[tos
- 1]->u
.tensor
->dim
[1] = j
;
33 push_identity_matrix(int n
)
36 push_zero_matrix(n
, n
);
37 for (i
= 0; i
< n
; i
++)
38 stack
[tos
- 1]->u
.tensor
->elem
[i
* n
+ i
] = one
;
63 print_lisp(stack
[tos
- 2]);
64 print_lisp(stack
[tos
- 1]);
70 if (cmp_expr(p1
, p2
) == 0)
79 if (cmp_expr(p1
, p2
) < 0)
97 cmp_expr(U
*p1
, U
*p2
)
104 if (p1
== symbol(NIL
))
107 if (p2
== symbol(NIL
))
110 if (isnum(p1
) && isnum(p2
))
111 return sign(compare_numbers(p1
, p2
));
119 if (isstr(p1
) && isstr(p2
))
120 return sign(strcmp(p1
->u
.str
, p2
->u
.str
));
128 if (issymbol(p1
) && issymbol(p2
))
129 return sign(strcmp(get_printname(p1
), get_printname(p2
)));
137 if (istensor(p1
) && istensor(p2
))
138 return compare_tensors(p1
, p2
);
146 while (iscons(p1
) && iscons(p2
)) {
147 n
= cmp_expr(car(p1
), car(p2
));
174 static void unique_f(U
*);
183 if (p2
!= symbol(NIL
))
194 if (p1
== symbol(NIL
))
202 if (p2
!= symbol(NIL
))
211 check_endianess(void)
214 if (((char *) &tmp
)[0] == 1 && Y_LITTLE_ENDIAN
== 0) {
215 printf("Please change Y_LITTLE_ENDIAN to 1 in defs.h and recompile.");
218 if (((char *) &tmp
)[0] == 0 && Y_LITTLE_ENDIAN
!= 0) {
219 printf("Please change Y_LITTLE_ENDIAN to 0 in defs.h and recompile.");
259 __cmp(const void *p1
, const void *p2
)
261 return cmp_expr(*((U
**) p1
), *((U
**) p2
));
267 qsort(stack
+ tos
- n
, n
, sizeof (U
*), __cmp
);