bool getdata(struct iface *ifa, int cols) { static unsigned long long rx, tx; if (rx && tx) { if (!getcounters(ifa->ifname, &ifa->rx, &ifa->tx)) return false; memmove(ifa->rxs, ifa->rxs+1, sizeof(ifa->rxs) * (cols - 1)); memmove(ifa->txs, ifa->txs+1, sizeof(ifa->txs) * (cols - 1)); ifa->rxs[cols - 1] = (ifa->rx - rx) / delay; ifa->txs[cols - 1] = (ifa->tx - tx) / delay; if (globalmax) { ifa->rxmax = arraymax(ifa->rxs, cols, ifa->rxmax); ifa->txmax = arraymax(ifa->txs, cols, ifa->txmax); } else { ifa->rxmax = arraymax(ifa->rxs, cols, 0); ifa->txmax = arraymax(ifa->txs, cols, 0); } ifa->rxavg = arrayavg(ifa->rxs, cols); ifa->txavg = arrayavg(ifa->txs, cols); ifa->rxmin = arraymin(ifa->rxs, cols); ifa->txmin = arraymin(ifa->txs, cols); } if (!getcounters(ifa->ifname, &rx, &tx)) return false; return true; }
void getdata(struct iface *ifa, double delay, int cols) { static long long rx, tx; if (rx && tx && !resize) { getcounters(ifa->ifname, &ifa->rx, &ifa->tx); memmove(ifa->rxs, ifa->rxs+1, sizeof(long) * (cols-1)); memmove(ifa->txs, ifa->txs+1, sizeof(long) * (cols-1)); ifa->rxs[cols-1] = (ifa->rx - rx) / delay; ifa->txs[cols-1] = (ifa->tx - tx) / delay; ifa->rxavg = arrayavg(ifa->rxs, cols); ifa->txavg = arrayavg(ifa->txs, cols); ifa->rxmax = arraymax(ifa->rxs, cols); ifa->txmax = arraymax(ifa->txs, cols); } getcounters(ifa->ifname, &rx, &tx); }
/************************************************************************** * Row non-linear seperable filter - max (see nlfiltersep.m) * x = nlfiltersep_max( [ 1 9; 5 9; 0 0; 4 8; 7 3; 2 6], 1, 1 ) * y = [5 9; 5 9; 5 9; 7 8; 7 8; 7 6]; x-y * B(i,j) is the max of A(i-r1:i+r2,j). It has the same dims as A. * Border calculations are done separately for efficiency. *************************************************************************/ void nlfiltersep_max( const double *A, double *B, int r1, int r2, int mRows, int nCols ) { int i, row0, e, s, r, c; double m; for( c=0; c<nCols; c++ ) { row0 = mRows * c; /* leading border calculations */ for(r=0; r<mini(r1, mRows-1); r++) { e = mini( r+r2, mRows-1 ); arraymax( A, m, row0, row0+e, i ); B[r+row0] = m; } /* main caclulations */ for(r=r1; r<mRows-r2; r++) { arraymax( A, m, r-r1+row0, r+r2+row0, i ); B[r+row0]=m; } /* end border calculations */ for(r=maxi(mRows-r2-1, 0); r<mRows; r++) { s = maxi( r-r1, 0 ); arraymax( A, m, s+row0, mRows-1+row0, i ); B[r+row0] = m; } } }
int main() { char input[3]; int flag,data=0,h; //dynamic allocatio of the root root=(node*)malloc(sizeof(node)); printf("\nEnter the data to the node"); //assign data scanf("%d",&root->data); root->left=NULL; root->right=NULL; //for new node printf("\nDo you want to enter new node(yes/no):"); scanf("%s",input); flag=string_test(input); //Iterate itself until flag is 1 i. the string entered is yes while(flag==1) { //for new node printf("\nEnter the data to the new node"); //scan data scanf("%d",&data); //calling the create node function to create new node create_node(root,data); printf("\nDo you want to enter new node(yes/no):"); scanf("%s",input); //calling string_test fuction to check whether the input is yes or no flag=string_test(input); } //display the tree in pre_order printf("\npreorder\n"); print_preorder(root); //display the tree in in_order printf("\ninorder\n"); print_inorder(root); //display the tree in post_order printf("\npostorder\n"); print_postorder(root); path(root); h=arraymax(root); printf("\nmax of the tree: %d",h); return 0; }
double swconstfilter(void *space, Matchtype *m, IntSequence *a, IntSequence *b, Uint *ptr, Uint len, Uint pos, void *info) { imbissinfo *imbiss; int *swres; double t; imbiss = (imbissinfo*) info; t=scorefilter(space, m, a, b, ptr, len, pos, info); if (m->count == imbiss->minseeds) { swres = swgapless(space, a->sequence, a->length, b->sequence, b->length, constscr, imbiss->swscores); m->swscore= swres[arraymax(swres, (a->length+1)*(b->length+1))]; FREEMEMORY(space, swres); } return t; }
Matchtype* selectScoreSWconst(void *space, Matchtype *m, Uint k, IntSequence *a, IntSequence **s, void *info) { Uint l, i; int *swres; imbissinfo *imbiss; imbiss = (imbissinfo*) info; qsort(m, k, sizeof(Matchtype), cmp_score); l=0; for (i=k; i > 0 && l < 1000; i--) { if (m[i-1].count >= imbiss->minseeds) { swres = swgapless(space, a->sequence, a->length, s[m[i-1].id]->sequence, s[m[i-1].id]->length, constscr, imbiss->swscores /*subscr, info*/ ); m[i-1].swscore= swres[arraymax(swres, (a->length+1)*(s[m[i-1].id]->length+1))]; FREEMEMORY(space, swres); } else { m[i-1].swscore = 0; } l++; } qsort(m, k, sizeof(Matchtype), cmp_swscore); return m; }