code: def simx(A,B,transpose=False):
      "Similarity transform B^T(AB) or B(AB^T) (if transpose)"
      if transpose:
          return np.dot(B,np.dot(A,B.T))
      return np.dot(B.T,np.dot(A,B)f simx(A,B,transpose=False):
      "Similarity transform B^T(AB) or B(AB^T) (if transpose)"
      if transpose:
          return np.dot(B,np.dot(A,B.T))
      return np.dot(B.T,np.dot(A,B))
docs: Similarity transform B^T(AB) or B(AB^T) (if transpose)