float checkMultithreaded (string const & myResult, string const & learning)
{
    ofstream cmpLog("compare_log.txt", ofstream::trunc);
    if (!cmpLog.is_open())
    {
        cerr << "Cannot create compare_log file.\n";
        return 0;
    }

    map<int, vector<int> > myOdds = readOutput(myResult);
    map<int, vector<int> > trueOdds = readOutput(learning);

    int currentSetN = StartSet;
    int n_wrong = 0;
    float mark = 0;

    Stitcher stitcher;

    while (currentSetN < FinishSet)
    {
        vector<int> v1 = getNextSet(currentSetN, myOdds);
        vector<int> v2 = getNextSet(currentSetN, trueOdds);
        float tmpMark = compareResults(v1, v2);
        if (tmpMark != 1.0)
        {
            cmpLog << currentSetN << "\nmy odds:";
            printIntVector(cmpLog, v1);
            cmpLog << "true odds:";
            printIntVector(cmpLog, v2);

            int tmp;
            printMat_(cmpLog, stitcher.calcSetStitch2(currentSetN, &tmp));
            //Stitcher::printStitchMatrix(cmpLog, stitcher.calcSetStitch2(currentSetN));

            n_wrong += 1;

        }
        mark += tmpMark;
        currentSetN += 1;
    }
    cmpLog << n_wrong << " classified wrong.";
    cmpLog.close();
    return (currentSetN-StartSet>0) ? mark/(currentSetN-StartSet) : mark;
}
Exemple #2
0
int main( int argc, char** argv )
{
		int vector1[] = {1,2,3,4,5};
		int vector2[] = {6,7,8,9,10};
		
		int* vetorfinal = joinVector(vector1, 5, vector2, 5);

		printIntVector(vetorfinal, 10);

		return 0;
}
void testIntVector(void) {
    intVector *a = intVector_construct(1);
    int *elements = a->elements;
    int i = 0;
    // Vector contains numbers from 1 to inclusive 10
    for (i = 0; i < 10; ++i) {
        intVector_add(a, i + 1);
    }
    int sum = 0;
    for (i = 0; i < 10; ++i) {
        sum += *(intVector_get(a, i));
    }
    printf("Sum from 1 to 10 (must be 55): %d is %s\n", sum, (sum == 55) ? "True" : "False"  );

    puts("Tests for get which generate errors");
    intVector_get(a, -4);
    intVector_get(a, a->size);
    puts("");

    printIntVector(a);
    puts("Remove value at index 5");
    int r;
    intVector_removeAt(a, 5, &r);
    printf("Removed value : %d\n", r);
    printIntVector(a);
    puts("");

    puts("Remove elements to resize the array");
    printf("Old: C:%d S:%d\n", a->capacity, a->size);
    for ( i = 0 ; i < 6 ; ++i) {
        intVector_removeAt(a, 1, &r);
    }
    printf("New: C:%d S:%d\n", a->capacity, a->size);
    printIntVector(a);

    puts("");
    r = 11;
    printf("Remove the %d: ",r);
    r = intVector_remove(a, &r, &equalsInt);
    printf("%s\n", (r == EXIT_SUCCESS) ? "True" : "False"  );
    printIntVector(a);

    puts("");
    r = 9;
    printf("Remove the %d: ",r);
    r = intVector_remove(a, &r, &equalsInt);
    printf("%s\n", (r == EXIT_SUCCESS) ? "True" : "False"  );
    printIntVector(a);

    puts("Add elements from 11 to 20 and test if 13 is contained");
    for (i = 10; i < 20; ++i) {
        intVector_add(a, i + 1);
    }
    printIntVector(a);
    r = 13;
    printf("Contains 13: %s\n", intVector_contains(a, &r, &equalsInt) == EXIT_SUCCESS ? "True" : "False"  );
}