Commit c4fffa29 authored by Giovanne Marcelo's avatar Giovanne Marcelo

add omega structure#2

parent 916358f4
Pipeline #6393 passed with stage
in 4 minutes and 55 seconds
......@@ -9,13 +9,17 @@
#include <stddef.h>
#include <string.h>
typedef struct {
list(long unsigned int, *data);
}omega;
typedef struct {
matrix residual;
matrix W;
matrix H;
list(long unsigned int, omegai);
list(long unsigned int, omegaj);
double lamb;
omega omegai;
omega omegaj;
double lamb;
long unsigned int k;
long unsigned int T;
}algorithm_args;
......@@ -24,10 +28,10 @@ typedef struct {
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*));
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_pp(matrix residual, matrix W, matrix H, double lamb, int k);
void perform(algorithm_args *args);
void ccd(matrix residual, matrix W, matrix H,list(long unsigned int, omegai), list(long unsigned int, omegaj), double lamb, long unsigned int k,long unsigned int T);
void ccd(matrix residual, matrix W, matrix H,omega omegai, omega omegaj, double lamb, long unsigned int k,long unsigned int T);
#endif
......@@ -54,13 +54,13 @@ 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, omega) ,long unsigned int t, long unsigned int i, void (*f)(double, double, double, double*, double*)) {
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*)) {
double rij, wit, hjt, numerator, denominator;
numerator = denominator = .0;
list_each_elem(omega,elem) {
list_each_elem(om,elem) {
rij = matrix_get(residual,i, *elem);
wit = matrix_get(W, i, t);
hjt = matrix_get(H, *elem, t);
......@@ -70,23 +70,23 @@ double find_minimun(matrix residual, matrix W, matrix H, double lamb,list(long u
return ( numerator / denominator );
}
void ccd(matrix residual, matrix W, matrix H, list(long unsigned int, omegai), list(long unsigned int, omegaj), double lamb, long unsigned int k,long unsigned int T) {
void ccd(matrix residual, matrix W, matrix H, omega omegai, omega omegaj, double lamb, long unsigned int k,long unsigned int T) {
double rating;
for(long unsigned int iter = 0; iter < T ; iter++) {
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_col_residual(residual, omegai, rating, W, H, i, t ) ;
rating = find_minimun(residual, W, H, lamb, omegai.data[i], t, i, z);
update_col_residual(residual,omegai.data[i], rating, W, H, i, t ) ;
matrix_set(W, i, t, rating);
}
}
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_row_residual(residual, omegaj, rating, W, H, j, t);
rating = find_minimun(residual, W, H, lamb, omegaj.data[j], t, j, s);
update_row_residual(residual, omegaj.data[j], 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