RE: common factors in a matrix
- To: mathgroup at smc.vnet.net
- Subject: [mg33596] RE: common factors in a matrix
- From: Bart Vorselaars <fourteen at stack.nl>
- Date: Wed, 3 Apr 2002 01:13:18 -0500 (EST)
- Organization: Eindhoven University of Technology, The Netherlands
- References: <a86ki1$jsj$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Thanks for responding to my question. The routine I use now, is a altered version of David's FactorMatrix[mat]. This can handle any matrix (I think :), even ones which are already 'factorized': (*Remove common factors :*) FactorMatrix2[(mat_)?MatrixQ] := Module[{contracted, flatmat, fcontracted, prefactor, \[CapitalPsi]\[CapitalPsi]\[CapitalPsi], mult1, mult2}, contracted = 0; flatmat = Flatten[mat]; Do[contracted = contracted + flatmat[[ii]]*\[CapitalPsi]\[CapitalPsi]\[CapitalPsi][ii], {ii, 1, Length[flatmat]}]; fcontracted = Factor[contracted]; If[Head[fcontracted] === Head[mult1 mult2], prefactor = Drop[fcontracted, -1]; HoldForm @@ {prefactor}* MatrixForm[Map[Cancel[#1/prefactor] &, mat, {2}]], MatrixForm[mat]]] Bart