MathGroup Archive 2006

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

Search the Archive

Re: Define a matrix function with size as argument

  • To: mathgroup at smc.vnet.net
  • Subject: [mg71387] Re: Define a matrix function with size as argument
  • From: "andre.robin3" <andre.robin3 at wanadoo.fr>
  • Date: Thu, 16 Nov 2006 00:53:47 -0500 (EST)
  • Organization: les newsgroups par Orange
  • References: <ejf10f$4pt$1@smc.vnet.net>

Remove MatrixForm from your definition of Q[w_]
Example : Q[w_]= SparseArray[ ... ]

Use MatrixFrom only to see the matrix in the conventionnal school form (a
table
into parenthesis).

Example :
Q[w_]= SparseArray[ ... ]
MatrixForm[Q[2]]
MatrixForm[Inverse[Q[2]]]

If you want to make a definition and see the matrix in one line, use for
example :
MatrixForm[ newDefinedVariable=Q[2] ] so that the "wrapper" MatrixFrom
is not affected to newDefinedVariable.


"Simone Giannerini" <sgiannerini at gmail.com> a écrit dans le message de news:
ejf10f$4pt$1 at smc.vnet.net...
> Dear all,
>
> I am quite new to Mathematica and I have the following problem I could
> not find track of both in the Forum and in the documentation.
> I need to define a matrix function with size of the matrix as an
> argument. The function produces a tridiagonal matrix:
>
> Q[w_] := MatrixForm[SparseArray[
>     {i_, j_} /; Abs[i - j] <= 1 -> Which[i < j,
>       a[i - 1]*(1 - (i - 1)/(2*w)), i > j,
>       (a[-i + 2*w + 1]*(i - 1))/(2*w), i == j,
>       (-(1 - (i - 1)/(2*w)))*a[i - 1] -
>        (a[-i + 2*w + 1]*(i - 1))/(2*w) + 1],
>     {2*w, 2*w}]]
>
>
> dum = Q[2]
>
> the problem is that dum is not recognized as a matrix so that
> operations like Inversion and the like do not work.
>
> Many thanks for your attention.
>
> Kind regards,
> ______________________________________________________
>
> Simone Giannerini
> Dipartimento di Scienze Statistiche "Paolo Fortunati"
> Universita' di Bologna
> Via delle belle arti 41 - 40126  Bologna,  ITALY
> Tel: +39 051 2098262  Fax: +39 051 232153
> ______________________________________________________
>



  • Prev by Date: RE: Define a matrix function with size as argument
  • Next by Date: Re: Define a matrix function with size as argument
  • Previous by thread: RE: Define a matrix function with size as argument
  • Next by thread: Re: Define a matrix function with size as argument