Deadcode
[openmx:openmx.git] / src / omxExpectation.h
1 /*
2  *  Copyright 2007-2013 The OpenMx Project
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *       http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *   Unless required by applicable law or agreed to in writing, software
11  *   distributed under the License is distributed on an "AS IS" BASIS,
12  *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License.
15  */
16
17 /***********************************************************
18
19 *  omxExpectation.h
20 *
21 *  Created: Timothy R. Brick    Date: 2009-02-17
22 *
23 *       Contains header information for the omxExpectation class
24 *   omxExpectation objects hold necessary information to simplify
25 *       Expectation function calculation.
26 *
27 **********************************************************/
28
29 #ifndef _OMXEXPECTATION_H_
30 #define _OMXEXPECTATION_H_
31
32 #include <R.h>
33 #include <Rinternals.h> 
34 #include <Rdefines.h>
35 #include <R_ext/Rdynload.h> 
36 #include <R_ext/BLAS.h>
37 #include <R_ext/Lapack.h>
38 #include "omxDefines.h"
39
40 typedef struct omxExpectation omxExpectation;
41 typedef struct omxDefinitionVar omxDefinitionVar;
42
43 #include "omxMatrix.h"
44 #include "omxAlgebra.h"
45 #include "omxAlgebraFunctions.h"
46 #include "omxData.h"
47 #include "omxState.h"
48
49 /* Def Var and Threshold Structures */
50 struct omxDefinitionVar {                       // Definition Var
51
52         int data, column;               // Where it comes from
53         omxData* source;                // Data source
54         int numLocations;               // Num locations
55         int* rows;                              // row positions
56         int* cols;                              // column positions
57         int* matrices;                  // matrix numbers
58         int  numDeps;           // number of algebra/matrix dependencies
59         int* deps;              // indices of algebra/matrix dependencies
60
61 };
62
63 /* Expectation structure itself */
64 struct omxExpectation {                                 // An Expectation
65
66         /* Fields unique to Expectation Functions */
67         void (*initFun)(omxExpectation *ox);
68         void (*destructFun)(omxExpectation* ox);                                                                        // Wrapper for the destructor object
69         void (*computeFun)(omxExpectation* ox);                                                                         // Wrapper for the Expectation function itself
70         void (*printFun)(omxExpectation* ox);                                                                           // Prints the appropriate pieces of the expectation
71         void (*populateAttrFun)(omxExpectation* ox, SEXP algebra);                                      // Add attributes to the result algebra object
72         omxMatrix* (*componentFun)(omxExpectation*, omxFitFunction*, const char*);              // Return component locations to expectation
73         void (*mutateFun)(omxExpectation*, omxFitFunction*, const char*, omxMatrix*); // Modify/set/mutate components of expectation
74         
75         SEXP rObj;                                                                                                                                      // Original r Object Pointer
76         void* argStruct;                                                                                                                        // Arguments needed for Expectation function
77         const char* expType;   // pointer to a static string, no need to allocate or free
78
79         omxData* data;                                                                                                                          // Not sure if this is appropriate, but the expectation passes the actual data object
80         omxMatrix* dataColumns;
81         omxThresholdColumn* thresholds;
82         omxDefinitionVar* defVars;
83         int numOrdinal, numDefs;
84         
85         /* Replication of some of the structures from Matrix */
86         unsigned short isComplete;                                                                                                      // Whether or not this expectation has been initialize
87         omxState* currentState;
88         int expNum;
89
90         omxExpectation *container;
91         int numSubmodels;
92         omxExpectation **submodels;
93 };
94
95 omxExpectation *
96 omxNewInternalExpectation(const char *expType, omxState* os);
97
98         void omxCompleteExpectation(omxExpectation *ox);
99         void omxFreeExpectationArgs(omxExpectation* Expectation);                                       // Frees all args
100 omxExpectation* omxExpectationFromIndex(int expIndex, omxState* os);
101         omxExpectation* omxNewIncompleteExpectation(SEXP mxobj, int expNum, omxState* os);
102         
103
104 /* Expectation-specific implementations of matrix functions */
105         void omxExpectationRecompute(omxExpectation *ox);
106         void omxExpectationCompute(omxExpectation *ox);
107         omxExpectation* omxDuplicateExpectation(const omxExpectation *src, omxState* newState);
108         
109         void omxExpectationPrint(omxExpectation *source, char* d);                                      // Pretty-print a (small-form) expectation
110         
111 omxMatrix* omxGetExpectationComponent(omxExpectation *ox, omxFitFunction *off, const char* component);
112         
113 void omxSetExpectationComponent(omxExpectation *ox, omxFitFunction *off, const char* component, omxMatrix *om);
114
115 #endif /* _OMXEXPECTATION_H_ */