Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2001
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2001

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

Search the Archive

Programming question about multiple assignments in the Coefficients Matrix

  • To: mathgroup at smc.vnet.net
  • Subject: [mg28493] Programming question about multiple assignments in the Coefficients Matrix
  • From: "J. Guillermo Sanchez" <guillerm at gugu.usal.es>
  • Date: Sun, 22 Apr 2001 01:30:24 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Dear friends:

I have built the following expressions


A[n_] := Module[{A}, A = DiagonalMatrix[Table[-Sum[k[i, j], {j, 0, 
n}], {i, 1, n}]] + Table[k[j, i], {i, 1, n}, {j, 1, n}]];

k[i_,j_,a_:h]:=k[i,j]= Block[{h=0},a];


(This matrix is usually called Coefficients Matrix)

With these functions I obtain the solution that I was looking for. For 
instance:


k[1,2,2] ;k[2,1,1];k[1,0,0.7];k[1,3,0.3] ;k[3,0,1];k[3,1,1];

A[3]//MatrixForm


But need to apply the above functions in only one sentence to make a 
package. I mean, I wish build a function like this (of course it doesn't 
work)


A[n_, k[i_,j_,a_:h]]:=

Module[{k,A},A=DiagonalMatrix[Table[-Sum[k[i,j],{j,0,n}],{i,1,n}]]+Table[k[j,i],{i,1,n},{j,1,n}]; k=k[i,j]=Block[{h=0},a];A]


In the way that it was applied obtaining the same solution that before


A[3,k[1,2,2];k[2,1,1];k[1,0,0.7];k[1,3,0.3];k[3,0,1];k[3,1,1]];


Any suggestion?


  • Prev by Date: Frequent crashing problem
  • Next by Date: Re: PC - Mac Compatibility
  • Previous by thread: Re: Frequent crashing problem
  • Next by thread: Re: Programming question about multiple assignments in the Coefficients Matrix