repo.or.cz
/
eigenmath-fx.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Little fix after the last commit (mostly a git fail)
[eigenmath-fx.git]
/
zero.cpp
blob
01f8b27ed902aa7289de699f663415864df322c1
1
#include
"stdafx.h"
2
#include
"defs.h"
3
4
void
5
eval_zero
(
void
)
6
{
7
int
i
,
k
[
MAXDIM
],
m
,
n
;
8
m
=
1
;
9
n
=
0
;
10
p2
=
cdr
(
p1
);
11
while
(
iscons
(
p2
)) {
12
push
(
car
(
p2
));
13
eval
();
14
i
=
pop_integer
();
15
if
(
i
<
2
) {
16
push
(
zero
);
17
return
;
18
}
19
m
*=
i
;
20
k
[
n
++] =
i
;
21
p2
=
cdr
(
p2
);
22
}
23
if
(
n
==
0
) {
24
push
(
zero
);
25
return
;
26
}
27
p1
=
alloc_tensor
(
m
);
28
p1
->
u
.
tensor
->
ndim
=
n
;
29
for
(
i
=
0
;
i
<
n
;
i
++)
30
p1
->
u
.
tensor
->
dim
[
i
] =
k
[
i
];
31
push
(
p1
);
32
}
33
34
#if SELFTEST
35
36
static char
*
s
[] = {
37
38
"zero(2,2)"
,
39
"((0,0),(0,0))"
,
40
41
"zero(1,1)"
,
42
"0"
,
43
};
44
45
void
46
test_zero
(
void
)
47
{
48
test
(
__FILE__
,
s
,
sizeof
s
/
sizeof
(
char
*));
49
}
50
51
#endif