"""Common util functions
"""
import numpy as np
[docs]
def asym(a):
"""asymmetrize
"""
return 0.5*(a-a.T)
[docs]
def sym(a):
"""symmetrize
"""
return 0.5*(a+a.T)
[docs]
def lie(a, b):
"""Lie bracket
"""
return a@b - b@a
[docs]
def vcat(x, y):
"""vertical concatenate
"""
return np.concatenate([x, y], axis=0)
[docs]
def hcat(x, y):
"""horizontal concatenate
"""
return np.concatenate([x, y], axis=1)
[docs]
def cz(a):
""" check if zero
"""
return np.max(np.abs(a))