예제 #1
0
double BorderMattingHandler::dataTermForPixel(const Vec3f &pixel, const double alpha, const Gauss &bgd, const Gauss &fgd){
    Vec3f miu;
    Mat cov(3,3,CV_64FC1);
    miu = (1-alpha)*fgd.getmean() + alpha*bgd.getmean();
    cov = (1-alpha)*(1-alpha)*fgd.getcovmat() + alpha*alpha*bgd.getcovmat();
    return Gauss::probability(miu, cov, pixel);
}
예제 #2
0
void QK_find_N_opt()
{
    using namespace Feel;
    typedef T value_type;

    Gauss<Hypercube<2,1>, N ,value_type > im;

    ublas::vector<value_type> x_i( ublas::row( im.points(),0 ) );
    ublas::vector<value_type> y_i( ublas::row( im.points(),1 ) );
    const value_type tol = value_type( 7.0 )*type_traits<value_type>::epsilon();

    /* 1D number of Nodes */
    //@{
    uint16_type Q = ( uint16_type )sqrt( im.nPoints() );
    //@}

    value_type error = 0.0;
    value_type res;
    uint16_type i=1;
    value_type sum=0.0;

    ost << "Nbre of Points on the Quadrangle : " << Q << "^2 = "<< im.nPoints() <<  std::endl;

    do
    {
        if ( i%2 == 0 )
            res = value_type( 4.0 )/value_type( i+1.0 )/value_type( i+1.0 );

        else
            res = 0.0;

        sum = 0.0;

        for ( uint16_type l=0; l< x_i.size(); ++l )
        {
            sum += pow( x_i( l ),i )*pow( y_i( l ),i )*im.weight( l );
        }

        error = math::abs( sum - res );
        ost << "i = " << i <<" Error = "<< error << "\n";
        ++i;
    }
    while ( error <= tol );

    if ( i-2 < 2*Q-1  )
        QK_log << "Q = " << Q << " ; i = " << i << " ; Error" << error << std::endl;

    BOOST_CHECK( i-2 >= 2*Q-1  );
}
예제 #3
0
int test35() {
    string target = "679662059";
    Gauss* pObj = new Gauss();
    clock_t start = clock();
    vector<string> result = pObj->whichSums(target);
    clock_t end = clock();
    delete pObj;
    vector<string> expected = {"[46727, 59520]", "[103049, 109445]", "[578342, 579515]", "[1157564, 1158150]", "[1877339, 1877700]", "[3754949, 3755129]", "[339831029, 339831030]"};
    if(result == expected) {
        cout << "Test Case 35: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 35: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
예제 #4
0
int test56() {
    string target = "33333333333";
    Gauss* pObj = new Gauss();
    clock_t start = clock();
    vector<string> result = pObj->whichSums(target);
    clock_t end = clock();
    delete pObj;
    vector<string> expected = {"[191673, 321566]", "[480766, 545712]", "[748210, 791507]", "[1528893, 1550541]", "[5555555553, 5555555558]", "[11111111110, 11111111112]", "[16666666666, 16666666667]"};
    if(result == expected) {
        cout << "Test Case 56: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 56: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
예제 #5
0
int test54() {
    string target = "92147483647";
    Gauss* pObj = new Gauss();
    clock_t start = clock();
    vector<string> result = pObj->whichSums(target);
    clock_t end = clock();
    delete pObj;
    vector<string> expected = {"[2099638, 2143075]", "[4231854, 4253572]", "[78489604, 78490777]", "[156980088, 156980674]", "[1245236229, 1245236302]", "[2490472513, 2490472549]", "[46073741823, 46073741824]"};
    if(result == expected) {
        cout << "Test Case 54: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 54: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
예제 #6
0
int test52() {
    string target = "123456789";
    Gauss* pObj = new Gauss();
    clock_t start = clock();
    vector<string> result = pObj->whichSums(target);
    clock_t end = clock();
    delete pObj;
    vector<string> expected = {"[5117, 16525]", "[5999, 16819]", "[12429, 20034]", "[13507, 20720]", "[30562, 34364]", "[32424, 36030]", "[6858702, 6858719]", "[13717417, 13717425]", "[20576129, 20576134]", "[41152262, 41152264]", "[61728394, 61728395]"};
    if(result == expected) {
        cout << "Test Case 52: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 52: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
예제 #7
0
int test50() {
    string target = "9999999999";
    Gauss* pObj = new Gauss();
    clock_t start = clock();
    vector<string> result = pObj->whichSums(target);
    clock_t end = clock();
    delete pObj;
    vector<string> expected = {"[20709, 142929]", "[49999, 149999]", "[50002, 150000]", "[81312, 163130]", "[116669, 183334]", "[156059, 210604]", "[159537, 213194]", "[283337, 316669]", "[353027, 380299]", "[359317, 386145]", "[438894, 461115]", "[540904, 559085]", "[550154, 568039]", "[894454, 905564]", "[1095444, 1104534]", "[1113722, 1122664]", "[1227772, 1235889]", "[1674309, 1680270]", "[2047582, 2052459]", "[2461632, 2465690]", "[3353089, 3356069]", "[3694139, 3696844]", "[4098822, 4101260]", "[6149249, 6150874]", "[7390307, 7391659]", "[11086024, 11086925]", "[12299717, 12300529]", "[13549767, 13550504]", "[18449914, 18450455]", "[22172724, 22173174]", "[27100087, 27100455]", "[36900234, 36900504]", "[40650284, 40650529]", "[50504952, 50505149]", "[81300752, 81300874]", "[101010052, 101010150]", "[121951179, 121951260]", "[151515119, 151515184]", "[243902419, 243902459]", "[303030287, 303030319]", "[454545444, 454545465]", "[555555547, 555555564]", "[909090904, 909090914]", "[1111111107, 1111111115]", "[1666666664, 1666666669]", "[3333333332, 3333333334]", "[4999999999, 5000000000]"};
    if(result == expected) {
        cout << "Test Case 50: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 50: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
예제 #8
0
int test48() {
    string target = "99999999977";
    Gauss* pObj = new Gauss();
    clock_t start = clock();
    vector<string> result = pObj->whichSums(target);
    clock_t end = clock();
    delete pObj;
    vector<string> expected = {"[49999999988, 49999999989]"};
    if(result == expected) {
        cout << "Test Case 48: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 48: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
예제 #9
0
int test29() {
    string target = "890593";
    Gauss* pObj = new Gauss();
    clock_t start = clock();
    vector<string> result = pObj->whichSums(target);
    clock_t end = clock();
    delete pObj;
    vector<string> expected = {"[40471, 40492]", "[80958, 80968]", "[445296, 445297]"};
    if(result == expected) {
        cout << "Test Case 29: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 29: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
예제 #10
0
int test28() {
    string target = "730041";
    Gauss* pObj = new Gauss();
    clock_t start = clock();
    vector<string> result = pObj->whichSums(target);
    clock_t end = clock();
    delete pObj;
    vector<string> expected = {"[9321, 9398]", "[18700, 18738]", "[28066, 28091]", "[56151, 56163]", "[121671, 121676]", "[243346, 243348]", "[365020, 365021]"};
    if(result == expected) {
        cout << "Test Case 28: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 28: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
예제 #11
0
int test27() {
    string target = "47539";
    Gauss* pObj = new Gauss();
    clock_t start = clock();
    vector<string> result = pObj->whichSums(target);
    clock_t end = clock();
    delete pObj;
    vector<string> expected = {"[37, 310]", "[279, 415]", "[23769, 23770]"};
    if(result == expected) {
        cout << "Test Case 27: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 27: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
예제 #12
0
int test25() {
    string target = "3775";
    Gauss* pObj = new Gauss();
    clock_t start = clock();
    vector<string> result = pObj->whichSums(target);
    clock_t end = clock();
    delete pObj;
    vector<string> expected = {"[51, 100]", "[139, 163]", "[373, 382]", "[753, 757]", "[1887, 1888]"};
    if(result == expected) {
        cout << "Test Case 25: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 25: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
예제 #13
0
int test24() {
    string target = "8230";
    Gauss* pObj = new Gauss();
    clock_t start = clock();
    vector<string> result = pObj->whichSums(target);
    clock_t end = clock();
    delete pObj;
    vector<string> expected = {"[402, 421]", "[1644, 1648]", "[2056, 2059]"};
    if(result == expected) {
        cout << "Test Case 24: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 24: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
예제 #14
0
int test14() {
    string target = "99999999998";
    Gauss* pObj = new Gauss();
    clock_t start = clock();
    vector<string> result = pObj->whichSums(target);
    clock_t end = clock();
    delete pObj;
    vector<string> expected = {"[862068908, 862069023]", "[3448275848, 3448275876]", "[24999999998, 25000000001]"};
    if(result == expected) {
        cout << "Test Case 14: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 14: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
예제 #15
0
int test13() {
    string target = "99999999997";
    Gauss* pObj = new Gauss();
    clock_t start = clock();
    vector<string> result = pObj->whichSums(target);
    clock_t end = clock();
    delete pObj;
    vector<string> expected = {"[2941176454, 2941176487]", "[5882352933, 5882352949]", "[49999999998, 49999999999]"};
    if(result == expected) {
        cout << "Test Case 13: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 13: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
예제 #16
0
int test38() {
    string target = "12624469209";
    Gauss* pObj = new Gauss();
    clock_t start = clock();
    vector<string> result = pObj->whichSums(target);
    clock_t end = clock();
    delete pObj;
    vector<string> expected = {"[63759847, 63760044]", "[127519842, 127519940]", "[191279804, 191279869]", "[382559657, 382559689]", "[573839499, 573839520]", "[701359392, 701359409]", "[1147679014, 1147679024]", "[1402718797, 1402718805]", "[2104078199, 2104078204]", "[4208156402, 4208156404]", "[6312234604, 6312234605]"};
    if(result == expected) {
        cout << "Test Case 38: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 38: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
예제 #17
0
int test30() {
    string target = "3462649";
    Gauss* pObj = new Gauss();
    clock_t start = clock();
    vector<string> result = pObj->whichSums(target);
    clock_t end = clock();
    delete pObj;
    vector<string> expected = {"[1267, 2920]", "[3774, 4600]", "[21837, 21994]", "[32614, 32719]", "[43792, 43870]", "[65307, 65359]", "[1731324, 1731325]"};
    if(result == expected) {
        cout << "Test Case 30: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 30: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
예제 #18
0
int test49() {
    string target = "100000000000";
    Gauss* pObj = new Gauss();
    clock_t start = clock();
    vector<string> result = pObj->whichSums(target);
    clock_t end = clock();
    delete pObj;
    vector<string> expected = {"[60688, 451312]", "[925363, 1027762]", "[1240938, 1319062]", "[4872573, 4893052]", "[6392188, 6407812]", "[24412015, 24416110]", "[31998438, 32001562]", "[159999688, 160000312]", "[799999938, 800000062]", "[3999999988, 4000000012]", "[19999999998, 20000000002]"};
    if(result == expected) {
        cout << "Test Case 49: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 49: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
예제 #19
0
int test31() {
    string target = "3453244";
    Gauss* pObj = new Gauss();
    clock_t start = clock();
    vector<string> result = pObj->whichSums(target);
    clock_t end = clock();
    delete pObj;
    vector<string> expected = {"[2334, 3514]", "[4359, 5089]", "[9867, 10210]", "[25324, 25459]", "[80287, 80329]", "[203124, 203140]", "[431652, 431659]"};
    if(result == expected) {
        cout << "Test Case 31: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 31: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
예제 #20
0
int test51() {
    string target = "99999999999";
    Gauss* pObj = new Gauss();
    clock_t start = clock();
    vector<string> result = pObj->whichSums(target);
    clock_t end = clock();
    delete pObj;
    vector<string> expected = {"[61779, 451460]", "[415819, 610659]", "[704912, 834805]", "[1507244, 1572190]", "[2287927, 2331224]", "[4608327, 4629975]", "[5555555547, 5555555564]", "[11111111107, 11111111115]", "[16666666664, 16666666669]", "[33333333332, 33333333334]", "[49999999999, 50000000000]"};
    if(result == expected) {
        cout << "Test Case 51: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 51: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
예제 #21
0
int test32() {
    string target = "10286461";
    Gauss* pObj = new Gauss();
    clock_t start = clock();
    vector<string> result = pObj->whichSums(target);
    clock_t end = clock();
    delete pObj;
    vector<string> expected = {"[24165, 24586]", "[48646, 48856]", "[5143230, 5143231]"};
    if(result == expected) {
        cout << "Test Case 32: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 32: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
예제 #22
0
int test53() {
    string target = "42";
    Gauss* pObj = new Gauss();
    clock_t start = clock();
    vector<string> result = pObj->whichSums(target);
    clock_t end = clock();
    delete pObj;
    vector<string> expected = {"[3, 9]", "[9, 12]", "[13, 15]"};
    if(result == expected) {
        cout << "Test Case 53: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 53: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
예제 #23
0
int test33() {
    string target = "32142027";
    Gauss* pObj = new Gauss();
    clock_t start = clock();
    vector<string> result = pObj->whichSums(target);
    clock_t end = clock();
    delete pObj;
    vector<string> expected = {"[277, 8022]", "[6363, 10235]", "[11158, 13739]", "[24252, 25542]", "[27178, 28335]", "[55224, 55802]", "[83077, 83462]", "[124453, 124710]", "[166443, 166635]", "[249099, 249227]", "[373702, 373787]", "[747468, 747510]", "[5357002, 5357007]", "[10714008, 10714010]", "[16071013, 16071014]"};
    if(result == expected) {
        cout << "Test Case 33: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 33: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
예제 #24
0
int test55() {
    string target = "50005000";
    Gauss* pObj = new Gauss();
    clock_t start = clock();
    vector<string> result = pObj->whichSums(target);
    clock_t end = clock();
    delete pObj;
    vector<string> expected = {"[1, 10000]", "[918, 10042]", "[5643, 11482]", "[12888, 16312]", "[21717, 23908]", "[24003, 26002]", "[26488, 28312]", "[42229, 43396]", "[72658, 73342]", "[79696, 80320]", "[124813, 125212]", "[136818, 137182]", "[364932, 365068]", "[399978, 400102]", "[625023, 625102]", "[684964, 685036]", "[2000188, 2000212]", "[3125305, 3125320]", "[10000998, 10001002]"};
    if(result == expected) {
        cout << "Test Case 55: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 55: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
예제 #25
0
int test34() {
    string target = "323600046";
    Gauss* pObj = new Gauss();
    clock_t start = clock();
    vector<string> result = pObj->whichSums(target);
    clock_t end = clock();
    delete pObj;
    vector<string> expected = {"[349755, 350678]", "[1050496, 1050803]", "[1400751, 1400981]", "[2451450, 2451581]", "[3852340, 3852423]", "[4202560, 4202636]", "[7354525, 7354568]", "[9806046, 9806078]", "[11557131, 11557158]", "[15409516, 15409536]", "[26966665, 26966676]", "[29418181, 29418191]", "[46228575, 46228581]", "[80900010, 80900013]", "[107866681, 107866683]"};
    if(result == expected) {
        cout << "Test Case 34: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 34: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
예제 #26
0
int test36() {
    string target = "3674679277";
    Gauss* pObj = new Gauss();
    clock_t start = clock();
    vector<string> result = pObj->whichSums(target);
    clock_t end = clock();
    delete pObj;
    vector<string> expected = {"[204349, 221602]", "[421638, 430264]", "[830299, 834712]", "[1663908, 1666114]", "[9519702, 9520087]", "[19039693, 19039885]", "[1837339638, 1837339639]"};
    if(result == expected) {
        cout << "Test Case 36: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 36: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
예제 #27
0
int test37() {
    string target = "2766184524";
    Gauss* pObj = new Gauss();
    clock_t start = clock();
    vector<string> result = pObj->whichSums(target);
    clock_t end = clock();
    delete pObj;
    vector<string> expected = {"[112339, 134730]", "[366872, 374335]", "[986877, 989675]", "[1110567, 1113054]", "[2964362, 2965294]", "[8894329, 8894639]", "[38419194, 38419265]", "[115257677, 115257700]", "[307353832, 307353840]", "[345773062, 345773069]", "[922061507, 922061509]"};
    if(result == expected) {
        cout << "Test Case 37: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 37: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
예제 #28
0
파일: MxElem.cpp 프로젝트: wpoely86/ThING
/**
 * Function to find the total number of orbitals corresponding to a problem
 * @param readin the problem to be solved
 * @return the number of different orbitals
 */
int MxElem::CalcTotalNumberOfOrbitals(input & readin){

   int counter = 0;
   int Ncores = readin.gNcores();

   for (int cnt=0; cnt<Ncores; cnt++){

      Gauss * atom = readin.gGaussInfo(cnt);
      int Ntypes = atom->gNtypes();
      
      for (int cnt2=0; cnt2<Ntypes; cnt2++){

         char type = atom->gtype(cnt2);
         int L = GetLofType(type);
         counter += ((L+1)*(L+2))/2;

      }

   }

   return counter;

}
예제 #29
0
double* Krylov::getPoly ()
{
    double** Q = new double* [size];
    for (int i=0;i<size;i++)
    {
        Q[i] = new double[size+1];
    }
    double* c = new double [size];
    for (int i=0;i<size;i++)
    {
        c[i]= c_0[i];
    }
    for (int i=0;i<size+1;i++)
    {
        for (int j=0;j<size;j++)
        {
            Q[j][((size+1)+size-1-i)%(size+1)] = c[j];
        }
        c = mulMatrix (c);

    }
    Gauss gauss = Gauss(Q,size);
    int m = 0;
    double* p = gauss.solve (m);
    if (m==size)
    {
        return p;
    }
    else
    {
        printf ("Only %d steps on get Poly\n",m);
    }
    for (int i=0;i<size;i++) delete [] Q[i];
    delete [] Q;
    delete [] c;
    return NULL;
}
예제 #30
0
void PK_find_N_opt()
//@}
{
    using namespace Feel;

    typedef T value_type;

    Gauss<Simplex<2,1> , N, value_type> im;

    ublas::vector<value_type> x_i( ublas::row( im.points(),0 ) );
    ublas::vector<value_type> y_i( ublas::row( im.points(),1 ) );

    const value_type tol = value_type( 7.0 )*type_traits<value_type>::epsilon();

    ost << "Tolerance = " << tol << "\n";

    uint16_type Q = ( uint16_type )sqrt( im.nPoints() );

    value_type error;
    value_type res;
    uint16_type i=1;
    value_type sum;

    ost << "Nbre of Points on the triangle : " << Q << "^2 = "<< im.nPoints() <<  std::endl;

    do
    {
        if ( i%2 == 0 )
            res = value_type( 2.0 )/value_type( double( i )+1.0 )/value_type( double( i )+1.0 );

        else
            res = value_type( 0.0 );

        sum = value_type( 0.0 );

        for ( uint16_type l=0; l< x_i.size(); ++l )
        {
            value_type p = pow( x_i( l ),i )*pow( y_i( l ),i )*im.weight( l );
            //        std::cout << "Contrib = " << p << "\n";
            sum += p;
        }

#if 0
        std::cout << "i = " << i << "\n";
        std::cout << "res = " << res << "\n";
        std::cout << "sum = " << sum << "\n";
#endif

        error = math::abs( sum - res );
        ost << "i = " << i <<" Error = "<< error << "\n";

        ++i;
    }
    while ( error <= tol );

    if ( i-2 < Q-1  )
        PK_log << "Q = " << Q << " ; i = " << i << " ; Error = " << error << std::endl;

    BOOST_CHECK( i-2 >= Q-1  );

}