Ejemplo n.º 1
0
MatrSolver::MatrSolver(int size)
{
    InitVars(size);
    InitRand();
    InitMatr();
    SetMtx(matr, b_matr, n);
    PrintMtx(matr, n);
    std::cout << "Матрица В: " << std::endl;
    PrintVector(b_matr, n);
    //Solve();
}
Ejemplo n.º 2
0
void MatrSolver::Solve(){
    det = Det(matr, n);
    std::cout << "Определитель матрицы = " << det << std::endl;
    if (det) FindObrMatr();
    else std::cout << "Т.к. определитель матрицы = 0,\nто матрица вырожденная и обратной не имеет!!!" << std::endl;
    TransponMtx(obr_matr, tobr_matr, n);
    PrintMtx(tobr_matr, n);
    SolveEquation(tobr_matr, b_matr, res, n);
    std::cout << "Результат: " << std::endl;
    PrintVector(res, n);
    FreeResources();
}
Ejemplo n.º 3
0
void GetGraphs(const vector <TStr>& Parameters, const TStr& ModelGen, const TStr&ModelPlt)
{
    PNGraph G;
    size_t PSize = Parameters.size();
    if (GRAPHGEN >= PSize || MTXGEN >= PSize || KRONGEN >= PSize || KRONFIT >= PSize)
        Error("GetGraphs", "Wrong index in array of parameters");

    GetModel(Parameters[GRAPHGEN], G);

    if (G->GetNodes() == 0)
        Error("GetGraphs", "Empty graph");

    TFltPrV MDegIn, MDegOut;
    TSnap::GetInDegCnt(G, MDegIn);
    TSnap::GetOutDegCnt(G, MDegOut);

    PlotDegrees(Parameters, MDegIn, MDegOut, "model");
    TFile << "Model nodes: " << G->GetNodes() << ", model edges: " << G->GetEdges() << endl;
    TFile << "Maximum output degree in model graph: " << MDegOut[MDegOut.Len()-1].GetVal1() << endl;
    TFile << "Maximum input degree in model graph: " << MDegIn[MDegIn.Len()-1].GetVal1() << endl;


    if (ModelGen == "model+kron"){
        // generate (or read) Kronecker initiator matrix
        TKronMtx FitMtxM;
        if (!GetMtx(Parameters[MTXGEN], FitMtxM))
            GenNewMtx(G, Parameters[KRONFIT], FitMtxM);
        PrintMtx(FitMtxM, TFile);
        TFile << "Scaling for the number of edges... " << endl;
        FitMtxM.SetForEdges(G->GetNodes(), G->GetEdges());

        int ModelNodes = G->GetNodes(), ModelEdges = G->GetEdges();

        Env = TEnv(Parameters[KRONGEN], TNotify::NullNotify);
        TStr IsDir = Env.GetIfArgPrefixStr("-isdir:", "false", "Produce directed graph (true, false)");
        const TInt NIter = Env.GetIfArgPrefixInt("-i:", 1, "Number of iterations of Kronecker product");
        
        if (pow(FitMtxM.GetDim(), static_cast<double>(NIter)) != ModelNodes)
            Error("GetGraphs", "Inconsistent value of -i: parameter, KronNodes != ModelNodes");
              

        // in and out average degrees of Kronecker graphs
        TFltPrV KronDegAvgIn, KronDegAvgOut;

       
        GenKron(Parameters[KRONGEN], FitMtxM, KronDegAvgIn, KronDegAvgOut);

        PlotDegrees(Parameters, KronDegAvgIn, KronDegAvgOut, "kron");

    }
}