Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static double objectiveFunction(double[][] P, double[][] U, int[][] input, double factor) {
- double result = 0;
- double tempResult = 0;
- for ( int u = 0; u < U[0].length; u++ ) {
- for ( int p = 0; p < P[0].length; p++ ) {
- if ( input[u][p] != 0 ) {
- double temp = multiplyMatricesOneDim(getColumn(U, u), getColumn(P, p));
- double temp2 = input[u][p];
- result += Math.pow(temp2 - temp, 2);
- }
- }
- }
- for ( int u = 0; u < U[0].length; u++ ) {
- tempResult += Math.pow(getNorm(getColumn(U, u)), 2);
- }
- for ( int p = 0; p < P[0].length; p++ ) {
- tempResult += Math.pow(getNorm(getColumn(P, p)), 2);
- }
- return result + tempResult * factor;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement