Beispiel #1
0
void set_tbl (table * t, obj index, obj value){
  int i;
  obj cur_key;

  for (i = 0 ; i < t->size ; i++){
    cur_key = t->keys[i];

    if (!APTR(cur_key) || !ASTR(cur_key)){
      if (cur_key == index)
        break;
    }
    else if (ASTR(cur_key))
      if (eq_str ((string *) cur_key, (string *) index))
        break;
  }

  if (i == t->max_size){
    t->max_size *= 2;
    t->keys     = realloc (t->keys, sizeof (obj) * t->max_size);
    t->values   = realloc (t->values, sizeof (obj) * t->max_size);
  }

  if (i == t->size)
    t->size++;

  t->keys[i] = index;
  t->values[i] = value;
}
Beispiel #2
0
obj tbl_lookup (table * t, obj index){
  int i;
  obj cur_key;

  for (i = 0 ; i < t->size ; i++){
    cur_key = t->keys[i];

    if (!APTR(cur_key) || !ASTR(cur_key)){
      if (cur_key == index)
        return t->values[i];
    }
    else if (ASTR(cur_key))
      if (eq_str ((string *) cur_key, (string *) index))
        return t->values[i];
  }

  return SYM2OBJ("nil");
}
Beispiel #3
0
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>. */

#ifndef __CYTOSKELAB_VOIGT_IMPL__
#define __CYTOSKELAB_VOIGT_IMPL__

namespace cytoskelab {

  template<int dim>
  Voigt<dim>::Voigt ()
  {}

  template<int dim>
  Voigt<dim>::Voigt
  (APTR(Particle<dim>) _start,
   APTR(Particle<dim>) _end,
   double _springConst,
   double _restLength,
   double _viscosityConst,
   voigt_type_t t)
    : start (_start), end (_end), springConst (_springConst), restLength (_restLength),
      viscosityConst (_viscosityConst), type(t)
  {}

  template<int dim>
  Voigt<dim>::~Voigt ()
  {}

  template<int dim>
  typename Voigt<dim>::vec_t
Beispiel #4
0
glob_pars  G;

int verbose = 0; // each -v increments this value, e.g. -vvv sets it to 3
//            DEFAULTS
// default global parameters
glob_pars const Gdefault = {
    .gotoangle = 400.,
};

/*
 * Define command line options by filling structure:
 *  name    has_arg flag    val     type        argptr          help
*/
myoption cmdlnopts[] = {
    // set 1 to param despite of its repeating number:
    {"help",    NO_ARGS,    NULL,   'h',    arg_int,    APTR(&help),        _("show this help")},
    // change p3 position, don't run guiding
    {"goto",    NEED_ARG,   NULL,   'g',    arg_double, APTR(&G.gotoangle), _("rotate for given angle")},
    // goto 0, don't run guiding
    {"absmove", NO_ARGS,    NULL,   'a',    arg_none,   APTR(&G.absmove),   _("rotate to given absolute angle (or zero without -g)")},
    // incremented parameter without args (any -v will increment value of "verbose")
    {"verbose", NO_ARGS,    NULL,   'v',    arg_none,   APTR(&verbose),     _("verbose level (each -v increase it)")},
    end_option
};


/**
 * Parse command line options and return dynamically allocated structure
 *      to global parameters
 * @param argc - copy of argc from main
 * @param argv - copy of argv from main
Beispiel #5
0
void explore_heap(obj from){
  long o;
  long * fn;
  table * t;
  sharedvar * s;
  int i;
  obj * pfrom;

  if (APTR(from)){
    pfrom = (void *) from;
    i     = 0;

    /*Why is this checking if it's FREE?
      shouldn't this process occur only
      of there are no FREE heapspaces?
      Because it might change in the future, but let's remove it for now
      while (i < HEAP_SIZE && (freel.heap[i] != from || freel.mark[i] == FREE)) */
    while (i < HEAP_SIZE && freel.heap[i] != from)
      i++;

    if (i < HEAP_SIZE && freel.mark[i] == UNMARKED){
      freel.mark[i] = MARKED;
      o = (long) *pfrom;

      switch (o){
        case T_PAIR:
          explore_heap(((pair *)pfrom)->car);
          explore_heap(((pair *)pfrom)->cdr);
          break;
        case T_TAG:
          explore_heap(((tagged *)pfrom)->ctype);
          explore_heap(((tagged *)pfrom)->content);
          break;
        case T_STR:
          break;
        case T_FLOAT:
          break;
        case T_FN:
	case T_KFN:
	case T_LKFN:
          fn = pfrom;

          for (i = 0 ; i < fn[1]; i++)
            explore_heap((obj)(fn[i+3]));
          break;
        case T_TBL:
          t = (table *) pfrom;

          for (i = 0 ; i < t->size ; i++){
            explore_heap(t->keys[i]);
            explore_heap(t->values[i]);
          }
          break;
        case T_SHAREDVAR:
          s = (sharedvar *) pfrom;

          explore_heap(s->var);
          break;
      }
    }
  }
}
Beispiel #6
0
  { return externalF; }


  template<int dim>
  void Particle<dim>::addInternalForce( typename Particle<dim>::vec_t f ) {
	  this->internalF += f;
  }



  template<int dim>
  void Particle<dim>::addExternalForce( typename Particle<dim>::vec_t f ) {
	  this->externalF += f;
  }


  template<int dim>
  void Particle<dim>::computeNewPosition( APTR( EqSolver) eqs ) {

    // TODO !!!!!!!
	//here it should be connection with
    //instance of equation for this particle
    //ad using this equation we should be able to
	//compute new position of particle

  }

};

#endif