Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. public static double objectiveFunction(double[][] P, double[][] U, int[][] input, double factor) {
  2. double result = 0;
  3. double tempResult = 0;
  4. for ( int u = 0; u < U[0].length; u++ ) {
  5. for ( int p = 0; p < P[0].length; p++ ) {
  6. if ( input[u][p] != 0 ) {
  7. double temp = multiplyMatricesOneDim(getColumn(U, u), getColumn(P, p));
  8. double temp2 = input[u][p];
  9. result += Math.pow(temp2 - temp, 2);
  10. }
  11. }
  12. }
  13.  
  14. for ( int u = 0; u < U[0].length; u++ ) {
  15. tempResult += Math.pow(getNorm(getColumn(U, u)), 2);
  16. }
  17.  
  18. for ( int p = 0; p < P[0].length; p++ ) {
  19. tempResult += Math.pow(getNorm(getColumn(P, p)), 2);
  20. }
  21. return result + tempResult * factor;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement