An inversion technique for certain patterned matrices