'Code for calculating a given math function in java - some suggestions

I have to write a Java method that calculates this math function: enter image description here The function itself is not a problem but I need some advice.

C(u, v) is a two-dimensional array where I will save the result.

f(x, y) is a two-dimensional array from where I get the values I need to calculate C(u, v)

Obviously, I have to assume that the lengths of u and v are different (same for x and y). So, although the two summations are x = 0 to N-1 and y = 0 to N-1 (which would suggest that the matrix is the same size), I think it would be better to treat it as if it had different sizes. So :

  • x will be the lines (and I will find them with matrix.length)
  • y will be the columns (and I will find them with matrix [i].lenth)
  • (the two points above will also be reflected on the dimensions of the matrix C)
  • 2N will be the total number of elements in the matrix

Did I think it right?



Solution 1:[1]

you seem to be right, except for the 2N part, 2N is not the total number of elements, if the matrix has is N by M size then the total number of elements is N*M. since it says on the equation (2N)then it probably means (N+M) or it could be (2N) or (2M), you need to be sure.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Grim Ranger