/* * 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 */ }
INT16 CGEN_PROTECTED CPMproc::Analyze(data* dSignal, data* dPM) { INT16 ret = NOT_EXEC; INT16 bLabels = FALSE; data* dLabels = NULL; ICREATEEX(CData,dLabels,"~lab",NULL); if(dlp_is_symbolic_type_code(dSignal->GetCompType(dSignal->GetNComps()-1))) { dLabels->SelectComps(dSignal,dSignal->GetNComps()-1,1); dSignal->DeleteComps(dSignal->GetNComps()-1,1); bLabels=TRUE; } if(m_bChfa == true) { ret = Chfa(dSignal, dPM); } else if(m_bGcida == true) { ret = Gcida(dSignal, dPM); } else if(m_bEpochdetect == true) { ret = Epochdetect(dSignal, dPM); } else { ret = Hybrid(dSignal, dPM); } if(bLabels==TRUE) { dSignal->Join(dLabels); } IDESTROY(dLabels); return ret; }
/* * Synthesis * * @return O_K if successfull, NOT_EXEC otherwise */ INT16 CGEN_PUBLIC CFBAproc::Synthesize(data *idFea, data *idControl, data *idSyn) { if((idFea != NULL) && (idSyn != NULL)) { if (idControl == NULL) return IERROR(this,ERR_NULLINST,0,0,0); if (idFea == NULL) return IERROR(this,ERR_NULLINST,0,0,0); if (idSyn == NULL) return IERROR(this,ERR_NULLINST,0,0,0); if (idControl->IsEmpty()) return IERROR(idControl,DATA_EMPTY,idControl->m_lpInstanceName,0,0); if (idFea->IsEmpty()) return IERROR(idFea,DATA_EMPTY,idFea->m_lpInstanceName,0,0); if (idFea->GetCompType(0)!=T_DOUBLE) return IERROR(idFea,DATA_BADCOMPTYPE,0,idFea->m_lpInstanceName,"double"); if(dlp_is_numeric_type_code(idControl->GetCompType(0)) && dlp_is_numeric_type_code(idControl->GetCompType(1))) { if(SynthesizeUsingPM(idFea, idControl, idSyn) != O_K) return NOT_EXEC; } else if(dlp_is_symbolic_type_code(idControl->GetCompType(0)) && dlp_is_numeric_type_code (idControl->GetCompType(1)) && dlp_is_symbolic_type_code(idControl->GetCompType(2)) && dlp_is_numeric_type_code (idControl->GetCompType(3)) && dlp_is_numeric_type_code (idControl->GetCompType(4)) && dlp_is_symbolic_type_code(idControl->GetCompType(5)) && dlp_is_numeric_type_code (idControl->GetCompType(6)) && dlp_is_numeric_type_code (idControl->GetCompType(7))) { if(SynthesizeUsingInto(idFea, idControl, idSyn) != O_K) return NOT_EXEC; } else { IERROR(this,FBA_BADPITCH,idControl->m_lpInstanceName,0,0); return IERROR(this,FBA_BADINTO, idControl->m_lpInstanceName,0,0); } ISETFIELD_RVALUE(idSyn,"rinc",1000/m_nSrate); for(INT32 i = 0; i < idFea->GetNComps(); i++) { if(dlp_is_symbolic_type_code(idFea->GetCompType(i))) { idSyn->AddComp(idFea->GetCname(i),idFea->GetCompType(i)); } } idSyn->CopyLabels(idFea); } return O_K; }
/** * Synthesis * * * @return O_K if successfull, NOT_EXEC otherwise */ INT16 CGEN_PROTECTED CFWTproc::Synthesize(CData* idTrans, CData* idSignal) { INT32 nNrOfCoeff; /* number of signal values */ INT16 ret = NOT_EXEC; INT16 di=GetDindex(); if(!di) return IERROR(this,ERR_INVALARG,"wvltype invalid",0,0); if (idTrans == NULL) return IERROR(this,ERR_NULLINST,0,0,0); if (idTrans->IsEmpty()) return IERROR(idTrans,DATA_EMPTY,idTrans->m_lpInstanceName,0,0); if (idTrans->GetCompType(0)!=T_DOUBLE) return IERROR(idTrans,DATA_BADCOMPTYPE,0,idTrans->m_lpInstanceName,"double"); // remove symbolic component if(dlp_is_symbolic_type_code(idTrans->GetCompType(idTrans->GetNComps()-1))) { idTrans->DeleteComps(idTrans->GetNComps()-1,1); } nNrOfCoeff = (INT32) idTrans->GetNComps(); /* get number of coefficients */ // maybe the records containing the data if(nNrOfCoeff == 1) { nNrOfCoeff = (INT32) idTrans->GetNRecs(); /* get number of coefficients */ } /* allocate output data objects */ idSignal->Reset(TRUE); idSignal->AddNcomps(T_DOUBLE, 1); idSignal->Alloc(nNrOfCoeff); idSignal->SetNRecs(nNrOfCoeff); if(!dlp_strncmp(m_lpsWvltype,"haar",4)) di=2; else if(m_lpsWvltype[0]=='d') di=atoi(m_lpsWvltype+1); else return NOT_EXEC; return dlm_fwt_dx_inv((FLOAT64*)idTrans->XAddr(0,0), (FLOAT64*)idSignal->XAddr(0,0), (INT32)nNrOfCoeff, di, (INT16)m_nLevel); return ret; }
/** * Prints one block of the instance in vector mode (standard). */ INT32 CGEN_PRIVATE CData_PrintVectors_Block ( CData* _this, /* Pointer to data instance */ INT32 nBlock /* Block index (<0: ignore blocks) */ ) /* Returns number of lines printed */ { INT32 i = 0; /* Universal loop counter */ INT32 nR = 0; /* Current record */ INT32 nR_ = 0; /* First record to be printed */ INT32 nR0 = 0; /* First record of current page */ INT32 nSR = 0; /* Number of records of currenr page */ INT32 nXR = 0; /* Last record to print plus one */ INT32 nC = 0; /* Current component */ INT32 nXC = 0; /* Number of components */ INT32 nWI = 0; /* Component index column width */ INT32 nW0 = 0; /* Head column width */ INT32 nW = 0; /* Column width */ INT32 nP = 0; /* Current page */ INT32 nPps = 0; /* Pages per screen */ INT32 nL = 0; /* Line counter */ BOOL bPur = FALSE; /* Print physical record unit flag */ BOOL bPuc = FALSE; /* Print physical component unit flg.*/ FLOAT64 nBuf = 0.; /* Double buffer */ char sBuf[L_SSTR+1]; /* String buffer */ /* Validate */ /* --------------------------------- */ if (nBlock>=CData_GetNBlocks(_this)) return 0; /* Requested block does not exist */ /* Initialize */ /* --------------------------------- */ nR_ = nBlock>=0 ? CData_GetNRecsPerBlock(_this)*nBlock : 0; /* Get first record to print */ nXR = nBlock>=0 ? nR_+CData_GetNRecsPerBlock(_this) : CData_GetNRecs(_this); /* Get number of records */ nXC = CData_GetNComps(_this); /* Get number of components */ bPur = _this->m_lpTable->m_fsr!=1. && _this->m_lpTable->m_fsr!=0.; /* Displaying physical record units? */ bPuc = _this->m_nCinc!=1. && _this->m_nCinc!=0.; /* Displaying physical comp. units? */ nPps = dlp_maxprintlines()/(nXC+4); /* Compute no. of pages per sceeen */ /* Print vectors */ /* --------------------------------- */ if (nBlock>=0) /* Printing blockwise? */ { /* >> */ printf("\n Block %ld (offset %ld)",(long)nBlock,(long)nR_); /* Show current block index */ dlp_inc_printlines(1); nL++; /* Adjust number of printed lines */ } /* << */ for (nR0=nR_; nR0<nXR; ) /* Loop over records */ { /* >> */ CData_PrintVectors_GetColWidth(_this,nR0,0,&nWI,&nW0,&nW); /* Comp. head and data col. widths */ nSR = (dlp_maxprintcols()-nWI-nW0-4)/(nW+1); /* Number of columns to print */ if (nR0+nSR>nXR) nSR = nXR-nR0; /* No more than there are records! */ /* Print record header */ /* - - - - - - - - - - - - - - - - */ if (bPur) /* Display physical record units? */ { /* >> */ printf("\n %s ->",__pad(strcpy(sBuf,_this->m_lpRunit),nW0+nWI,'r')); /* Print name of physical unit */ for (nR=nR0; nR<nR0+nSR; nR++) /* Loop over remaining records */ { /* >> */ nBuf = _this->m_lpTable->m_ofs + (nR-nR_)*_this->m_lpTable->m_fsr; /* Compute abscissa value */ __sprintx(sBuf,&nBuf,T_DOUBLE,_this->m_bExact); /* Print to a string */ printf("%s ",__pad(sBuf,nW,'r')); /* Format and print to screen */ } /* << */ dlp_inc_printlines(1); nL++; /* Adjust number of printed lines*/ } /* << */ sBuf[0]='\0'; /* Clear string buffer */ if (bPuc) sprintf(sBuf,"%s| ",_this->m_lpCunit); /* Print phys. comp. unit name... */ printf("\n %s",__pad(sBuf,nW0+nWI+3,'r')); /* ... or empty string */ for (nR=nR0; nR<nR0+nSR; nR++) /* Loop over remaining records */ { /* >> */ i=nR-nR_; __sprintx(sBuf,&i,T_INT,_this->m_bExact); /* Print record index to a str. */ printf("%s%c",__pad(sBuf,nW,'r'),CData_RecIsMarked(_this,nR)?'*':' '); /* Format and print to screen */ } /* << */ sBuf[0]='\0'; /* Clear string buffer */ if (bPuc) sprintf(sBuf,"%c ",bPuc?'v':' '); /* Print down arrow ... */ printf("\n %s",__pad(sBuf,nW0+nWI+3,'r')); /* ... or empty string */ sBuf[0]='\0'; for (i=0; i<nW; i++) sBuf[i]='.'; sBuf[i]='\0'; /* Make horizonal delimiter */ for (nR=nR0; nR<nR0+nSR; nR++) printf("%s ",sBuf); /* Print one per vector */ dlp_inc_printlines(2); nL+=2; /* Adjust number of printed lines */ /* Print data */ /* - - - - - - - - - - - - - - - - */ for (nC=0; nC<nXC; ) /* Loop over components */ { /* >> */ __sprintx(sBuf,&nC,T_INT,_this->m_bExact); /* Print comp. index to a string */ printf("\n%c%s ", /* Format and print to screen */ CData_CompIsMarked(_this,nC)?'*':' ',__pad(sBuf,nWI,'r')); /* | (incl. "*" for "marked") */ if (bPuc && dlp_is_numeric_type_code(CData_GetCompType(_this,nC))) /* Display ordinate value? */ { /* >> */ nBuf = _this->m_nCofs + nC*_this->m_nCinc; /* Compute it */ __sprintx(sBuf,&nBuf,T_DOUBLE,_this->m_bExact); /* Print it to a string */ } /* << */ else strcpy(sBuf,CData_GetCname(_this,nC)); /* else display component name */ printf("%s: ",__pad(dlp_strtrimleft(dlp_strtrimright(sBuf)),nW0,'r')); /* Format and print to screen */ for (nR=nR0; nR<nR0+nSR; nR++) /* Loop over remaining records */ { /* >> */ __sprintx(sBuf,CData_XAddr(_this,nR,nC), /* Print cell value to a str. */ CData_GetCompType(_this,nC),_this->m_bExact); /* | */ if (dlp_is_symbolic_type_code(CData_GetCompType(_this,nC))) /* Is string value */ if ((INT32)dlp_strlen(sBuf)>nW) /* Will not fit in column */ dlp_strabbrv(sBuf,sBuf,nW); /* Abbreviate it */ if (dlp_is_numeric_type_code(CData_GetCompType(_this,nC))) /* Is numeric value */ if (_this->m_bNz && CMPLX_EQUAL(CData_Cfetch(_this,nR,nC),CMPLX(0.))) dlp_strcpy(sBuf,"-"); printf("%s%c",__pad(sBuf,nW,'r'), /* Format and print to screen */ CData_CellIsMarked(_this,nR*CData_GetNComps(_this)+nC)?'*':' '); /* | (incl. "*" for "marked") */ } /* << */ dlp_inc_printlines(1); nL++; /* Adjust number of printed lines*/ /* Break component listing */ /* - - - - - - - - - - - - - - - */ if (nPps==0) /* Not all comps. fit on screen */ { /* >> */ sprintf(sBuf,"component (0..%ld), cancel -3",(long)nXC-1); /* Make user hint */ if ((nC=dlp_printstop_nix(nC,sBuf,NULL))==-1) break; /* Break listing */ if (nC< -2 ) return -1; /* Cancelled by user */ if (nC>=nXC) break; /* No more components -> break */ } /* << */ else nC++; /* No breaking -> count comps. */ } /* << */ nR0+=nSR; /* First record on next page */ nP++; /* Count pages */ if (nR0<nXR) /* There are more records */ { /* >> */ printf("\n"); dlp_fprint_x_line(stdout,'-',dlp_maxprintcols()); /* Print a separator */ dlp_inc_printlines(1); nL++; /* Adjust number of printed lines*/ } /* << */ /* Break record listing */ /* - - - - - - - - - - - - - - - - */ if (((nPps>0 && nP>=nPps) || nPps==0) && nR0<nXR) /* Complicated break condition :) */ { /* >> */ dlp_inc_printlines(dlp_maxprintlines()); /* Do stop right here */ sprintf(sBuf,"record (%ld..%ld)%s",(long)nR_,(long)nXR-1, /* Make user hint */ nBlock>=0?", cancel -3":""); /* | */ if ((nR0=dlp_printstop_nix(--nR0,sBuf,NULL))==-1) break; /* Break listing */ if (nR0< -2 ) return -1; /* Cancelled by user */ if (nR0< nR_) nR0=nR_; /* No previous blocks, please! */ if (nR0>=nXR) break; /* No more records -> break */ nP=0; /* Reset page counter */ } /* << */ } /* << */ return nL; /* Return number of printed lines */ }
/** * Computes the print widths of the head column and one data vector. */ INT16 CGEN_PRIVATE CData_PrintVectors_GetColWidth ( CData* _this, /* Pointer to data instance */ INT32 nR0, /* First record to be printed */ INT32 nC0, /* First component to be printed */ INT32* lpnWI, /* Print width of comp.idx.col.(ret) */ INT32* lpnW0, /* Print width of head column (ret) */ INT32* lpnW /* Print width of data column (ret) */ ) /* Returns O_K or (neg.) error code */ { INT32 nR = 0; /* Current record */ INT32 nXR = 0; /* Number of records */ INT32 nC = 0; /* Current component */ INT32 nXC = 0; /* Number of components */ INT32 nWn = 0; /* Widest number in cols. of screen */ INT32 nWs = 0; /* Widest string in cols. of screen */ FLOAT64 nBuf = 0.; /* Double buffer */ char sBuf[L_SSTR+1]; /* String buffer */ UINT64 nTime = 0; /* Initialize */ /* --------------------------------- */ *lpnW = 0; /* Data column width */ *lpnWI = 0; /* Component index column width */ *lpnW0 = 0; /* Head column width */ nXR = CData_GetNRecs(_this); /* Get number of records */ nXC = CData_GetNComps(_this); /* Get number of components */ /* Compute head column print width */ /* --------------------------------- */ for (*lpnW0=0,nC=nC0; nC<nXC; nC++) /* Loop over remaining components */ { /* >> */ if /* Displaying physical units? */ ( /* | */ dlp_is_numeric_type_code(CData_GetCompType(_this,nC)) && /* | Numeric component */ dlp_strlen(_this->m_lpCunit) && _this->m_nCinc!=0. /* | Physical units specified */ ) /* | */ { /* >> */ nBuf = _this->m_nCofs + nC*_this->m_nCinc; /* The physical coordinate */ __sprintx(sBuf,&nBuf,T_DOUBLE,_this->m_bExact); /* Print to a string */ } /* << */ else /* String comp. or no phys. units */ __sprintx(sBuf,CData_GetCname(_this,nC),10,_this->m_bExact); /* Print component name to str. */ *lpnW0 = MAX(*lpnW0,(INT32)dlp_strlen(sBuf)); /* Get length of phys. unit / name */ } /* << */ /* Compute component index column print width */ /* --------------------------------- */ nC--; /* Last component to be printed */ __sprintx(sBuf,&nC,T_INT,_this->m_bExact); /* Print greatest comp. index to str.*/ *lpnWI = (INT32)dlp_strlen(sBuf); /* Get length of component index col.*/ /* Compute data vector print width */ /* --------------------------------- */ nTime = dlp_time(); for (*lpnW=0,nR=nR0; nR<nXR; nR++) /* Loop over remaining records */ { /* >> */ /* Determine width of physical unit */ /* - - - - - - - - - - - - - - - - */ if (dlp_strlen(_this->m_lpRunit) && _this->m_lpTable->m_fsr!=0.) /* Displaying physical units? */ { /* >> */ nBuf = _this->m_lpTable->m_ofs + nR*_this->m_lpTable->m_fsr; /* The physical coordinate */ __sprintx(sBuf,&nBuf,T_DOUBLE,_this->m_bExact); /* Print to a string */ *lpnW = MAX((INT32)dlp_strlen(sBuf),*lpnW); /* Aggregate actual print width */ } /* << */ /* Determine width of record index */ /* - - - - - - - - - - - - - - - - */ __sprintx(sBuf,&nR,T_INT,_this->m_bExact); /* Print record index to a string */ *lpnW = MAX((INT32)dlp_strlen(sBuf),*lpnW); /* Aggregate actual print width */ /* Determine greatest component width */ /* - - - - - - - - - - - - - - - - */ for (nC=nC0; nC<nXC; nC++) /* Loop over remaining components */ { /* >> */ __sprintx(sBuf,CData_XAddr(_this,nR,nC), /* Print cell value to a string */ CData_GetCompType(_this,nC),_this->m_bExact); /* | */ if (dlp_is_numeric_type_code(CData_GetCompType(_this,nC))) /* It is a number */ nWn = MAX((INT32)dlp_strlen(sBuf),nWn); /* Aggr. number print width */ else if (dlp_is_symbolic_type_code(CData_GetCompType(_this,nC))) /* It is a string */ nWs = MAX((INT32)dlp_strlen(sBuf),nWs); /* Aggr. string print width */ if (dlp_time()-nTime>__TIMEOUT) break; /* Takes too long -> forget it! */ } /* << */ if (dlp_time()-nTime>__TIMEOUT) break; /* Takes too long -> forget it! */ if ((nR-nR0+2)*((*lpnW)+1)>dlp_maxprintcols()-*lpnWI-*lpnW0-3) break; /* Next vec. would not fit anymore*/ } /* << */ /* If computing data vector print width timed out ... */ /* --------------------------------- */ if (dlp_time()-nTime>__TIMEOUT) /* There was a time out */ for (nC=nC0; nC<nXC; nC++) /* Loop over remaining components */ if (dlp_is_numeric_type_code(CData_GetCompType(_this,nC))) /* It is a number */ nWn = MAX(dlp_printlen(CData_GetCompType(_this,nC)),nWn); /* Use standard print width */ else if (dlp_is_symbolic_type_code(CData_GetCompType(_this,nC))) /* It is a string */ nWs = MAX(dlp_printlen(CData_GetCompType(_this,nC)),nWs); /* Also use std. print width */ /* Aftermath */ /* --------------------------------- */ if (nWs>dlp_maxprintcols()-(*lpnW0)-(*lpnWI)-3) /* Limit string width to line length */ nWs=dlp_maxprintcols()-(*lpnW0)-(*lpnWI)-3; /* ... */ if (nWn<=0) *lpnW = MAX(nWs,*lpnW); /* No numbers -> complete strings */ else *lpnW = MAX(nWn,*lpnW); /* Minimal space req. for numbers */ /*if (nWn>0 && *lpnW+3<nWs) (*lpnW) += 3;*/ /* Print a little more of the strs. */ if (nWn>0 && *lpnW<nWs) *lpnW = MIN(16,nWs); /* Print max. 16 chars. of strings */ return O_K; /* Ok */ }
/* * Manual page at statistics.def */ INT16 CGEN_PUBLIC CStatistics_Update ( CStatistics* _this, CData* idVec, INT32 nIcLab, CData* idW ) { INT32 i = 0; /* Update vector loop counter */ INT32 I = 0; /* Number of update vectors */ INT32 c = 0; /* Class of current update vector */ INT32 C = 0; /* Number of classes */ INT32 n = 0; /* Dimension loop counter */ INT32 N = 0; /* Statistics' dimensionality */ FLOAT64 w = 0.; /* Weight of current update vector */ char* lpsLab = NULL; /* Symbolic label of curr. upd. vec. */ FLOAT64* lpX = NULL; /* Vector copy buffer */ INT32 nVecIgnored = 0; /* Number of ignored vectors */ /* Validate */ /* --------------------------------- */ 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); /* ... */ if (CData_IsEmpty(idVec)) return O_K; /* No input vector(s), no service! */ I = CData_GetNRecs(idVec); /* Get number of update vectors */ C = CStatistics_GetNClasses(_this); /* Get number of statitistics classes*/ N = CStatistics_GetDim(_this); /* Get statistics vector dimension */ if (C>1) /* Multiclass statistics needs labels*/ { /* >> */ if (_this->m_idLtb) /* Need symbolic labels */ { /* >> */ if ((nIcLab<0 || nIcLab>=CData_GetNComps(idVec))) /* Symbolic label comp. not spec.*/ for (nIcLab=0; nIcLab<CData_GetNComps(idVec); nIcLab++) /* Seek label component */ if (dlp_is_symbolic_type_code(CData_GetCompType(idVec,nIcLab))) /* ... */ break; /* ... */ if (!dlp_is_symbolic_type_code(CData_GetCompType(idVec,nIcLab))) /* Symbolic label comp. not found*/ return /* -> Error */ IERROR(_this,STA_BADCOMP,"Label",idVec->m_lpInstanceName,"symbolic"); /* | */ } /* << */ else /* Need numeric labels */ { /* >> */ if (!dlp_is_numeric_type_code(CData_GetCompType(idVec,nIcLab)) && /* Numeric label comp. not found */ (nIcLab>=0 || CData_GetNComps(idW)!=C)) /* | */ return /* -> Error */ IERROR(_this,STA_BADCOMP,"Label",idVec->m_lpInstanceName,"numeric"); /* | */ } /* << */ } /* << */ /*else if (nIcLab>=0) IERROR(_this,STA_IGNORE,"label component",0,0); / * Only one class -> ignore labels */ if (dlp_is_numeric_type_code(CData_GetCompType(idVec,nIcLab))) /* Check no. of comps. in idVec ... */ { /* >> */ if (CData_GetNNumericComps(idVec)!=N+1) /* Wrong number of numeric comps. */ IERROR(_this,STA_DIM,idVec->m_lpInstanceName,"numeric components",N+1); /* -> Warning */ } /* << */ else if (CData_GetNNumericComps(idVec)!=N) /* Wrong number of numeric comps. */ IERROR(_this,STA_DIM,idVec->m_lpInstanceName,"numeric components",N); /* -> Warning */ if (idW) /* Weigths passed -> check 'em */ { /* >> */ if (!dlp_is_numeric_type_code(CData_GetCompType(idW,0))) /* Component 0 not numeric */ return /* -> Error */ IERROR(_this,STA_BADCOMP,"Weight",idW->m_lpInstanceName,"numeric"); /* | */ if (CData_GetNComps(idW)!=1 && CData_GetNComps(idW)!=C) /* More than one component */ IERROR(_this,STA_IGNORE,"components in weight sequence",0,0); /* -> Warning */ if (CData_GetNRecs(idW)!=I) /* Not exactly one weight per vec. */ IERROR(_this,STA_DIM,idW->m_lpInstanceName,"records",I); /* -> Warning */ } /* << */ /* Initialize - NO RETURNS BEYOND THIS POINT! - */ /* --------------------------------- */ lpX = (FLOAT64*)dlp_calloc(N,sizeof(FLOAT64)); /* Allocate vector copy buffer */ /* Update statistics */ /* --------------------------------- */ for (i=0; i<I; i++) /* Loop over update vectors */ { /* >> */ /* Get vector label */ /* - - - - - - - - - - - - - - - - */ if (C>1) /* Multiclass stats. needs labels */ { /* >> */ if (_this->m_idLtb) /* idVec contains symbolic labs. */ { /* >> */ INT32 nLIdx = 0; DLPASSERT(dlp_is_symbolic_type_code(CData_GetCompType(idVec,nIcLab))); /* Must be checked before! */ lpsLab = (char*)CData_XAddr(idVec,i,nIcLab); /* Get string ptr. to label */ if(_this->m_bLabel){ nLIdx=strlen(lpsLab)-1; if(nLIdx && lpsLab[nLIdx]==']') nLIdx--; else nLIdx=0; if(nLIdx && lpsLab[nLIdx]>='0' && lpsLab[nLIdx]<='9') nLIdx--; else nLIdx=0; while(nLIdx && lpsLab[nLIdx]>='0' && lpsLab[nLIdx]<='9') nLIdx--; if(nLIdx && lpsLab[nLIdx]=='[') lpsLab[nLIdx]='\0'; else nLIdx=0; } c = CData_Find(_this->m_idLtb,0,C,1,0,lpsLab); /* Look up label -> class idx. */ if(nLIdx) lpsLab[nLIdx]='['; if (c<0) /* Label invalid */ { /* >> */ IERROR(_this,STA_SLAB,i,lpsLab?lpsLab:"(null)",0); /* Warning */ continue; /* Ignore record */ } /* << */ } /* << */ else if(nIcLab>=0) /* idVec contains numeric labs. */ { /* >> */ c = (INT32)CData_Dfetch(idVec,i,nIcLab); /* Fetch label */ if (c<0 || c>=C) /* Label invalid */ { /* >> */ IERROR(_this,STA_NLAB,i,c,0); /* Warning */ continue; /* Ignore record */ } /* << */ } /* << */ else c = 0; /* Default class is 0 */ } /* << */ else c = 0; /* Default class is 0 */ do /* Loop over classes */ { /* >> */ /* Get (weighted) update vector and update statistics */ /* - - - - - - - - - - - - - - - - */ if (idW) /* Using weights */ { /* >> */ w = CData_Dfetch(idW,i,_this->m_idLtb || nIcLab>=0 ? 0 : c); /* Fetch weight for this vector */ if(w==0.) continue; /* Nothing to do if no weight */ _this->m_bWeighted=TRUE; } else w=1.; /* << */ CData_DrecFetch(idVec,lpX,i,N,nIcLab); /* Fetch update vector */ fpclassify(0.); for (n=0; n<N; n++) /* Loop over vector components */ if (fabs(lpX[n])>1E100) /* Check value */ break; /* There's something wrong ... */ if (n<N) { nVecIgnored++; continue; } /* Ignore this vector */ CStatistics_UpdateVector(_this,lpX,c,w); /* Update statistics with vector */ } /* << */ while(!_this->m_idLtb && nIcLab<0 && ++c<C); /* Next class if there is one */ } /* << */ /* Clean up */ /* --------------------------------- */ if (nVecIgnored>0) IERROR(_this,STA_VECIGNORED,nVecIgnored,0,0); /* Error: some vectors ignored */ dlp_free(lpX); /* Free vector copy buffer */ return O_K; /* Done */ }