PNLW_USING bool NetCallback::GetNodeInfo(Vector<pnl::CNodeType> *paNodeType, Vector<int> *paNodeAssociation, const ProbabilisticNet &net) { int iW, iPNL, i; Vector<String> aNodeName(net.Graph().Names()); paNodeAssociation->resize(aNodeName.size()); paNodeType->reserve(aNodeName.size() > 16 ? 8:4); for(i = 0; i < aNodeName.size(); i++) { iW = net.Graph().INode(aNodeName[i]); iPNL = net.Graph().IGraph(iW); const pnl::CNodeType &nt = net.pnlNodeType(iW); (*paNodeAssociation)[iPNL] = NodeAssociation(paNodeType, nt.IsDiscrete(), nt.GetNodeSize(), nt.GetNodeState()); } return true; }
void CLDAPNode::UnLockSession( sLDAPContextData *inContext, bool inHasFailed, bool inNewMutex ) { sLDAPNodeStruct *pLDAPNodeStruct = nil; LDAPNodeMapI aLDAPNodeMapI; if (inContext != nil) { if ( (inContext->authCallActive) && !inNewMutex ) { if (inContext->fLDAPSessionMutex != nil) { inContext->fLDAPSessionMutex->Signal(); } } else { string aNodeName(inContext->fName); fLDAPNodeOpenMutex.Wait(); aLDAPNodeMapI = fLDAPNodeMap.find(aNodeName); if (aLDAPNodeMapI != fLDAPNodeMap.end()) { pLDAPNodeStruct = aLDAPNodeMapI->second; } if (pLDAPNodeStruct != nil) { if (inHasFailed) { pLDAPNodeStruct->bHasFailed = true; } if (pLDAPNodeStruct->fLDAPSessionMutex != nil) { pLDAPNodeStruct->fLDAPSessionMutex->Signal(); } pLDAPNodeStruct->fRefCount--; if (pLDAPNodeStruct->fRefCount == 0) { //remove the entry if refcount is zero after cleaning contents CleanLDAPNodeStruct(pLDAPNodeStruct); fLDAPNodeMap.erase(aNodeName); } } fLDAPNodeOpenMutex.Signal(); } } } //UnLockSession
sInt32 CLDAPNode::SafeClose ( char *inNodeName, LDAP *inHost ) { sInt32 siResult = eDSNoErr; sLDAPNodeStruct *pLDAPNodeStruct = nil; LDAPNodeMapI aLDAPNodeMapI; string aNodeName(inNodeName); //decrement ref count and delete if ref count zero //if Auth call was active then the inHost will NOT be nil and we need to unbind it //called from CloseDirNode fLDAPNodeOpenMutex.Wait(); if (inHost != nil) { //this check is for auth call active closes ldap_unbind( inHost ); } else { aLDAPNodeMapI = fLDAPNodeMap.find(aNodeName); if (aLDAPNodeMapI != fLDAPNodeMap.end()) { pLDAPNodeStruct = aLDAPNodeMapI->second; pLDAPNodeStruct->fRefCount--; if (pLDAPNodeStruct->fRefCount == 0) { //remove the entry if refcount is zero after cleaning contents CleanLDAPNodeStruct(pLDAPNodeStruct); fLDAPNodeMap.erase(aNodeName); free(pLDAPNodeStruct); } } } fLDAPNodeOpenMutex.Signal(); return(siResult); }// SafeClose
void CLDAPNode::ActiveConnection( char *inNodeName ) { sLDAPNodeStruct *pLDAPNodeStruct = nil; LDAPNodeMapI aLDAPNodeMapI; if (inNodeName != nil) { fLDAPNodeOpenMutex.Wait(); string aNodeName(inNodeName); aLDAPNodeMapI = fLDAPNodeMap.find(aNodeName); if (aLDAPNodeMapI != fLDAPNodeMap.end()) { pLDAPNodeStruct = aLDAPNodeMapI->second; pLDAPNodeStruct->fConnectionActiveCount++; pLDAPNodeStruct->fIdleTOCount = 0; } fLDAPNodeOpenMutex.Signal(); } } //ActiveConnection
LDAP* CLDAPNode::LockSession( sLDAPContextData *inContext ) { sLDAPNodeStruct *pLDAPNodeStruct = nil; LDAPNodeMapI aLDAPNodeMapI; if (inContext != nil) { if (inContext->authCallActive) { if (inContext->fLDAPSessionMutex != nil) { inContext->fLDAPSessionMutex->Wait(); } return inContext->fHost; } else { string aNodeName(inContext->fName); fLDAPNodeOpenMutex.Wait(); aLDAPNodeMapI = fLDAPNodeMap.find(aNodeName); if (aLDAPNodeMapI != fLDAPNodeMap.end()) { pLDAPNodeStruct = aLDAPNodeMapI->second; pLDAPNodeStruct->fRefCount++; } fLDAPNodeOpenMutex.Signal(); if (pLDAPNodeStruct != nil) { if (pLDAPNodeStruct->fLDAPSessionMutex != nil) { pLDAPNodeStruct->fLDAPSessionMutex->Wait(); } return pLDAPNodeStruct->fHost; } } } return nil; } // LockSession
sInt32 CLDAPNode::SafeOpen ( char *inNodeName, LDAP **outLDAPHost, uInt32 *outLDAPConfigTableIndex ) { sInt32 siResult = eDSNoErr; sLDAPNodeStruct *pLDAPNodeStruct = nil; uInt32 iTableIndex = 0; sLDAPConfigData *pConfig = nil; int ldapPort = LDAP_PORT; char *aLDAPName = nil; bool bConfigFound = false; LDAPNodeMapI aLDAPNodeMapI; string aNodeName(inNodeName); //if already open then just get host and config index //if not open then bind to get host and search for config index //called from OpenDirNode //allow the inNodeName to have a suffixed ":portNumber" for directed open //inNodeName is NOT consumed here fLDAPNodeOpenMutex.Wait(); aLDAPNodeMapI = fLDAPNodeMap.find(aNodeName); if (aLDAPNodeMapI == fLDAPNodeMap.end()) { pLDAPNodeStruct = (sLDAPNodeStruct *) calloc(1, sizeof(sLDAPNodeStruct)); pLDAPNodeStruct->fRefCount = 1; pLDAPNodeStruct->fLDAPSessionMutex = new DSMutexSemaphore(); // don't care if this was originally in the config file or not // ie. allow non-configured connections if possible // however, they need to use the standard LDAP PORT if no config entry exists // search now for possible LDAP port entry //Cycle through the gConfigTable to get the LDAP port to use for the ldap_open //start at index of one since 0 is generic config for (iTableIndex=1; iTableIndex<gConfigTableLen; iTableIndex++) { pConfig = (sLDAPConfigData *)gConfigTable->GetItemData( iTableIndex ); if (pConfig != nil) { if (pConfig->fServerName != nil) { if (::strcmp(pConfig->fServerName,inNodeName) == 0) { ldapPort = pConfig->fServerPort; bConfigFound = true; pLDAPNodeStruct->fLDAPConfigTableIndex = iTableIndex; //add the idle connection TO value here based on user defined minutes and 30 sec periodic task pLDAPNodeStruct->fIdleTO = 2 * pConfig->fIdleTimeout; //add in the delay rebind try after failed bind time pLDAPNodeStruct->fDelayRebindTry = pConfig->fDelayRebindTry; //exit the for loop if entry found break; } // if name found } // if name not nil }// if config entry not nil } // loop over config table entries if (!bConfigFound) { //here we have not found a configuration but will allow the open //first check if there is a suffixed ':' port number on the inNodeName siResult = ParseLDAPNodeName( inNodeName, &aLDAPName, &ldapPort ); if (siResult == eDSNoErr) { pLDAPNodeStruct->fServerName = aLDAPName; pLDAPNodeStruct->fDirectLDAPPort = ldapPort; pLDAPNodeStruct->fLDAPConfigTableIndex = 0; //TODO need to access the LDAP server for possible mapping configuration that can be added //thus fLDAPConfigTableIndex would then be non-zero } } //add this to the fLDAPNodeMap fLDAPNodeMap[aNodeName] = pLDAPNodeStruct; //fLDAPNodeMap.insert(pair<string, sLDAPNodeStruct*>(aNodeName, pLDAPNodeStruct)); fLDAPNodeOpenMutex.Signal(); } else { pLDAPNodeStruct = aLDAPNodeMapI->second; fLDAPNodeOpenMutex.Signal(); pConfig = (sLDAPConfigData *)gConfigTable->GetItemData( pLDAPNodeStruct->fLDAPConfigTableIndex ); ldapPort = pConfig->fServerPort; pLDAPNodeStruct->fRefCount++; } if (siResult == eDSNoErr) { if (pLDAPNodeStruct->fLDAPSessionMutex != nil) { pLDAPNodeStruct->fLDAPSessionMutex->Wait(); } //call to bind here siResult = BindProc( pLDAPNodeStruct ); if (pLDAPNodeStruct->fLDAPSessionMutex != nil) { pLDAPNodeStruct->fLDAPSessionMutex->Signal(); } //set the out parameters now *outLDAPHost = pLDAPNodeStruct->fHost; *outLDAPConfigTableIndex = pLDAPNodeStruct->fLDAPConfigTableIndex; } return(siResult); } // SafeOpen
sInt32 CLDAPNode::SimpleAuth( char *inNodeName, char *inUserName, void *inAuthCredential ) { sInt32 siResult = eDSNoErr; sLDAPNodeStruct *pLDAPAuthNodeStruct = nil; sLDAPNodeStruct *pLDAPNodeStruct = nil; LDAPNodeMapI aLDAPNodeMapI; string aNodeName(inNodeName); //use bind to do the auth //called from DoClearTextAuth fLDAPNodeOpenMutex.Wait(); aLDAPNodeMapI = fLDAPNodeMap.find(aNodeName); if (aLDAPNodeMapI != fLDAPNodeMap.end()) { pLDAPNodeStruct = aLDAPNodeMapI->second; //build the temporary auth node struct for use with BindProc pLDAPAuthNodeStruct = (sLDAPNodeStruct *) calloc(1, sizeof(sLDAPNodeStruct)); if (pLDAPNodeStruct->fLDAPConfigTableIndex != 0) { pLDAPAuthNodeStruct->fLDAPConfigTableIndex = pLDAPNodeStruct->fLDAPConfigTableIndex; } else { pLDAPAuthNodeStruct->fServerName = pLDAPNodeStruct->fServerName; pLDAPAuthNodeStruct->fDirectLDAPPort = pLDAPNodeStruct->fDirectLDAPPort; } pLDAPAuthNodeStruct->fHost = nil; //new session handle for this directed auth //don't want this bind to disrupt //any other ops on the LDAP server pLDAPAuthNodeStruct->fLDAPSessionMutex = nil; pLDAPAuthNodeStruct->fUserName = inUserName; pLDAPAuthNodeStruct->fAuthCredential = inAuthCredential; //fAuthType nil is default for using a password //now try to bind siResult = BindProc( pLDAPAuthNodeStruct ); if (siResult != eDSNoErr) { siResult = eDSAuthFailed; } //no cleanup of contents other than session handle if (pLDAPAuthNodeStruct->fHost != nil) { ldap_unbind(pLDAPAuthNodeStruct->fHost); } free(pLDAPAuthNodeStruct); fLDAPNodeOpenMutex.Signal(); } else //no entry in fLDAPNodeMap { fLDAPNodeOpenMutex.Signal(); siResult = eDSAuthFailed; } return(siResult); }// SimpleAuth
sInt32 CLDAPNode::RebindSession( char *inNodeName, LDAP *inHost, LDAP **outLDAPHost ) { sInt32 siResult = eDSNoErr; sLDAPNodeStruct *pLDAPNodeStruct = nil; LDAPNodeMapI aLDAPNodeMapI; string aNodeName(inNodeName); //must already be open //called from ?? fLDAPNodeOpenMutex.Wait(); aLDAPNodeMapI = fLDAPNodeMap.find(aNodeName); if (aLDAPNodeMapI != fLDAPNodeMap.end()) { pLDAPNodeStruct = aLDAPNodeMapI->second; if (pLDAPNodeStruct->bHasFailed) { if (pLDAPNodeStruct->fHost != nil) { ldap_unbind(pLDAPNodeStruct->fHost); pLDAPNodeStruct->fHost = nil; } fLDAPNodeOpenMutex.Signal(); if (pLDAPNodeStruct->fLDAPSessionMutex != nil) { pLDAPNodeStruct->fLDAPSessionMutex->Wait(); } //call to bind here //TODO How many retries do we do? siResult = BindProc( pLDAPNodeStruct ); if (pLDAPNodeStruct->fLDAPSessionMutex != nil) { pLDAPNodeStruct->fLDAPSessionMutex->Signal(); } if (siResult == eDSNoErr) { pLDAPNodeStruct->bHasFailed = false; //set the out parameters now *outLDAPHost = pLDAPNodeStruct->fHost; } } else { fLDAPNodeOpenMutex.Signal(); //set the out parameter with the existing handle since //the handle has already been reset *outLDAPHost = pLDAPNodeStruct->fHost; } } else //no entry in fLDAPNodeMap { fLDAPNodeOpenMutex.Signal(); siResult = eDSOpenNodeFailed; } return(siResult); }// RebindSession
sInt32 CLDAPNode::AuthOpen ( char *inNodeName, LDAP *inHost, char *inUserName, void *inAuthCredential, char *inAuthType, LDAP **outLDAPHost, uInt32 *inOutLDAPConfigTableIndex, bool shouldCloseOld ) { sInt32 siResult = eDSNoErr; sLDAPNodeStruct *pLDAPNodeStruct = nil; sLDAPNodeStruct *pLDAPAuthNodeStruct = nil; int ldapPort = LDAP_PORT; char *aLDAPName = nil; LDAPNodeMapI aLDAPNodeMapI; string aNodeName(inNodeName); //there must be a fLDAPNodeMap entry for this ie. SafeOpen was already called since //this would come from a know Node Ref then need to SafeClose the non Auth Open //this is not ref counted NOR reused //inOutLDAPConfigTableIndex could be passed in for a directed open ie. not zero //called from the hierarchy below DoAuthentication //inNodeName is NOT consumed here fLDAPNodeOpenMutex.Wait(); aLDAPNodeMapI = fLDAPNodeMap.find(aNodeName); if (aLDAPNodeMapI != fLDAPNodeMap.end()) { pLDAPNodeStruct = aLDAPNodeMapI->second; pLDAPAuthNodeStruct = (sLDAPNodeStruct *) calloc(1, sizeof(sLDAPNodeStruct)); if (pLDAPNodeStruct->fLDAPConfigTableIndex != 0) { pLDAPAuthNodeStruct->fLDAPConfigTableIndex = pLDAPNodeStruct->fLDAPConfigTableIndex; } else { pLDAPAuthNodeStruct->fServerName = pLDAPNodeStruct->fServerName; pLDAPAuthNodeStruct->fDirectLDAPPort = pLDAPNodeStruct->fDirectLDAPPort; } pLDAPAuthNodeStruct->fUserName = inUserName; pLDAPAuthNodeStruct->fAuthCredential = inAuthCredential; pLDAPAuthNodeStruct->fAuthType = inAuthType; fLDAPNodeOpenMutex.Signal(); //call to bind here siResult = BindProc( pLDAPAuthNodeStruct ); if (siResult == eDSNoErr) { //set the out parameters now *outLDAPHost = pLDAPAuthNodeStruct->fHost; *inOutLDAPConfigTableIndex = pLDAPNodeStruct->fLDAPConfigTableIndex; //using duplicate of SafeClose(inNodeName) code here directly since within mutex if ( shouldCloseOld ) { fLDAPNodeOpenMutex.Wait(); if (inHost == pLDAPNodeStruct->fHost) { pLDAPNodeStruct->fRefCount--; if (pLDAPNodeStruct->fRefCount == 0) { //remove the entry if refcount is zero after cleaning contents CleanLDAPNodeStruct(pLDAPNodeStruct); fLDAPNodeMap.erase(aNodeName); } } fLDAPNodeOpenMutex.Signal(); } } if (pLDAPAuthNodeStruct != nil) { free(pLDAPAuthNodeStruct); pLDAPAuthNodeStruct = nil; } } else if (inHost != nil) //case where a second Auth is made on the Dir Node but //original LDAPNodeMap entry was already SafeClosed { fLDAPNodeOpenMutex.Signal(); pLDAPAuthNodeStruct = (sLDAPNodeStruct *) calloc(1, sizeof(sLDAPNodeStruct)); //here we have no configuration but will allow the open //first check if there is a suffixed ':' port number on the inNodeName siResult = ParseLDAPNodeName( inNodeName, &aLDAPName, &ldapPort ); if (siResult == eDSNoErr) { pLDAPAuthNodeStruct->fServerName = aLDAPName; pLDAPAuthNodeStruct->fDirectLDAPPort = ldapPort; pLDAPAuthNodeStruct->fLDAPConfigTableIndex = *inOutLDAPConfigTableIndex; //if ( *inOutLDAPConfigTableIndex == 0 ) //{ //NO try again to access the LDAP server for possible mapping configuration that can be added //SINCE we assume that this cannot be retrieved since attempt will have already been made in //the original SafeOpen for this directed open //} //call to bind here siResult = BindProc( pLDAPAuthNodeStruct ); if (siResult == eDSNoErr) { //set the out parameter now *outLDAPHost = pLDAPAuthNodeStruct->fHost; if ( shouldCloseOld ) { ldap_unbind( inHost ); inHost = nil; } } else { siResult = eDSAuthFailed; } } if (pLDAPAuthNodeStruct != nil) { if (pLDAPAuthNodeStruct->fServerName != nil) { free(pLDAPAuthNodeStruct->fServerName); //only var owned by this temporary struct here } free(pLDAPAuthNodeStruct); pLDAPAuthNodeStruct = nil; } } else { fLDAPNodeOpenMutex.Signal(); siResult = eDSOpenNodeFailed; } return(siResult); }// AuthOpen
bool NetCallback::CommonAttachFactors(pnl::CGraphicalModel &pnlModel, const ProbabilisticNet &net) { static const char fname[] = "CommonAttachFactors"; int i, iPNL, iWNode; Vector<String> aNodeName(net.Graph().Names()); // attach parameters for every nodes for(i = 0; i < aNodeName.size(); i++) { // it is index for wrapper node, pnl node index is 'iPNL' iWNode = net.Graph().INode(aNodeName[i]); iPNL = net.Graph().IGraph(iWNode); WDistribFun *pWDF = net.Distributions().Distribution(iWNode); PNL_CHECK_IS_NULL_POINTER(pWDF); pnlModel.AllocFactor(iPNL); pnl::CFactor *pPNLF = pnlModel.GetFactor(iPNL); PNL_CHECK_IS_NULL_POINTER(pPNLF); pnl::CDistribFun *pPNLdf = pPNLF->GetDistribFun(); PNL_CHECK_IS_NULL_POINTER(pPNLdf); if (net.pnlNodeType(iWNode).IsDiscrete()) { bool isSoftMax = false; DistribFunDesc *des = pWDF->desc(); for (int j=0; j<des->nNode(); j++ ) { TokIdNode *tokId = des->node(j); if (!static_cast<pnl::CNodeType*>(tokId->v_prev->data)->IsDiscrete() ) { isSoftMax = true; break; } } bool isCondSoftMax = false; if (isSoftMax) { for (int j=0; j<des->nNode()-1; j++ ) { TokIdNode * tokId = des->node(j); if (static_cast<pnl::CNodeType*>(tokId->v_prev->data)->IsDiscrete() ) { isCondSoftMax = true; break; } } } if (isCondSoftMax) { pPNLdf->CreateDefaultMatrices(); pnl::CCondSoftMaxDistribFun *pCondSoftMaxDFHigh = dynamic_cast<WCondSoftMaxDistribFun*>(pWDF)->GetDistribution(); PNL_CHECK_IS_NULL_POINTER(pCondSoftMaxDFHigh); pnl::CCondSoftMaxDistribFun *pCondSoftMaxDFPNL = dynamic_cast<pnl::CCondSoftMaxDistribFun*>(pPNLdf); PNL_CHECK_IS_NULL_POINTER(pCondSoftMaxDFPNL); pnl::CMatrixIterator<pnl::CSoftMaxDistribFun*>* iterHigh = pCondSoftMaxDFHigh->GetMatrixWithDistribution()->InitIterator(); pnl::CMatrixIterator<pnl::CSoftMaxDistribFun*>* iterPNL = pCondSoftMaxDFPNL->GetMatrixWithDistribution()->InitIterator(); for (iterHigh, iterPNL; (pCondSoftMaxDFHigh->GetMatrixWithDistribution()->IsValueHere(iterHigh))&& (pCondSoftMaxDFPNL->GetMatrixWithDistribution()->IsValueHere(iterPNL)); pCondSoftMaxDFHigh->GetMatrixWithDistribution()->Next(iterHigh), pCondSoftMaxDFPNL->GetMatrixWithDistribution()->Next(iterPNL) ) { pnl::CSoftMaxDistribFun* DataHigh = *(pCondSoftMaxDFHigh->GetMatrixWithDistribution()->Value(iterHigh)); PNL_CHECK_IS_NULL_POINTER(DataHigh); pnl::CMatrix<float> *matr = DataHigh->GetMatrix(pnl::matWeights); pnl::floatVector *ofVect = DataHigh->GetOffsetVector(); pnl::CSoftMaxDistribFun* DataPNL = *(pCondSoftMaxDFPNL->GetMatrixWithDistribution()->Value(iterPNL)); PNL_CHECK_IS_NULL_POINTER(DataPNL); DataPNL->AttachOffsetVector(ofVect); DataPNL->AttachMatrix(matr, pnl::matWeights); } } else if (isSoftMax) { pnl::CDenseMatrix<float> *weight = pWDF->Matrix(pnl::matWeights, 0); PNL_CHECK_IS_NULL_POINTER(weight); pPNLF->AttachMatrix(weight, pnl::matWeights); // offsetVector pnl::floatVector *offVector = dynamic_cast<WSoftMaxDistribFun*>(pWDF)-> OffsetVector(); pnl::CDistribFun *df = pPNLF->GetDistribFun(); dynamic_cast<pnl::CSoftMaxDistribFun*>(df)->AttachOffsetVector(offVector); } else { pnl::CDenseMatrix<float> *mat = pWDF->Matrix(pnl::matTable); PNL_CHECK_IS_NULL_POINTER(mat); pPNLF->AttachMatrix(mat, pnl::matTable); pPNLF->AttachMatrix(mat->Copy(mat), pnl::matDirichlet); } } else { WGaussianDistribFun* pGWDF = dynamic_cast<WGaussianDistribFun* >(pWDF); WCondGaussianDistribFun* pCGWDF = dynamic_cast<WCondGaussianDistribFun* >(pWDF); //Gaussian or cond. gaussian case if (pGWDF || pCGWDF) { Vector<int> indexes; pnl::CMatrix<pnl::CGaussianDistribFun* > * pCondMatrix = 0; if (pCGWDF) { //Gaussian matrixes for all combinations of discrete parents pCondMatrix = pCGWDF->GetPNLDistribFun()->GetMatrixWithDistribution(); } else { const int range = 1; pnl::CGaussianDistribFun* pGDF = dynamic_cast<pnl::CGaussianDistribFun*>(pPNLF->GetDistribFun()); //For gaussian case there is only 1 distrib function pCondMatrix = pnl::CDenseMatrix<pnl::CGaussianDistribFun* >::Create(1, &range, &pGDF); }; pnl::CMatrixIterator<pnl::CGaussianDistribFun* > * iterThis = pCondMatrix->InitIterator(); //Excess all distrib functions to attach them to pPNLF for( iterThis; pCondMatrix->IsValueHere( iterThis ); pCondMatrix->Next(iterThis)) { //Discrete parent combination for cond. gaussian case pCondMatrix->Index( iterThis, &indexes ); bool isDistributionSpecific = (pGWDF)? (pGWDF->IsDistributionSpecific() == 1):(pCGWDF->IsDistributionSpecific() == 1); if (isDistributionSpecific) { if (pGWDF) { const pnl::pConstNodeTypeVector* ntVec = pPNLF->GetDistribFun() ->GetNodeTypesVector(); int NumberOfNodes = pPNLF->GetDistribFun()->GetNumberOfNodes(); pnl::CGaussianDistribFun *gaudf = pnl::CGaussianDistribFun ::CreateUnitFunctionDistribution(NumberOfNodes, &ntVec->front()); pPNLF->SetDistribFun(gaudf); delete gaudf; } else { ThrowUsingError("At the moment of writing this function WCondGaussianDistribFun class could not be specific. Please contact developers.", fname); }; } else { const int *pDiscrParentValues = 0; if (pCGWDF) { pDiscrParentValues = &(indexes.front()); }; pnl::CDenseMatrix<float> *mean = pWDF->Matrix(pnl::matMean, -1, pDiscrParentValues); PNL_CHECK_IS_NULL_POINTER(mean); pnl::CDenseMatrix<float> *cov = pWDF->Matrix(pnl::matCovariance, -1, pDiscrParentValues); PNL_CHECK_IS_NULL_POINTER(cov); pPNLF->AttachMatrix(mean, pnl::matMean, -1, pDiscrParentValues); pPNLF->AttachMatrix(mean->Copy(mean), pnl::matWishartMean, -1, pDiscrParentValues); pPNLF->AttachMatrix(cov, pnl::matCovariance, -1, pDiscrParentValues); pPNLF->AttachMatrix(cov->Copy(cov), pnl::matWishartCov, -1, pDiscrParentValues); int NDims; const int *Ranges; cov->GetRanges(&NDims, &Ranges); pnl::CGaussianDistribFun* a = dynamic_cast<pnl::CGaussianDistribFun*>(pPNLF->GetDistribFun()); if (pGWDF) { dynamic_cast<pnl::CGaussianDistribFun*>(pPNLF->GetDistribFun()) ->SetFreedomDegrees(1 , Ranges[0] + 2); } else { const_cast<pnl::CGaussianDistribFun *>(dynamic_cast<pnl::CCondGaussianDistribFun*>(pPNLF->GetDistribFun())->GetDistribution(pDiscrParentValues))-> SetFreedomDegrees(1 , Ranges[0] + 2); }; int ContParent = 0; int NumOfNds = pPNLF->GetDistribFun()->GetNumberOfNodes(); const pnl::pConstNodeTypeVector *pNodeTypes = pPNLF->GetDistribFun()->GetNodeTypesVector(); for (int parent = 0; parent < (NumOfNds-1); parent++) { if (!((*pNodeTypes)[parent]->IsDiscrete())) { pnl::CDenseMatrix<float> *weight = pWDF->Matrix(pnl::matWeights, ContParent, pDiscrParentValues); PNL_CHECK_IS_NULL_POINTER(weight); pPNLF->AttachMatrix(weight, pnl::matWeights, ContParent, pDiscrParentValues); ContParent++; }; } }; }; } else { PNL_CHECK_IS_NULL_POINTER(pGWDF); }; } } return true; }