I’ve got:
void pprint_matrix(matrix *m)
{
int n,k,p;
matrix* row = new_matrix(1,m->j);
for (k = 1; k < (m->i)+1; k++)
{
p = 0;
for (n = (m->j)*k-(m->j); n < (m->j)*k; n++)
{
row->m[p] = m->m[n];
p++;
}
for (n = 0; n < m->j; n++)
{
printf("(%+#3.3g%+#3.3gi) ",row->m[n].re,row->m[n].im);
}
printf("\n");
}
}
Which is printing:
(-1.73+0.00i) (+0.866+0.00i) (-0.722+0.00i) (-0.866+0.00i)
(+0.00+0.00i) (-0.707+0.00i) (+0.707+0.00i) (+0.707+0.00i)
(+0.00+0.00i) (+0.00+0.00i) (+0.204+0.00i) (+0.00+0.00i)
another example of print output:
(-2.24+0.00i) (+2.22e-16+0.00i) (-1.12+0.00i) (-1.79+0.00i)
(+0.00+0.00i) (+1.58+0.00i) (+0.00+0.00i) (+0.632+0.00i)
(+0.00+0.00i) (+5.55e-17+0.00i) (-0.725+0.00i) (-1.04+0.00i)
(+0.00+0.00i) (+2.22e-16+0.00i) (-0.589+0.00i) (-0.816+0.00i)
(+0.00+0.00i) (+2.22e-16+0.00i) (+0.0467+0.00i) (+0.404+0.00i)
I want to get rid of that offset. How can I force this alignment given the preceding code? The function I’ve listed really isn’t important to the question. It’s just a question about printf.
For clarity, the goal is something like this:
( ) ( ) ( )
( ) ( ) ( )
( ) ( ) ( )
If you just want more padding to form columns, you can try:
If you want them 0 padded, just add a 0 to the format: