Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: common factors in a matrix

  • To: mathgroup at
  • Subject: [mg33596] RE: common factors in a matrix
  • From: Bart Vorselaars <fourteen at>
  • Date: Wed, 3 Apr 2002 01:13:18 -0500 (EST)
  • Organization: Eindhoven University of Technology, The Netherlands
  • References: <a86ki1$jsj$>
  • Sender: owner-wri-mathgroup at

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,
        Length[flatmat]}]; fcontracted = Factor[contracted];
    If[Head[fcontracted] === Head[mult1 mult2],
      prefactor = Drop[fcontracted, -1];
      HoldForm @@ {prefactor}*
        MatrixForm[Map[Cancel[#1/prefactor] &, mat, {2}]],


  • Prev by Date: Re: Mathlink formulas return different results
  • Next by Date: Math::ematica Perl module
  • Previous by thread: Re: Mathlink formulas return different results
  • Next by thread: Math::ematica Perl module