Anonymous user
Matrix transposition: Difference between revisions
m
Fixed lang tags.
(Added Scala) |
m (Fixed lang tags.) |
||
Line 5:
This example illustrates use of Transpose for the matrices built upon the standard type Float:
<lang ada>with Ada.Numerics.Real_Arrays; use Ada.Numerics.Real_Arrays;▼
<lang ada>▼
▲with Ada.Numerics.Real_Arrays; use Ada.Numerics.Real_Arrays;
with Ada.Text_IO; use Ada.Text_IO;
Line 32 ⟶ 31:
Put_Line ("After Transposition:");
Put (Transpose (Matrix));
end Matrix_Transpose;</lang>
Sample output:
<pre>
Line 49 ⟶ 47:
=={{header|ALGOL 68}}==
Output:
=={{header|AutoHotkey}}==
<lang AutoHotkey>a = a
Line 326 ⟶ 324:
Sample originally from ftp://ftp.dra.hmg.gb/pub/ella (a now dead link) - Public release.
Code for matrix transpose hardware design verification:<
=={{header|Fortran}}==
In ISO Fortran 90 or later, use the TRANSPOSE intrinsic function:
<lang fortran>
In ANSI FORTRAN 77 with MIL-STD-1753 extensions or later, use nested structured DO loops:
<lang fortran>
In ANSI FORTRAN 66 or later, use nested labeled DO loops:
<lang fortran>
=={{header|GAP}}==
=={{header|Groovy}}==
Line 399 ⟶ 395:
For matrices represented as lists, there's ''transpose'':
<lang haskell>*Main> transpose [[1,2],[3,4],[5,6]]
For matrices in arrays, one can use ''ixmap'':
<lang haskell>import Data.Array▼
▲import Data.Array
swap (x,y) = (y,x)
Line 413 ⟶ 406:
transpArray :: (Ix a, Ix b) => Array (a,b) e -> Array (b,a) e
transpArray a = ixmap (swap l, swap u) swap a where
(l,u) = bounds a</lang>
=={{header|IDL}}==
Line 420 ⟶ 412:
Standard IDL function <tt>transpose()</tt>
=={{header|J}}==
Transpose is the monadic primary verb <tt>|:</tt>
<lang j> ]matrix=: 3 5 $ 10+ i. 15 NB. make and show example matrix
=={{header|Java}}==
Line 459 ⟶ 451:
=={{header|Mathematica}}==
=={{header|MATLAB}}==
Line 471 ⟶ 463:
=={{header|Maxima}}==
=={{header|MAXScript}}==
Uses the built in transpose() function
=={{header|Nial}}==
make an array
transpose it
=={{header|OCaml}}==
Line 589 ⟶ 581:
=={{header|Pop11}}==
<lang pop11>define transpose(m) -> res;▼
▲define transpose(m) -> res;
lvars bl = boundslist(m);
if length(bl) /= 4 then
Line 603 ⟶ 594:
endfor;
endfor;
enddefine;</lang>
=={{header|Python}}==
|