MathGroup Archive 2004

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

Search the Archive

Re: matrix operations

  • To: mathgroup at smc.vnet.net
  • Subject: [mg48419] Re: matrix operations
  • From: Erich Neuwirth <erich.neuwirth at univie.ac.at>
  • Date: Sat, 29 May 2004 03:06:39 -0400 (EDT)
  • References: <c0qim0$k5s$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

DiffMat[n_, k_] := Table[KroneckerDelta[i, j - 1] -
		KroneckerDelta[i, j], {i, 1, n - 1}, {j, 1, k}]

mat = Array[x, {4, 4}]
DiffMat[4,4].mat

is a linear algebra way of doing it.



David Park wrote:

> Paolo,
> 
> The wonders of functional programming! Here's an example.
> 
> mat = Array[x, {4, 4}]
> 
> Partition[mat, 2, 1]
> (answer = #2 - #1 & @@@ %) // MatrixForm
> 
> @@@ is the Apply function, mapped onto the first level of mat. #2 - #1& is a
> pure function that subtracts the second argument from the first argument.
> 
> David Park
> djmp at earthlink.net
> http://home.earthlink.net/~djmp/
> 
> 
> -----Original Message-----
> From: paolo tarpanelli [mailto:tarpanelli at libero.it]
To: mathgroup at smc.vnet.net
> Subject: [mg48419]  matrix operations
> 
> 
> If I have a matrix
> 
> a={x[[1,1]],x[[1,2]],...,x[[1,n]]}
>     {x[[2,1]],x[[2,2]],...,x[[2,n]]}
>             .
>             .
>             .
>     {x[[m,1]],x[[m,2]],...,x[[m,n]]}
> 
> how can I compute the difference between any element and the previous for
> each column :
> 
> aa={x[[2,1]]-x[[1,1]], x[[2,2]]-x[[1,2]],...,x[[2,n]]-x[[1,n]]}
>       {x[[3,1]]-x[[2,1]], x[[3,2]]-x[[2,2]],...,x[[3,n]]-x[[2,n]]}
>             .
>             .
>             .
>       {x[[m,1]]-x[[m-1,1]],x[[m,2]]-x[[m-1,2]],...,x[[m,n]]-x[[m-1,n]]}
> 
> ----------------------------------------------------------------------------
> --------------------------
> 
> I built this code but it does not work
> 
> r=Array[0,{m,n}]
> For[j=1,j=n,j++
>        r[[i,j]]=Table[a[[i+1,j]]-a[[i,j]],{i,1,m-1,1}]]
> 
> thanks
> 
> Paolo
> 
> ----------------
> 
> 


  • Prev by Date: Re: stepwise ode. why does this fail?
  • Next by Date: Re: S_4 elements
  • Previous by thread: checking accuracy with stepwise ode.
  • Next by thread: About Reading and writing