quara.math.matrix module

multiply_veca_vecb(vec_a, vec_b)[source]

returns \(a \cdot b\). this dot means inner product.

Parameters
  • vec_a (np.ndarray) – vector a.

  • vec_b (np.ndarray) – vector b.

Returns

value of \(a \cdot b\).

Return type

float

Raises
  • ValueError – dimension of vec_a is not 1.(not vector)

  • ValueError – dimension of vec_b is not 1.(not vector)

multiply_veca_vecb_matc(vec_a, vec_b, mat_c)[source]

returns \(a \cdot C b\). this dot means inner product.

Parameters
  • vec_a (np.ndarray) – vector a.

  • vec_b (np.ndarray) – vector b.

  • mat_c (np.ndarray) – matrix C.

Returns

value of \(a \cdot C b\).

Return type

float

Raises
  • ValueError – dimension of vec_a is not 1.(not vector)

  • ValueError – dimension of vec_b is not 1.(not vector)

  • ValueError – dimension of mat_c is not 2.(not matrix)

project_to_traceless_matrix(A)[source]

returns a matrix projected to a trace-less matrix subspace.

Parameters

A (np.ndarray) – Square matrix

Returns

B – Square matrix, \(B = A - \mathrm{Tr}[b_0 A] b_0\), where \(b_0 = \frac{I}{\sqrt{d}}\).

Return type

np.ndarray