eigenmath/product.cpp

58 lines
732 B
C++
Raw Permalink Normal View History

2008-08-10 03:01:00 +02:00
// 'product' function
2004-03-03 21:24:06 +01:00
#include "stdafx.h"
#include "defs.h"
2008-08-10 03:01:00 +02:00
#define A p3
#define B p4
#define I p5
#define X p6
2004-03-03 21:24:06 +01:00
void
eval_product(void)
{
2008-08-10 03:01:00 +02:00
int i, j, k;
// 1st arg (quoted)
X = cadr(p1);
2008-08-15 07:34:58 +02:00
if (!issymbol(X))
stop("product: 1st arg?");
2008-08-10 03:01:00 +02:00
// 2nd arg
2004-03-03 21:24:06 +01:00
push(caddr(p1));
eval();
2008-08-10 03:01:00 +02:00
j = pop_integer();
if (j == (int) 0x80000000)
stop("product: 2nd arg?");
2004-03-03 21:24:06 +01:00
2008-08-10 03:01:00 +02:00
// 3rd arg
2004-03-03 21:24:06 +01:00
2008-08-10 03:01:00 +02:00
push(cadddr(p1));
eval();
2004-03-03 21:24:06 +01:00
k = pop_integer();
2008-08-10 03:01:00 +02:00
if (k == (int) 0x80000000)
stop("product: 3rd arg?");
2004-03-03 21:24:06 +01:00
2008-08-10 03:01:00 +02:00
// 4th arg
2004-03-03 21:24:06 +01:00
2008-08-10 03:01:00 +02:00
p1 = caddddr(p1);
B = get_binding(X);
A = get_arglist(X);
2004-03-03 21:24:06 +01:00
2008-08-10 03:01:00 +02:00
push_integer(1);
2004-03-03 21:24:06 +01:00
for (i = j; i <= k; i++) {
push_integer(i);
2008-08-10 03:01:00 +02:00
I = pop();
set_binding(X, I);
push(p1);
2006-10-06 20:28:26 +02:00
eval();
2008-08-10 03:01:00 +02:00
multiply();
2004-03-03 21:24:06 +01:00
}
2006-10-06 20:28:26 +02:00
2008-08-10 03:01:00 +02:00
set_binding_and_arglist(X, B, A);
2004-03-03 21:24:06 +01:00
}