Commit 08aa217a authored by Giovanne Marcelo's avatar Giovanne Marcelo

update pseudocode

parent ce4080b3
Pipeline #6398 passed with stage
in 4 minutes and 42 seconds
......@@ -28,13 +28,19 @@ typedef struct {
}algorithm_args;
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, om) ,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(algorithm_args *args);
void ccd_pp(matrix residual, matrix W, matrix H, double lamb, int k);
void perform(algorithm_args *args);
void ccd(algorithm_args *args);
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);
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 z(double r, double w, double h, double *numerator, double *denominator);
void s(double r, double w, double h, double *numerator, double *denominator);
double find_minimun(matrix residual, matrix W, matrix H, double lamb,
list(long unsigned int, om) ,long unsigned int t,
long unsigned int i, void (*f)(double_args));
#endif
......@@ -13,20 +13,71 @@
* for iter = 1, 2, . . . , T do
* for i = 1, 2, . . . , m do
* for t = 1, 2, . . . , k do
* Obtain z∗ using (6).
* Update R and wit using (7) and (8).
* Obtain z∗ using find_minimun(z)
* Update R using update_col_residual()
* wit using matrix_set()
* end for
* end for
*
* for j = 1, 2, . . . , n do
* for t = 1, 2, . . . , k do
* Obtain s∗ using (12).
* Update R and hjt using (9) and (10).
* Obtain s∗ using find_minimun(s).
* Update R using update_row_residual()
* hjt using matrix_set()
* end for
* end for
* end for
*/
void ccd(algorithm_args *args) {
double rating;
for(long unsigned int iter = 0; iter < args->T ; iter++) {
for(long unsigned int i = 0; i < args->residual->size1 ; i++ ) {
for(long unsigned int t = 0; t < args->k; t++) {
rating = find_minimun(args->residual, args->W, args->H, args->lamb, \
args->omegai.data[i], t, i, z);
update_col_residual(args->residual, args->omegai.data[i], rating, \
args->W, args->H, i, t ) ;
matrix_set(args->W, i, t, rating);
}
}
for(long unsigned int j = 0; j < args->residual->size2; j++) {
for(long unsigned int t = 0; t < args->k; t++) {
rating = find_minimun(args->residual, args->W, args->H, args->lamb, \
args->omegaj.data[j], t, j, s);
update_row_residual(args->residual, args->omegaj.data[j], rating, \
args->W, args->H, j, t);
matrix_set(args->H, j, t, rating);
}
}
}
}
/*
* CCD++
* Input: Initial R = A, W = 0, H, λ, and k
* for iter = 1, 2, . . . do
* for t = 1, 2, . . . , k do
* Get (u, v) using T CCD iterations for (16).
* Update R and (w¯t, h¯t) using (17) and (18).
* end for
* end for
*/
/* void ccd_pp(matrix residual, matrix W, matrix H, double lamb, int k) {
}
*/
void perform(algorithm_args *args) {
ccd(args);
}
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) {
......@@ -63,7 +114,6 @@ void s(double r, double w, double h, double *numerator, double *denominator) {
*denominator += w * w;
}
double find_minimun(matrix residual, matrix W, matrix H, double lamb,
list(long unsigned int, om) ,long unsigned int t,
long unsigned int i,void (*f)(double_args)) {
......@@ -81,52 +131,3 @@ double find_minimun(matrix residual, matrix W, matrix H, double lamb,
denominator += lamb;
return ( numerator / denominator );
}
void ccd(algorithm_args *args) {
double rating;
for(long unsigned int iter = 0; iter < args->T ; iter++) {
for(long unsigned int i = 0; i < args->residual->size1 ; i++ ) {
for(long unsigned int t = 0; t < args->k; t++) {
rating = find_minimun(args->residual, args->W, args->H, args->lamb, \
args->omegai.data[i], t, i, z);
update_col_residual(args->residual, args->omegai.data[i], rating, \
args->W, args->H, i, t ) ;
matrix_set(args->W, i, t, rating);
}
}
for(long unsigned int j = 0; j < args->residual->size2; j++) {
for(long unsigned int t = 0; t < args->k; t++) {
rating = find_minimun(args->residual, args->W, args->H, args->lamb, \
args->omegaj.data[j], t, j, s);
update_row_residual(args->residual, args->omegaj.data[j], rating, \
args->W, args->H, j, t);
matrix_set(args->H, j, t, rating);
}
}
}
}
/*
* CCD++
* Input: Initial R = A, W = 0, H, λ, and k
* for iter = 1, 2, . . . do
* for t = 1, 2, . . . , k do
* Get (u, v) using T CCD iterations for (16).
* Update R and (w¯t, h¯t) using (17) and (18).
* end for
* end for
*/
/* void ccd_pp(matrix residual, matrix W, matrix H, double lamb, int k) {
}
*/
void perform(algorithm_args *args) {
ccd(args);
}
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