Exemplo n.º 1
0
        private void StepForU(int u)
        {
            List <int> _I_u = FlatNonZeroInRow(u, Ratings);

            double[,] _regE = EyeMulDouble(d);
            MyMatrix <double> gauss = new MyMatrix <double>(d);

            //Liczymy _P_I_u_(czyli kolumny z macierzy P o indeksach w _I_u_)
            double[,] _P_I_u = MyMatrix <double> .GetMatrixFromOtherMatrixColumns(P, _I_u);

            double[,] _P_I_u_T = MyMatrix <double> .Transpose(_P_I_u);

            double[,] _A_u = MyMatrix <double> .Add(
                MyMatrix <double> .Multiplication(_P_I_u, _P_I_u_T),
                _regE);

            double[] _V_u = Count_V_u(_I_u, P, Ratings, u);
            //Jak już mamy wszystko policzone, możemy podstawić A_u oraz V_u do gaussa:
            gauss.A = _A_u;
            gauss.B = _V_u;
            gauss.ComputePG();
            double[] GaussSolution = gauss.Xgauss;
            U = InsertGaussColumn(u, U, GaussSolution);
        }
Exemplo n.º 2
0
        private void StepForP(int p)
        {
            List <int> _I_p = FlatNonZeroInColumn(p, Ratings);

            double[,] _regE = EyeMulDouble(d);
            MyMatrix <double> gauss = new MyMatrix <double>(d);

            double[,] _U_I_p = MyMatrix <double> .GetMatrixFromOtherMatrixColumns(U, _I_p);

            double[,] _U_I_p_T = MyMatrix <double> .Transpose(_U_I_p);

            double[,] _B_u =
                MyMatrix <double> .Add(
                    MyMatrix <double> .Multiplication(_U_I_p, _U_I_p_T),
                    _regE
                    );

            double[] _W_u = Count_W_u(_I_p, U, Ratings, p);
            gauss.A = _B_u;
            gauss.B = _W_u;
            gauss.ComputePG();
            double[] GaussSolution = gauss.Xgauss;
            P = InsertGaussColumn(p, P, GaussSolution);
        }