def pivot(mat_in, idx):
    """
    This function transforms the elements in a row of matrix such as to create
    a pivot, i.e. a unit matrix elemnt, in a specified index position along the
    main diagonal.

    :param mat_in: list of lists, i.e. a matrix
    :param idx: int
    :return: list of lists, i.e. a matrix
    """

    mat_in[idx] = [x/mat_in[idx][idx] for x in mat_in[idx]]
    return mat_in