March 2014 update

This commit is contained in:
Ingy döt Net 2014-04-02 16:56:35 +00:00
parent 09687c4926
commit a25938f123
1846 changed files with 21876 additions and 5203 deletions

View file

@ -0,0 +1,7 @@
Transpose(M){
R := []
for i, row in M
for j, col in row
R[j,i] := col
return R
}

View file

@ -0,0 +1,11 @@
Matrix := [[1,2,3],[4,5,6],[7,8,9],[10,11,12]]
MsgBox % ""
. "Original Matrix :`n" Print(Matrix)
. "`nTransposed Matrix :`n" Print(Transpose(Matrix))
Print(M){
for i, row in M
for j, col in row
Res .= (A_Index=1?"":"`t") col (Mod(A_Index,M[1].MaxIndex())?"":"`n")
return Trim(Res,"`n")
}

View file

@ -0,0 +1,36 @@
#include <iostream>
int main(){
const int l = 5;
const int w = 3;
int m1[l][w] = {{1,2,3}, {4,5,6}, {7,8,9}, {10,11,12}, {13,14,15}};
int m2[w][l];
for(int i=0; i<w; i++){
for(int x=0; x<l; x++){
m2[i][x]=m1[x][i];
}
}
// This is just output...
std::cout << "Before:";
for(int i=0; i<l; i++){
std::cout << std::endl;
for(int x=0; x<w; x++){
std::cout << m1[i][x] << " ";
}
}
std::cout << "\n\nAfter:";
for(int i=0; i<w; i++){
std::cout << std::endl;
for(int x=0; x<l; x++){
std::cout << m2[i][x] << " ";
}
}
std::cout << std::endl;
return 0;
}

View file

@ -0,0 +1,12 @@
transpose = function(a) {
return a[0].map(function(x,i) {
return a.map(function(y,k) {
return y[i];
});
});
}
A = [[1,2,3],[4,5,6],[7,8,9],[10,11,12]];
JSON.stringify(transpose(A));
"[[1,4,7,10],[2,5,8,11],[3,6,9,12]]"

View file

@ -0,0 +1,6 @@
M := <<2,3>|<3,4>|<5,6>>;
M^%T;
with(LinearAlgebra):
Transpose(M);