Eliminate Rprintf
[openmx:openmx.git] / src / omxFitFunctionBA81.cpp
1 /*
2  * This is throw-away proof-of-concept code that will likely be
3  * replaced by something else.
4  *
5  * JNP 2012Dec10
6  */
7
8 #include "omxFitFunction.h"
9 #include "omxExpectationBA81.h"
10
11 static const char *NAME = "FitFunctionBA81";
12
13 typedef struct {
14
15         omxData *data;
16
17 } omxBA81State;
18
19
20 static void ba81Destroy(omxFitFunction *oo) {
21         //omxBA81State *mml = (omxBA81State *) oo->argStruct;
22         // nothing to do yet
23 }
24
25 // TODO: Don't trample the Expectation/FitFunction separation.
26
27 static omxRListElement *ba81SetFinalReturns(omxFitFunction *off, int *numReturns)
28 {
29         return ba81EAP(off->expectation, numReturns);
30 }
31
32 static void ba81Compute(omxFitFunction *oo, int want, double *gradient, double *hessian) {
33         omxExpectation* expectation = oo->expectation;
34   
35         oo->matrix->data[0] = ba81ComputeFit(expectation, want, gradient, hessian);
36 }
37
38 void omxInitFitFunctionBA81(omxFitFunction* oo, SEXP rObj) {
39         //omxExpectation* expectation = oo->expectation;
40
41         //omxState* currentState = oo->matrix->currentState;
42         
43         //omxBA81State *newObj = (omxBA81State*) R_alloc(1, sizeof(omxBA81State));
44         
45         //newObj->data = oo->expectation->data;
46
47         omxExpectationCompute(oo->expectation, COMPUTE_EXPECT_INITIALIZE);
48
49         oo->computeFun = ba81Compute;
50         oo->setFinalReturns = ba81SetFinalReturns;
51         oo->destructFun = ba81Destroy;
52 }