Example #1
0
def _rotate_decomposition_basis_by_series(data, R_basis, ell_min, ell_max, D):
    """Rotate data by a different rotor at each point in time

    `D` is just a workspace, which holds the Wigner D matrices.
    During the summation, it is also used as temporary storage to hold
    the results for each item of data, where the first row in the
    matrix is overwritten with the new sums.

    """
    for i_t in xrange(data.shape[0]):
        sf._Wigner_D_matrices(R_basis[i_t, 0], R_basis[i_t, 1], ell_min,
                              ell_max, D)
        for ell in xrange(ell_min, ell_max + 1):
            i_data = ell**2 - ell_min**2
            i_D = sf._linear_matrix_offset(ell, ell_min)

            for i_m in xrange(2 * ell + 1):
                new_data_mp = 0j
                for i_mp in xrange(2 * ell + 1):
                    new_data_mp += data[i_t, i_data +
                                        i_mp] * D[i_D + i_m +
                                                  (2 * ell + 1) * i_mp]
                D[i_D + i_m] = new_data_mp
            for i_m in xrange(2 * ell + 1):
                data[i_t, i_data + i_m] = D[i_D + i_m]
def test_Wigner_D_linear_indices(ell_max):
    for l_min in range(ell_max):
        for l_max in range(l_min + 1, ell_max + 1):
            LMpM = sf.LMpM_range(l_min, l_max)

            assert len(LMpM) == sf._total_size_D_matrices(l_min, l_max)

            for ell in range(l_min, l_max + 1):
                assert list(LMpM[sf._linear_matrix_offset(ell, l_min)]) == [ell, -ell, -ell]

            for ell in range(l_min, l_max + 1):
                for mp in range(-ell, ell + 1):
                    i = sf._linear_matrix_diagonal_index(ell, mp)
                    o = sf._linear_matrix_offset(ell, l_min)
                    assert list(LMpM[i + o]) == [ell, mp, mp]
                    for m in range(-ell, ell + 1):
                        i = sf._linear_matrix_index(ell, mp, m)
                        o = sf._linear_matrix_offset(ell, l_min)
                        assert list(LMpM[i + o]) == [ell, mp, m]
def test_Wigner_D_linear_indices(ell_max):
    for l_min in range(ell_max):
        for l_max in range(l_min + 1, ell_max + 1):
            LMpM = sf.LMpM_range(l_min, l_max)

            assert len(LMpM) == sf._total_size_D_matrices(l_min, l_max)

            for ell in range(l_min, l_max + 1):
                assert list(LMpM[sf._linear_matrix_offset(ell, l_min)]) == [ell, -ell, -ell]

            for ell in range(l_min, l_max + 1):
                for mp in range(-ell, ell + 1):
                    assert list(
                        LMpM[sf._linear_matrix_diagonal_index(ell, mp) + sf._linear_matrix_offset(ell, l_min)]) == [ell,
                                                                                                                    mp,
                                                                                                                    mp]
                    for m in range(-ell, ell + 1):
                        assert list(
                            LMpM[sf._linear_matrix_index(ell, mp, m) + sf._linear_matrix_offset(ell, l_min)]) == [ell,
                                                                                                                  mp, m]
Example #4
0
def _rotate_decomposition_basis_by_constant(data, ell_min, ell_max, D, tmp):
    """Rotate data by the same rotor at each point in time

    `D` is the Wigner D matrix for all the ell values.

    `tmp` is just a workspace used as temporary storage to hold the
    results for each item of data during the sum.

    """
    for i_t in range(data.shape[0]):
        for ell in range(ell_min, ell_max + 1):
            i_data = ell ** 2 - ell_min ** 2
            i_D = sf._linear_matrix_offset(ell, ell_min)

            for i_m in range(2 * ell + 1):
                tmp[i_m] = 0j
            for i_mp in range(2 * ell + 1):
                for i_m in range(2 * ell + 1):
                    tmp[i_m] += data[i_t, i_data + i_mp] * D[i_D + (2 * ell + 1) * i_mp + i_m]
            for i_m in range(2 * ell + 1):
                data[i_t, i_data + i_m] = tmp[i_m]