Esempio n. 1
0
        private void TestColumnFromMatrix()
        {
            P = new double[, ] {
                { 0.93119636, 0.01215318, 0.82254304, 0.92704314, 0.72097256,
                  0.1119594, 0.05907673, 0.27337659, 0.51578453, 0.47299487 },
                { 0.1671686, 0.02328032, 0.64793332, 0.46310597, 0.98508579,
                  0.23390272, 0.34862754, 0.29751156, 0.81994987, 0.32293732 },
                { 0.72302848, 0.91165485, 0.70980305, 0.20125138, 0.33071352,
                  0.40941998, 0.6984816, 0.94986196, 0.52719633, 0.66722182 }
            };

            List <int> myL = new List <int>();

            myL.Add(4);
            myL.Add(6);
            double[,] M = MyMatrix <double> .GetMatrixFromOtherMatrixColumns(P, myL);

            Utils <double> .PrintMatrix(M);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }