Implementing a tensor product formula
Readability &amp; Maintainability


Right now your code is a bit hard to read.  A way to greatly help this would be to use better variable names.


Put the variable declarations to separate lines and initialize them to some value at the same time. From Code Complete, 2d Edition, p. 759:


  With statements on their own lines, the code reads from top to bottom,
  instead of top to bottom and left to right. When you’re looking for a
  specific line of code, your eye should be able to follow the left
  margin of the code. It shouldn’t have to dip into each and every line
  just because a single line might contain two statements.

You should declare your for loops as such:

for(int i = 0; i &lt; size; ++i)


Note that this was introduced in the C99 standard.  There is no reason you should not be using this standard in your code.


Design


Group your variables in structs to make them more maintainable, a
good hint that you should be doing this is when you are passing in
9 parameters to your function.
Return the output vector; it makes your function easier to use. 
You'll have to allocate the space in your method and free it
elsewhere.  This also eliminates the potential bug discussed below.
Don't cast malloc().
Right now you are using this loop to zero out temp (or at least part of it)

for (r = 0; r &lt;= c - 1; r++){
    temp[r] = 0.0;
}


The original algorithm doesn't implement this in a separate loop, and I don't recommend you do either.  It's a loop in the code you don't need.
These lines:

temp[r] = temp[r] + Nu[k]*P[idx+r];
S[r] = S[r] + Nv[l]*temp[r];


Can be shortened to:

temp[r] += Nu[k]*P[idx+r];
S[r] += Nv[l]*temp[r];

Set those pointers you free()ed to NULL right after.  This prevents us from trying to access the data afterwards, which will result in undefined and usually catastrophic behavior.


Bug


Right now you are relying on the passed in values already stored in S[r] when you add Nv[l]*temp[r] to them.  In the original NURBS A3.5 algorithm, they are 0'ed out right before their use.  You could overwrite all these values to 0 with a memset() in our function and continue as is. However, overwriting something the user passes when we could've started from scratch is usually not expected behavior.

Create the array at the top of the function like you do with the other arrays, using calloc().