RE: basic operations in matrices
- To: mathgroup at smc.vnet.net
- Subject: [mg34578] RE: [mg34542] basic operations in matrices
- From: Juan Egea Garcia <jeg at um.es>
- Date: Wed, 29 May 2002 02:44:22 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Christian, i´ve make this operation in order to transpose tow rows Operation[m_List, v_List] := Module[{a}, a = Table[j, {j, Length[m]}] /. v[[1]] -> v[[2]]; b = ReplacePart[a, v[[1]], v[[2]]]; Map[m[[#]] &, b] ] Note that v = {i,j} (i=1,j=3 in your example). Another way is use only the Map function in this form Operaton2[m_List,v_List]:=Map[m[[#]] &,v] in this case v represents the complete vector, {3,2,1,4} for your example. You can make in a similar way a function in order to transpose to columns. ======================================= Juan Egea Garcia Departamento de Matemática Aplicada Universidad de Murcia España +34 968654243 +34 968367144 -----Mensaje original----- De: Christian Junk [mailto:junkc at fh-trier.de] Enviado el: lunes, 27 de mayo de 2002 7:16 Para: mathgroup at smc.vnet.net Asunto: [mg34542] basic operations in matrices Hi! I'm new to Mathematica and I'm searching for an operation, that simply transpose two rows or columns of a matrix M. e.g: Operation[M,{1,3}] 1 1 1 1 3 3 3 3 2 2 2 2 ---> 2 2 2 2 3 3 3 3 1 1 1 1 4 4 4 4 4 4 4 4 Much thanks in advance, Christian