MathGroup Archive 2002

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

Search the Archive

RE: common factors in a matrix


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






  • 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