MathGroup Archive 1995

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

Search the Archive

Re: matrix evaluation

  • To: mathgroup at christensen.cybernetics.net
  • Subject: [mg853] Re: matrix evaluation
  • From: rubin at msu.edu (Paul A. Rubin)
  • Date: Wed, 26 Apr 1995 00:20:22 -0400
  • Organization: Michigan State University

In article <3mf9us$l4o at news0.cybernetics.net>,
   wacb at aplcomm.jhuapl.edu (Bill Christens-Barry) wrote:
->Please help me understand why the notebook below gags when it tries to
->evaluate/generate the matrix qmat.  This occurs on a Macintosh IIfx under
->System 7.5.
[chomp]
->*A troublesome notebook with it's output:*
->N[matr = Table[Random[], {i,1,8}, {j,1,8}],4]
[chomp]
->N[coocc = MatrixForm[Table[matr[[i,j]], {i,1,8}, {j,1,8}]],4]
[chomp]
->Some function definitions:
->pX[i_] := Sum[coocc[[i,j]], {j,1,8}]
->pY[j_] := Sum[coocc[[i,j]], {i,1,8}]
->pXplsY[k_] := Sum[coocc[[i,j]] (If[i+j==k,1,0]), {i,1,8}, {j,1,8}]
->pXmnsY[k_] := Sum[coocc[[i,j]] (If[Abs[i-j]==k,1,0]), {i,1,8}, {j,1,8}]
->q[i_, j_] := Sum[(coocc[[i,k]] coocc[[k,j]]) / (pX[i] pY[k]), {k,1,8}]
->*------Evaluation of the following line is where trouble occurs:-------*
->N[qmat = Table[q[i,j], {i,1,8}, {j,1,8}],4]
->*And below is the red letter output I get before I terminate evaluation:*
->Part::partw: Part 2 of [copious stuff deleted]     does not exist.
->
[chomp]
->A different but related problem occurs when I run this on a Macintosh
->Quadra 660AV.  On that machine the evaluation of the function pX[i_]
->generates an 8-element
->list (vector) instead of a single element result (scalar) for pX[1].
->And evaluation of pX[2], pX[3],... produces an error.  Same thing for 
pY[j_].

The source of the first problem (and quite possibly the source of other 
problems) is your use of MatrixForm in the line defining coocc.  You 
didn't just print out coocc in matrix form, you made MatrixForm part of 
its definition.  If you type in Head[coocc], you will find that coocc 
contains not a matrix (list of lists) but an object with head MatrixForm 
(and body equal to the desired matrix).  Changing

     N[coocc = MatrixForm[Table[matr[[i,j]], {i,1,8}, {j,1,8}]],4]

to 

     MatrixForm[N[coocc = Table[matr[[i,j]], {i,1,8}, {j,1,8}],4]]

should do the trick.

Paul


**************************************************************************
* Paul A. Rubin                                  Phone: (517) 432-3509   *
* Department of Management                       Fax:   (517) 432-1111   *
* Eli Broad Graduate School of Management        Net:   RUBIN at MSU.EDU    *
* Michigan State University                                              *
* East Lansing, MI  48824-1122  (USA)                                    *
**************************************************************************
Mathematicians are like Frenchmen:  whenever you say something to them,
they translate it into their own language, and at once it is something
entirely different.                                    J. W. v. GOETHE


  • Prev by Date: Re: simplex tableau help wanted
  • Next by Date: Re: Extracting data points from Plot[]
  • Previous by thread: Mathematica in Calculus Workshop
  • Next by thread: Help using Compile with Solve