Commit 916358f4 authored by Giovanne Marcelo's avatar Giovanne Marcelo

add update residual function

parent fecf1b24
Pipeline #6392 passed with stage
in 4 minutes and 46 seconds
......@@ -21,8 +21,9 @@ typedef struct {
}algorithm_args;
void update_residual();
void z(double r, double w, double h, double *numerator, double *denominator);
void update_col_residual(matrix residual, list(long unsigned int, omegai), double z, matrix W, matrix H, long unsigned int i, long unsigned int t);
void update_row_residual(matrix residual, list(long unsigned int, omegaj), double s, matrix W, matrix H, long unsigned int j, long unsigned int t);
double find_minimun(matrix residual, matrix W, matrix H, double lamb,list(long unsigned int, omega) ,long unsigned int t, long unsigned int i, void (*f)(double, double, double, double*, double*));
void s(double r, double w, double h, double *numerator, double *denominator);
void ccd_pp(matrix residual, matrix W, matrix H, double lamb, int k);
......
......@@ -27,7 +27,21 @@
* end for
*/
void update_residual() {}
void update_col_residual(matrix residual, list(long unsigned int, omegai), double z, matrix W, matrix H, long unsigned int i, long unsigned int t) {
list_each_elem(omegai, elem) {
double result = matrix_get(residual, i, *elem) - (z - matrix_get(W, i, t) )*matrix_get(H, *elem, t);
matrix_set(residual, i, *elem, result );
}
}
void update_row_residual(matrix residual, list(long unsigned int, omegaj), double s, matrix W, matrix H, long unsigned int j, long unsigned int t) {
list_each_elem(omegaj, elem) {
double result = matrix_get(residual, *elem, j) - (s - matrix_get(H, j, t) ) * matrix_get(W, *elem, t);
matrix_set(residual, *elem, j, result );
}
}
void z(double r, double w, double h, double *numerator, double *denominator ) {
*numerator += (r + w * h) * h;
......@@ -64,7 +78,7 @@ void ccd(matrix residual, matrix W, matrix H, list(long unsigned int, omegai), l
for(long unsigned int i = 0; i < residual->size1 ; i++ ) {
for(long unsigned int t = 0; t < k; t++) {
rating = find_minimun(residual, W, H, lamb, omegai, t, i, z);
update_residual();
update_col_residual(residual, omegai, rating, W, H, i, t ) ;
matrix_set(W, i, t, rating);
}
}
......@@ -72,7 +86,7 @@ void ccd(matrix residual, matrix W, matrix H, list(long unsigned int, omegai), l
for(long unsigned int j = 0; j < residual->size2; j++) {
for(long unsigned int t = 0; t < k; t++) {
rating = find_minimun(residual, W, H, lamb, omegaj, t, j, s);
update_residual();
update_row_residual(residual, omegaj, rating, W, H, j, t);
matrix_set(H, j, t, rating);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment