/** * Fills a data table with the sample size (frequency) or the estimated a-priori * probability of the classes. * * @param _this * Pointer to this CStatistics instance * @param idDst * Pointer to the destination data instance * @param bProb * If <code>TRUE</code> the method estimates class a-priori * probabilities otherwise it stores the classes' sample sizes * @return <code>O_K</code> if successsfull, a (negative) error code otherwise */ INT16 CGEN_PUBLIC CStatistics_FreqEx ( CStatistics* _this, CData* idDst, BOOL bProb ) { INT32 c = 0; /* Class loop counter */ INT32 C = 0; /* Number of statistics classes */ INT32 nTsz = 0; /* Total sample size */ FLOAT64* lpSsz = NULL; /* Pointer to class' c sample size */ /* Validate */ /* --------------------------------- */ if (!idDst) return IERROR(_this,ERR_NULLARG,"idDst",0,0); /* Check output data instance */ CData_Reset(idDst,TRUE); /* Clear destination instance */ CHECK_THIS_RV(NOT_EXEC); /* Check this pointer */ IF_NOK(CStatistics_Check(_this)) /* Check instance data */ return IERROR(_this,STA_NOTSETUP," ( use -status for details)",0,0); /* ... */ /* Initialize */ /* --------------------------------- */ C = CStatistics_GetNClasses(_this); /* Get number of statistics classes */ CData_Array(idDst,T_DOUBLE,1,C); /* Allocate output data instance */ CData_SetNBlocks(idDst,C); /* Set block number */ if (!CData_XAddr(idDst,0,0)) return IERROR(_this,ERR_NOMEM,0,0,0); /* Should have been successfull ... */ /* Store sample sizes / estimated a-rpior probabilities */ /* --------------------------------- */ nTsz = bProb ? CStatistics_GetNSamples(_this) : 1; /* Get frequency divident */ for (c=0; c<C; c++) /* Loop over classes */ { /* >> */ DLPASSERT((lpSsz = CStatistics_GetPtr(_this,c,STA_DAI_SSIZE))); /* Get ptr. to class' c sample size*/ CData_Dstore(idDst,lpSsz[0]/(FLOAT64)nTsz,c,0); /* Store sample size of class c */ } /* << */ return O_K; }
/** * Get scaling function coefficients * * @return O_K if successfull, NOT_EXEC otherwise */ INT16 CGEN_PUBLIC CFWTproc::GetCoef(CData *idCoef) { INT16 di=GetDindex(); const FLOAT64 *h; if(!di) return IERROR(this,ERR_INVALARG,"wvltype invalid",0,0); if(!(h=dlm_fwt_geth(di))) return NOT_EXEC; CData_Array(idCoef,T_DOUBLE,1,di); memcpy(CData_XAddr(idCoef,0,0),h,sizeof(FLOAT64)*di); return O_K; }
/* * Manual page at statistics.def */ INT16 CGEN_PUBLIC CStatistics_Setup ( CStatistics* _this, INT32 nOrder, INT32 nDim, INT32 nCls, CData* idLtb, INT32 nIcLtb ) { INT32 c = 0; /* Statistics class loop counter */ INT32 n = 0; /* Dimension loop couner */ FLOAT64* lpMin = NULL; /* Ptr. to class' k minimum vector */ FLOAT64* lpMax = NULL; /* Ptr. to class' k maximum vector */ /* Validate */ /* --------------------------------- */ CHECK_THIS_RV(NOT_EXEC); /* Check this pointer */ if (nOrder<2) nOrder = 2; /* Default order is 2 */ if (nDim <1) nDim = 1; /* Default dimensionality is 1 */ if (nCls <1) nCls = 1; /* Default number of classes is 1 */ /* Initialize statistics */ /* --------------------------------- */ CStatistics_Reset(_this,TRUE); /* Start over */ IFIELD_RESET(CData,"dat"); /* Create/reset statistic data */ CData_Array(_this->m_idDat,T_DOUBLE,nDim,nCls*(nOrder+nDim+2)); /* Allocate statistic data */ CData_SetNBlocks(_this->m_idDat,nCls); /* Set number of blocks */ if (CData_IsEmpty(_this->m_idDat)) return IERROR(_this,ERR_NOMEM,0,0,0); /* Check if it worked out... */ for (c=0; c<nCls; c++) /* Loop over classes */ { /* >> */ lpMin = CStatistics_GetPtr(_this,c,STA_DAI_MIN); /* Get ptr. to class' k min. vec. */ lpMax = CStatistics_GetPtr(_this,c,STA_DAI_MAX); /* Get ptr. to class' k max. vec. */ for (n=0; n<nDim; n++) /* Loop over dimensions */ { /* >> */ lpMin[n] = T_DOUBLE_MAX; /* Initialize minimum vector */ lpMax[n] = T_DOUBLE_MIN; /* Initialize maximum vector */ } /* << */ } /* << */ /* Initialize label table */ /* --------------------------------- */ if (CData_IsEmpty(idLtb)) return O_K; /* No label table -> that's it */ if (CData_GetNRecs(idLtb)!=nCls) /* Bad number of labels */ return IERROR(_this,STA_NOTSETUP," (wrong no. of labels in idLtb)",0,0); /* -> Error */ if (nIcLtb<0) /* Label component not specified */ for (nIcLtb=0; nIcLtb<CData_GetNComps(idLtb); nIcLtb++) /* Seek first symbolic component */ if (dlp_is_symbolic_type_code(CData_GetCompType(idLtb,nIcLtb))) /* ... */ break; /* ... */ if (!dlp_is_symbolic_type_code(CData_GetCompType(idLtb,nIcLtb))) /* Label component not symbolic */ return IERROR(_this,STA_NOTSETUP," (label comp. not found in idLtb)",0,0); /* -> Error */ IFIELD_RESET(CData,"ltb"); /* Create/reset label table */ CData_SelectComps(_this->m_idLtb,idLtb,nIcLtb,1); /* Copy label table */ return O_K; /* Done */ }