55 |
/** |
/** |
56 |
Return the output variable instance from r, assuming r is from a blackbox. |
Return the output variable instance from r, assuming r is from a blackbox. |
57 |
*/ |
*/ |
58 |
extern struct Instance *BlackBoxGetOutputVar(struct relation *r); |
extern struct Instance *BlackBoxGetOutputVar(CONST struct relation *r); |
59 |
|
|
60 |
/** All the relations evaluated in a single call to y=f(x) have this data in common. */ |
/** All the relations evaluated in a single call to y=f(x) have this data in common. */ |
61 |
struct BlackBoxCache { /* was extrelcache, sort of. */ |
struct BlackBoxCache { /* was extrelcache, sort of. */ |
62 |
struct gl_list_t *formalArgList; /**< only passed on pre_slv */ |
struct gl_list_t *argListNames; /**< list of list of names. */ |
63 |
|
struct Name *dataName; /**< name of the DATA instance. */ |
64 |
|
struct ExternalFunc *efunc; /**< external function table. */ |
65 |
struct BBoxInterp interp; /**< userdata lives in here only */ |
struct BBoxInterp interp; /**< userdata lives in here only */ |
66 |
int32 inputsLen; /**< number of actual, not formal, inputs */ |
int32 inputsLen; /**< number of actual, not formal, inputs */ |
67 |
int32 outputsLen; /**< number of actual, not formal, outputs. */ |
int32 outputsLen; /**< number of actual, not formal, outputs. */ |
74 |
double *hessian; /**< undetermined format */ |
double *hessian; /**< undetermined format */ |
75 |
int residCount; /**< number of calls made for y output. */ |
int residCount; /**< number of calls made for y output. */ |
76 |
int gradCount; /**< number of calls made for gradient. */ |
int gradCount; /**< number of calls made for gradient. */ |
77 |
int refCount; /* when to destroy */ |
int refCount; /**< when to destroy */ |
78 |
|
int count; /**< serial number */ |
79 |
}; |
}; |
80 |
|
|
81 |
|
/** Fetch the input array len size. |
82 |
|
@param bbc the source. |
83 |
|
*/ |
84 |
|
extern int32 BlackBoxCacheInputsLen(struct BlackBoxCache *bbc); |
85 |
|
|
86 |
/** All the elements of an array of blackbox relations resulting |
/** All the elements of an array of blackbox relations resulting |
87 |
from a single external statement have the BlackBoxCache in common, but |
from a single external statement have the BlackBoxCache in common, but |
88 |
the varlist and lhs are unique to the specific relation. |
the varlist and lhs are unique to the specific relation. |
91 |
*/ |
*/ |
92 |
struct BlackBoxData { |
struct BlackBoxData { |
93 |
struct BlackBoxCache *common; |
struct BlackBoxCache *common; |
94 |
unsigned long *inputArgs; /**< an array of indexes into the varlist; |
int count; |
|
see notes elsewhere about why varlist |
|
|
may be shorter than arglist due to alias/ats. |
|
|
size is in common. */ |
|
|
unsigned long lhsindex; /**< location of value yhati in C output array. */ |
|
|
unsigned long lhsvar; /**< location of lhs var(yi) in varlist. */ |
|
95 |
}; |
}; |
96 |
|
|
97 |
/* make a blackboxdata unique to a single relation. */ |
/** make a blackboxdata unique to a single relation. |
98 |
extern struct BlackBoxData *CreateBlackBoxData(struct BlackBoxCache *common, |
@param common the data common to all the relations in the array of blackbox output relations. |
99 |
unsigned long lhsindex, |
@param lhsindex the index of this relation's residual in the blackbox output vector. |
100 |
unsigned long lhsVarNumber); |
@param lhsVarNumber the index of the output variable (y) in the relation's varlist. |
101 |
|
*/ |
102 |
|
extern struct BlackBoxData *CreateBlackBoxData(struct BlackBoxCache *common); |
103 |
|
|
104 |
|
/* do anoncopy of bbox data for relation sharing. */ |
105 |
|
extern void CopyBlackBoxDataByReference(struct relation *src, struct relation *dest, void *bboxtable_p); |
106 |
|
|
107 |
/* called when destroying the relation containing b. */ |
/* called when destroying the relation containing b. */ |
108 |
extern void DestroyBlackBoxData(struct relation * rel, struct BlackBoxData *b); |
extern void DestroyBlackBoxData(struct relation * rel, struct BlackBoxData *b); |
115 |
persistent structure. |
persistent structure. |
116 |
@param inputsLen number of actual, not formal, inputs. |
@param inputsLen number of actual, not formal, inputs. |
117 |
@param outputsLen number of actual, not formal, outputs. |
@param outputsLen number of actual, not formal, outputs. |
118 |
@param formalArgs list of list of args, which will be copied. |
@param argListNames list of lists of names of real atom instances in/output. |
119 |
|
@param dataName name of the data instance. |
120 |
*/ |
*/ |
121 |
extern struct BlackBoxCache *CreateBlackBoxCache( int32 inputsLen, int32 outputsLen, struct gl_list_t *formalArgs); |
extern struct BlackBoxCache *CreateBlackBoxCache( int32 inputsLen, int32 outputsLen, struct gl_list_t *argListNames, struct Name *dataName, struct ExternalFunc *efunc); |
122 |
|
|
123 |
/** make a persistent reference to b. */ |
/** make a persistent reference to b. */ |
124 |
extern void AddRefBlackBoxCache(struct BlackBoxCache *b); |
extern void AddRefBlackBoxCache(struct BlackBoxCache *b); |
125 |
|
|
126 |
|
/** dispatch the init function on a bbox after updating the input instance list |
127 |
|
from the names list. |
128 |
|
@param context the parent model containing the relations the cache is |
129 |
|
referenced by. |
130 |
|
@param b a cache in need of the init call. |
131 |
|
*/ |
132 |
|
extern void InitBBox(struct Instance *context, struct BlackBoxCache *b); |
133 |
|
|
134 |
/** remove a persistent reference to *b. |
/** remove a persistent reference to *b. |
135 |
sets *b to null before returning. |
sets *b to null before returning. |
136 |
deallocates **b if refcount has dropped to 0. |
deallocates **b if refcount has dropped to 0. |