Example #1
0
        public void TestAdding()
        {
            P = new double[, ] {
                { 0.1, 0.4, 0.7 }, { 0.2, 0.5, 0.8 }, { 0.3, 0.6, 0.9 }
            };
            U = new double[, ] {
                { 0.25, 0.35, 0.78 }, { 0.15, 0.45, 0.25 }, { 0.85, 0.1, 0.1 }
            };
            double[,]  Result = MyMatrix <double> .Add(U, P);

            Console.WriteLine("\n wynik dodowania");
            Utils <double> .PrintMatrix(Result);
        }
Example #2
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);
        }
Example #3
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);
        }