MathGroup Archive 2003

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

Search the Archive

Re: Re: Transpose matrix does not work when MatrixForm is used, why?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg45277] Re: [mg45264] Re: Transpose matrix does not work when MatrixForm is used, why?
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Sat, 27 Dec 2003 05:00:16 -0500 (EST)
  • References: <bruqrt$t0p$1@smc.vnet.net> <bs1b8r$9m0$1@smc.vnet.net> <200312210842.DAA18953@smc.vnet.net> <B8E20599-352B-11D8-8801-00039311C1CC@mimuw.edu.pl> <bsbmsb$lr1$1@smc.vnet.net> <200312242242.RAA27805@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Well, actually there is nothing to stop one doing this now.

In[1]:=
Unprotect[MatrixForm];

In[2]:=
MatrixForm/:f_[MatrixForm[expr_]]:=MatrixForm[f[expr]]

In[3]:=
Protect[MatrixForm];

In[4]:=
m={{1,2,3},{4,5,6},{0,1,0}}//MatrixForm

Now try:

Transpose[m]

or

Inverse[m]

As you see this seems to work already. Of course it still needs more 
work: it should be extended to functions of several arguments with 
MatrixForm heads, and one should also think more about unforeseen 
consequences.
Still, I have to say that I have recently started (after years of 
persuasion by Paul Abbott) to use TraditionalForm for input and output 
and now I don't feel this sort of thing is needed. In fact it may not 
always be what one wants. One example that comes to my mind is form my 
own recent lectures on linear algebra when I used formulae with 
MatrixForm wrapped around matrices when I did not want to expressions 
(products) to evaluate.

Andrzej Kozlowski

On 25 Dec 2003, at 07:42, steve_H wrote:

> Dr Bob <drbob at bigfoot.com> wrote in message 
> news:<bsbmsb$lr1$1 at smc.vnet.net>...
>
>> That may be easier... if we are willing to constantly pay attention to
>> whether the target of Transpose is "wrapped" in MatrixForm or not.
>> (Transpose/@m if it's wrapped, Transpose@m if not.)
>>
>> But if we want Help's claim that evaluation is not affected to be 
>> true (it
>> currently is NOT), then we have to redefine Transpose, Inverse, etc. 
>> as in
>> my example.
>>
>> Only then would MatrixForm act properly as a wrapper, as intended.
>>
>> Bobby
>>
>
>
>> On Tue, 23 Dec 2003 18:38:10 +0900, Andrzej Kozlowski 
>> <akoz at mimuw.edu.pl>
>> wrote:
>>
>>> This of course works, but presumably he would want do this for other
>>> functions, (e.g. Inverse etc), not just transpose. So it seems to me 
>>> it
>>> is easier simply to use Map:
>>>
>>> m = { {1, 2, 3}, {4, 5, 6} } // MatrixForm
>>> Transpose/@m
>>>
>>> etc.
>>>
>>> Andrzej Kozlowski
>>>
>
>
> Correct Dr Bob,
>
> But why do we have to resort to all these tricks? Why can't 
> Mathematica just
> accept a MatrixForm (or any other representation form) of the object
> in its functions (Transpose in this example) just as well as the
> list representation?
>
> Each Mathematica function, where needed, could start by checking if 
> this
> 'Wrapper' as you call it exists, and converts it to a list
> representation (remove the wrapper), and do its thing on the list,
> and at the end put the 'wrapper' around the result as needed and
> return the result to the user?
>
> This way one does not have to worry which form of an object one uses,
> the representation form or the list form.
>
> i.e. representation form will be transparent to all Mathematica 
> functions.
>
>


  • Prev by Date: AW: Re: Transpose matrix does not work when MatrixForm is used, why?
  • Next by Date: Re: Politically incorrect response to Re: a bug in RealDigits? Mathematica 5.0
  • Previous by thread: Re: Transpose matrix does not work when MatrixForm is used, why?
  • Next by thread: Re: Transpose matrix does not work when MatrixForm is used, why?