/** * Build a tree using a given string * @param txt the text to build it from * @return the finished tree's root */ node *build_tree( char *txt ) { // init globals e = 0; root=NULL; f=NULL; current=NULL; memset( &last, 0, sizeof(pos) ); memset( &old_beta, 0, sizeof(pos) ); old_j = 0; str = txt; slen = strlen(txt); // actually build the tree root = node_create( 0, 0 ); if ( root != NULL ) { f = node_create_leaf( 0 ); if ( f != NULL ) { int i; node_add_child( root, f ); for ( i=1; i<=slen; i++ ) phase(i); set_e( root ); } } return root; }
E3State::E3State(const E3Config* config){ int m = config->m(); for(int i=0; i<m; i++){ this->add_particles(); this->mutable_particles(i)->set_a(1); this->mutable_particles(i)->set_ksi(0.0); } set_e(0.001); set_phi(0.0); set_simulated(false); }
static uint8_t pulse_e() { uint8_t data = 0; set_e(); _delay_ms(1); data = input_nibble(); clear_e(); return data; }
/** * Set the length of each leaf to e recursively * @param v the node in question */ static void set_e( node *v ) { if ( node_is_leaf(v) ) { node_set_len( v, e-node_start(v)+1 ); } node *u = node_children( v ); while ( u != NULL ) { set_e( u ); u = node_next( u ); } }
//Determine values for the orbital elements for the requested JD, then //call KSAsteroid::findGeocentricPosition() bool KSPluto::findGeocentricPosition( const KSNumbers *num, const KSPlanetBase *Earth ) { //First, set the orbital element values according to the current epoch double t = num->julianCenturies(); set_a( a0 + a1*t ); set_e( e0 + e1*t ); set_i( i0.Degrees() + i1*t ); set_N( N0.Degrees() + N1*t ); set_M( M0.Degrees() + M1*t ); set_P( 365.2568984 * pow((a0+a1*t), 1.5) ); //set period from Kepler's 3rd law setJD( num->julianDay() ); return KSAsteroid::findGeocentricPosition( num, Earth ); }
/** * Set the length of each leaf to e recursively * @param v the node in question * @param log the log to record errors in */ static void set_e( suffixtree *st, node *v, plugin_log *log ) { if ( node_is_leaf(v) ) { node_set_len( v, st->e-node_start(v)+1 ); } node_iterator *iter = node_children( v, log ); if ( iter != NULL ) { while ( node_iterator_has_next(iter) ) { node *u = node_iterator_next( iter ); set_e( st, u, log ); } node_iterator_dispose( iter ); } }
/** * Build a tree using a given string * @param txt the text to build it from * @param tlen its length * @param log the log to record errors in * @return the finished tree */ suffixtree *suffixtree_create( UChar *txt, size_t tlen, plugin_log *log ) { if ( txt[tlen] != 0 ) { plugin_log_add(log,"suffixtree: text not null-terminated!"); return NULL; } else { suffixtree *st = calloc( 1, sizeof(suffixtree) ); if ( st != NULL ) { st->e = 0; memset( &st->last, 0, sizeof(pos) ); memset( &st->old_beta, 0, sizeof(pos) ); st->str = txt; st->slen = tlen; // actually build the tree st->root = node_create( 0, 0, log ); if ( st->root != NULL ) { st->f = node_create_leaf( 0, log ); if ( st->f != NULL ) { int i; node_add_child( st->root, st->f, st->str, log ); for ( i=1; i<=tlen; i++ ) phase(st,i,log); set_e( st, st->root, log ); } } } else fprintf(stderr,"suffixtree: failed to allocate tree\n"); return st; } }
E3State::E3State(){ set_e(0.001); set_phi(0.0); set_simulated(false); }