how about we use same method for invert(A) as for A^^-1 ?



At this point I'd like to propose that invert be renamed to
invert_by_adjoint and the hitherto-undocumented invertmx (which is
called by A^^-1 to do the work) be renamed to invert.

On 2012-12-10, Barton Willis <willisb at unk.edu> wrote:

> Algorithmically, I don't feel the love for the adjoint method for
> matrix inversion.  Is there a difference between invert and ^^-1 when
> modulus # false?

The only different between invert(A) and A^^-1 that I can see is that
invert(A) doesn't convert elements to CRE while A^^-1 does.
E.g. if A has bigfloat elements, A^^-1 converts them to rationals while
invert(A) leaves them be.

invert(A) also honors some flags (e.g. detout) which, I suppose, some
user might possibly want.

> This works the way I expect:
>
> (%i6) m . invert_by_lu(m, noncommutingring);
> (%o6) matrix([matrix([1,0],[0,1]),matrix([0,0],[0,0])],[matrix([0,0],[0,0]),matrix([1,0],[0,1])])

That's good, although invert_by_lu isn't entirely successful with
nonscalar elements. E.g.:

  declare ([a, b, c, d], nonscalar);
  matrix_element_mult : ".";
  matrix_element_transpose : 'transpose;
  A : matrix ([a, b], [c, d]);
  A1 : invert_by_lu (A, noncommutingring);
   => matrix([a^^(-1) . (b . (d-c . a^^(-1) . b)^^(-1) . c . a^^(-1)+1),
              -a^^(-1) . b . (d-c . a^^(-1) . b)^^(-1)],
             [-(d-c . a^^(-1) . b)^^(-1) . c . a^^(-1),
              (d-c . a^^(-1) . b)^^(-1)])

  expand (A . A1);
   => matrix([1,0],
             [-d . (d-c . a^^(-1) . b)^^(-1) . c . a^^(-1)
               +c . a^^(-1) . b . (d-c . a^^(-1) . b)^^(-1) . c .  a^^(-1)
               +c . a^^(-1),
              d . (d-c . a^^(-1) . b)^^(-1)
               -c . a^^(-1) . b . (d-c . a^^(-1) . b)^^(-1)])

  expand (A1 . A);
   => matrix([1,
              -a^^(-1) . b . (d-c . a^^(-1) . b)^^(-1) . d
               +a^^(-1) . b . (d-c . a^^(-1) . b)^^(-1) . c . a^^(-1) .  b
               +a^^(-1) . b],
             [0,
              (d-c . a^^(-1) . b)^^(-1) . d
               -(d-c . a^^(-1) . b)^^(-1) . c . a^^(-1) . b])

When the elements are in a noncommutative ring, is the matrix inverse
well-defined? Maybe there is only a left or right inverse? I don't know.

Maybe A . A1 and A1 . A could be reduced to 1's and 0's by enabling some
flags? Dunno.

best

Robert Dodier