MathGroup Archive 2009

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

Search the Archive

Re: MatrixForm affects values instead of only printing

  • To: mathgroup at smc.vnet.net
  • Subject: [mg100351] Re: [mg100298] MatrixForm affects values instead of only printing
  • From: Peter Falloon <pfalloon at gmail.com>
  • Date: Mon, 1 Jun 2009 07:11:58 -0400 (EDT)
  • References: <200905311035.GAA16937@smc.vnet.net>

This is normal behaviour and applies also to TableForm and various others.
The documentation actually refers to such things as "wrappers", which affect
printing but not evaluation. This means they just add a wrapper without
affecting the contents (this is why you're able to retrieve the original
matrix via test1[[1]]), but it doesn't mean the wrapper is invisible.

I think the key is to avoid using MatrixForm in definitions and only call it
for display purposes. So, where you had something like

mat = {{1,2}, {3,4}} // TableForm

you should add some parentheses so that the TableForm occurs outside of the
Set operation:

(mat = {{1,2}, {3,4}}) // TableForm

Cheers,
Peter

On Sun, May 31, 2009 at 8:35 PM, summer <summertan at hotmail.com> wrote:

> Here is the example:
>
> test1={-3, 7, 5}
> test1[[3]]
>
> returns the list and 5 as expected;
>
> test2={-3, 7, 5}//MatrixForm
> test2[[3]]
>
> returns a column vector and error: "part 3 of blah blah doesn't exist". The
> actual list itself is test2[[1]]. To get the right 3rd element I have to do:
>
> test2[[1,3]]
>
> which returns 5 as expected.
>
>
> The problem is MatrixForm is NOT supposed to change the expression it is
> applied on according to the manual. Is that a bug or there's logical
> explanation?
>


  • Prev by Date: Re: Indexed Slot in a Rule - How to do it??
  • Next by Date: Re: How can I get the previous Fibonacci calculated
  • Previous by thread: Re: MatrixForm affects values instead of only printing
  • Next by thread: Re: MatrixForm affects values instead of only printing