Matrix transposition: Difference between revisions

Content added Content deleted
Line 1,337: Line 1,337:
class Transpose {
class Transpose {
function : Main(args : String[]) ~ Nil {
function : Main(args : String[]) ~ Nil {
x := 4; y := 5;
input := [[1, 1, 1, 1]
m := [[1, 1, 1, 1]
[2, 4, 8, 16]
[2, 4, 8, 16]
[3, 9, 27, 81]
[3, 9, 27, 81]
[4, 16, 64, 256]
[4, 16, 64, 256]
[5, 25, 125, 625]];
[5, 25, 125, 625]];
dim := input->Size();


result := Int->New[x,y];
output := Int->New[dim[0],dim[1]];
for(i := 0; i < x; i+=1;) {
for(i := 0; i < dim[0]; i+=1;) {
for(j := 0; j < y; j+=1;) {
for(j := 0; j < dim[1]; j+=1;) {
result[i,j] := m[i,j];
output[i,j] := input[i,j];
};
};
};
};


Print(result, x, y);
Print(output);
}
}


function : Print(matrix : Int[,], x : Int, y : Int) ~ Nil {
function : Print(matrix : Int[,]) ~ Nil {
for(i := 0; i < x; i+=1;) {
dim := matrix->Size();
for(j := 0; j < y; j+=1;) {
for(i := 0; i < dim[0]; i+=1;) {
for(j := 0; j < dim[1]; j+=1;) {
IO.Console->Print(matrix[i,j])->Print('\t');
IO.Console->Print(matrix[i,j])->Print('\t');
};
};