fullycompiledBSplineSurf2 =
Hold@Compile[{{ctrlnets, _Real,
3}, {deg1, _Integer}, {deg2, _Integer}, {knots1, _Real,
1}, {knots2, _Real, 1}, {u, _Real}, {v, _Real}},
Module[{i, j, validnets, row, col},
i = With[{un = #2[[-(#1 + 1)]]},
If[#3 == un,
Position[#2, un][[1, 1]] -
2, (Position[#, Min[#]] &@UnitStep[#3 - #2])[[1, 1]] -
2]] &[deg1, knots1, u];
j =
With[{un = #2[[-(#1 + 1)]]},
If[#3 == un,
Position[#2, un][[1, 1]] -
2, (Position[#, Min[#]] &@UnitStep[#3 - #2])[[1, 1]] -
2]] &[deg2, knots2, v];