4
$\begingroup$

I have generated a real antisymmetric matrix of order 6 as follows.

k0 = {{0, 1, 0, 0, 0, 0}, {-1, 0, 0, 0, 0, 0}, {0, 0, 0, 1, 0, 0}, {0,
    0, -1, 0, 0, 0}, {0, 0, 0, 0, 0, 1}, {0, 0, 0, 0, -1, 0}}

Any way to generate such a matrix of order 36 X 36 without writing each terms as above?

$\endgroup$
6
$\begingroup$

Use SparseArray and Band to reproduce your example 6-by-6 matrix:

m = SparseArray[
  {Band[{1,2},{-1,-1}]->{1,0}, Band[{2,1},{-1,-1}]->{-1,0}}, {6,6}];
AntisymmetricMatrixQ@m (* True *)

This simple change from {6,6} to {36,36} makes a 36-by-36 matrix:

m = SparseArray[
  {Band[{1,2},{-1,-1}]->{1,0}, Band[{2,1},{-1,-1}]->{-1,0}}, {36,36}];
AntisymmetricMatrixQ@m (* True *)

The matrix is a SparseArray. Use Normal@m to create an ordinary list.

$\endgroup$
7
$\begingroup$

This example returns a SparseArray. Use Normal to make it a nested list, if you prefer.

mat = Block[{b, n = 6},
   b = Riffle[ConstantArray[1, n/2], 0];
   SparseArray[{Band[{1, 2}] -> b, Band[{2, 1}] -> -b}, {n, n}]
   ];
MatrixForm @ mat

$$\left( \begin{array}{cccccc} 0 & 1 & 0 & 0 & 0 & 0 \\ -1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & -1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0 & -1 & 0 \\ \end{array} \right)$$

Alternatively,

mat = With[{n = 6}, 
 KroneckerProduct[IdentityMatrix[n/2], {{0, 1}, {-1, 0}}]]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.