char *bayes::calcType(char *input) { // split int samplesInInput = 0, i = 0; char **samples = new char*[1024]; for (i = 0; i < 1024; i++) samples[i] = new char[0x20]; textSplitter(samples, samplesInInput, input); // calc double *isType = new double[getTotalTypes()], tmp = 0; int j = 0; for (j = 0; j < getTotalTypes(); j++) isType[j] = 1.000; for (i = 0; i < samplesInInput; i++) for (j = 0; j < getTotalTypes(); j++) isType[j] *= getPtkc(samples[i], getTypeName(j)); for (j = 0; j < getTotalTypes(); j++) isType[j] *= getPc(getTypeName(j)); int retID = 0; for (i = 0; i < getTotalTypes(); i++) { if (tmp <= isType[i]) { tmp = isType[i]; retID = i; } } // testOut for (i = 0; i < getTotalTypes(); i++) printf("P(%s) = %lf\n", getTypeName(i), getPc(getTypeName(i))); for (i = 0; i < getTotalTypes(); i++) for (j = 0; j < samplesInInput; j++) printf("P(%s|%s) = %lf\n", samples[j], getTypeName(i), getPtkc(samples[i], getTypeName(i))); for (i = 0; i < getTotalTypes(); i++) printf("\tP(%s|d) = %lf\n", getTypeName(i), isType[i]); // dispose for (i = 0; i < samplesInInput; i++) delete[]samples[i]; delete[]samples; delete[]isType; return getTypeName(retID); }
/** * Create a compact form of the specified call stack. * One int per frame containing * the method number and current offset. If the ignore parameter is non null * then frames that have a matching this field will not be included in the * trace. This allow the frames for the creation of an exception object to * be ignored. */ Object * create_stack_trace(Thread *thread, Object *ignore) { int frameCnt = thread->stackFrameIndex; Object *stackArray; JINT *data; int i; StackFrame *topFrame = ((StackFrame *)array_start(thread->stackFrameArray)) + frameCnt; StackFrame *stackFrame = topFrame; MethodRecord *methodBase = get_method_table(get_class_record(0)); byte *pcBase = get_binary_base() + 2; // Ignore frames if required. if (ignore) { while ((STACKWORD)ignore == *(stackFrame->localsBase)) { stackFrame--; frameCnt--; } } // Try and allocate the space for the trace. stackArray = new_single_array(AI, frameCnt); if (stackArray == JNULL) return JNULL; if (thread == currentThread) topFrame->pc = getPc(); // adjust top most pc to allow for return address hack topFrame->pc += 2; // Fill in the trace. data = jint_array(stackArray); for(i = 0; i < frameCnt; i++) { data[i] = ((stackFrame->methodRecord - methodBase) << 16) | (stackFrame->pc - pcBase - stackFrame->methodRecord->codeOffset); stackFrame--; } // restore correct pc topFrame->pc -= 2; return stackArray; }