		/** Efficient Mcb **/

/*K: Cb, Mcb, Combine */
/*A: John Gottschalk */
/*S: University of Western Australia */
/*D: January 1987 */

Loadonce[XProjfind]

/*: Emcb[$expr,$forms]
	combines coefficients of $forms in $expr, where $forms may be
	products or divisions, which Cb does not at the moment
	handle. This is a more memory efficient, though much slower, 
	version of MCb[$ex[r,$forms] of SMP version 1.5.0. The 
	problems with MCb is in the way it applies the inefficient
	system-defined functions of S and Cb. When these are
	improved this file will be redundant. */
Emcb_:Tier
Emcb[$expr,$v] :: (Lcl[%e,%f]; \
		   %e : Map[S[$1,$v->%f[$v]],$expr]; \
		   %e : Ecb[%e]; \
		   Map[S[$1,%f[$v] -> $v],%e])

/*F: Modify Emcb[$expr,$forms] so that $forms can be a list. */

/*: Ecb[$expr]
	is a more efficient version of Cb. It is designed specifically for
	Emcb[$expr,$v]. */
Ecb_:Tier
Ecb[$expr] :: (Lcl[%expr,%i,%pos]; \
	%pos : Projfind['%f,$expr]; \
	%expr : $expr; \
	Do[%i,1,Len[%pos],,%expr : Cb[%expr,%pos[%i]]]; \
	%expr)

