Skip to content
DeepForgeby svx
All problems
MediumLinear Algebrala-164

Skew-Symmetric Part

Problem

Compute the skew-symmetric part of a square matrix A:

skew(A) = (A - A^T) / 2

The result has zero diagonal and satisfies skew(A)^T = -skew(A).

Hint

Together, the symmetric and skew parts reconstruct A.

Test cases

case 1
in: [[[1,2],[3,4]]]
expected: [[0,-0.5],[0.5,0]]
case 2
in: [[[1,0],[0,1]]]
expected: [[0,0],[0,0]]
case 3
in: [[[0,2],[-2,0]]]
expected: [[0,2],[-2,0]]
case 4
in: [[[1,2,3],[4,5,6],[7,8,9]]]
expected: [[0,-1,-2],[1,0,-1],[2,1,0]]
Starter codePython
def skew_symmetric_part(A):
    # Your code here
    pass

4 test cases · run your code against them in the editor