Skip to content

Commit

Permalink
Use BinomialInt in dt.c and dteval.c, remove binomial
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Pfeiffer authored and fingolfin committed Feb 3, 2018
1 parent e0c0804 commit f16d0bd
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 36 deletions.
30 changes: 1 addition & 29 deletions src/dt.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ Obj MakeFormulaVector(
if ( ELM_PLIST(rel, j) == gen )
{
prod = ProdInt(ELM_PLIST(vec, 2),
binomial(ELM_PLIST(rel, j+1),
BinomialInt(ELM_PLIST(rel, j+1),
INTOBJ_INT(i) ) );
SET_ELM_PLIST(vec, 2, prod);
/* tell gasman that vec has changed */
Expand Down Expand Up @@ -680,34 +680,6 @@ Obj FuncMakeFormulaVector(
}


/*****************************************************************************
**
*F binomial(<n>, <k>) . . . . . . . . . binomial coefficient of <n> and <k>
**
** 'binomial' returns the binomial coefficient of the integers <n> and <k>.
*/
Obj binomial( Obj n,
Obj k )
{
UInt j, kc;
Obj bin, help;

if ( LtInt( INTOBJ_INT(0), n) && LtInt(n, k) )
return INTOBJ_INT(0);
if ( IS_INTOBJ(n) && n == k )
return INTOBJ_INT(1);
kc = INT_INTOBJ(k);
bin = INTOBJ_INT(1);
help = DiffInt(n, k);
for (j=1; j<=kc; j++)
bin = ProdInt( bin, SumInt(help, INTOBJ_INT(j) ) );
for (j=1; j<=kc; j++)
bin = QuoInt(bin, INTOBJ_INT(j) );
return bin;
}



/****************************************************************************
**
*F Leftof(<tree1>,<index1>,<tree2>,<index2>) . . . . test if one tree is left
Expand Down
5 changes: 0 additions & 5 deletions src/dt.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ extern Obj MakeFormulaVector(
Obj pr );


extern Obj binomial(
Obj n,
Obj k );


extern Int Leftof(
Obj tree1,
Int index1,
Expand Down
4 changes: 2 additions & 2 deletions src/dteval.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Obj Evaluation(
if ( IS_INTOBJ(power) && INT_INTOBJ(power) > 0 &&
power < ELM_PLIST(vec, 6) )
return INTOBJ_INT(0);
prod = binomial(power, ELM_PLIST(vec, 6) );
prod = BinomialInt(power, ELM_PLIST(vec, 6) );
len = LEN_PLIST(vec);
for (i=7; i < len; i+=2)
{
Expand All @@ -141,7 +141,7 @@ Obj Evaluation(
( INT_INTOBJ(help) == 0 ||
( INT_INTOBJ(help) > 0 && help < ELM_PLIST(vec, i+1) ) ) )
return INTOBJ_INT(0);
prod = ProdInt( prod, binomial( help, ELM_PLIST(vec, i+1) ) );
prod = ProdInt( prod, BinomialInt(help, ELM_PLIST(vec, i+1) ) );
}
return prod;
}
Expand Down

0 comments on commit f16d0bd

Please sign in to comment.