def ij_to_vectorized_idx(i,j,n):
    """    
    Returns the index of the vector generated from vectorizing matrix from its original i,j index
    [[A11, A12, A13],
     [A21, A22, A23],  --> [A11, A21, A31, A12, A22, A32, A13, A23, A33]
     [A31, A32, A33]  
    ]
    n: number of rows
    """
    return i+j*n