Originally your function parameters have been int**
, now they are int(*)[4]
. While accessing single elements in both cases use the same syntax under the hoods the access differs pretty much (double pointer indirection vs. single indirection and implicit offset calculation)!
The change of the signature is only valid if you change it in both header and source and recompile the library as well, otherwise you get pretty much into trouble.
I'd recommend to define a constant for the dimension, though, replacing those magic numbers (4
).
Assuming m
and n
are sizes of the matrices you might change the signature yet a bit more to remain more flexible:
void svdcmp(size_t m, size_t n, float a[m][n], float w[n /* or m??? */], float v[m][n]);
The use of variable length arrays (VLA) allows to still use matrices of different sizes even though you might not need.
In any case: The arguments you provide to the changed signature within main
indeed match the signature, so the call is fine – recommending to avoid the magic numbers, though, would rather recommend
svdcmp(sizeof(A)/sizeof(*A), sizeof(*A)/sizeof(**A), A, W, V);
// or without re-ordered parameters:
svdcmp(A, sizeof(A)/sizeof(*A), sizeof(*A)/sizeof(**A), W, V);
or you use the constant recommended above.