import numpy as np


def sh_eval_basis_1(
        x, y, z,
        p_0_0=0.282094791773878140,
        p_1_0=0.488602511902919920,
        p_1_1=-0.488602511902919920
):
    b = np.zeros(27)
    b[0::9] = p_0_0  # l=0,m=0
    b[2::9] = p_1_0 * z  # l=1,m=0
    b[1::9] = p_1_1 * y  # l=1,m=-1
    b[3::9] = p_1_1 * x  # l=1,m=+1
    return b


def sh_eval_basis_2(
        x, y, z,
        p_0_0=0.282094791773878140,
        p_1_0=0.488602511902919920,
        pp_2_0=0.946174695757560080,
        mp_2_0=-0.315391565252520050,
        p_1_1=-0.488602511902919920,
        p_2_1=-1.092548430592079200,
        p_2_2=0.546274215296039590
):
    b = np.zeros(27)
    b[0::9] = p_0_0  # l=0,m=0

    b[2::9] = p_1_0  # l=1,m=0
    b[6::9] = (pp_2_0 * z * z) + mp_2_0

    b[1::9] = p_1_1 * y  # l=1,m=-1
    b[3::9] = p_1_1 * x  # l=1,m=+1

    b[5] = p_2_1 * z * y  # l=2,m=-1
    b[7] = p_2_1 * z * x  # l=2,m=+1

    b[4] = p_2_2 * (x * y + y * x)  # l=2,m=-2
    b[8] = p_2_2 * (y * y + x * x)  # l=2,m=+2
    return b