## Zero padding is the transpose of truncation

Surrounding a dataset by zeros (zero padding) is adjoint to throwing away the extended data (truncation). Let us see why this is so. Set a signal in a vector , and then to make a longer vector , add some zeros at the end of . This zero padding can be regarded as the matrix multiplication
 (4)

The matrix is simply an identity matrix above a zero matrix . To find the transpose to zero-padding, we now transpose the matrix and do another matrix multiply:
 (5)

So the transpose operation to zero padding data is simply truncating the data back to its original length. Subroutine zpad1() below pads zeros on both ends of its input. Subroutines for two- and three-dimensional padding are in the library named zpad2() and zpad3().
 void zpad1_lop(bool adj, bool add, int nd, int np, float *data, float *padd) { int p,d; sf_adjnull(adj,add,nd,np,data,padd); for (d=0; d < nd; d++) { p = d + (np-nd)/2; if (adj) data[d] += padd[p]; else padd[p] += data[d]; } }