コード例 #1
0
ファイル: main.c プロジェクト: cinkaryliss/Numerical_Analysis
unsigned int calc_data(unsigned int n_step, double h, double t[], double x[], double y[]){
    int i;
    //int n_step;
    //double h;
    
    //初期条件
    //t[0] = 0.0;
    //x[0] = 2.0;
    //y[0] = 0.0;
    
    //h = 0.002; //刻み幅
    //n_step = 7500;  //ステップ数
    
    //オイラー法の計算
    for(i = 0; i <= n_step; i++){
        y[i+1] = y[i] + h*yfunc(x[i], t[i]);
        x[i+1] = x[i] + h*xfunc(y[i], t[i]);
        t[i+1] = t[i] + h;
    }
    
    //計算結果の表示
    for(i = 0; i <= n_step; i += 50)
        //printf("%lf | %lf\n", t[i], x[i]);
    
    return n_step;
}
コード例 #2
0
ファイル: dcache.c プロジェクト: mbref/gdb-65-microblaze
int
dcache_xfer_memory (DCACHE *dcache, CORE_ADDR memaddr, gdb_byte *myaddr,
		    int len, int should_write)
{
  int i;
  int (*xfunc) (DCACHE *dcache, CORE_ADDR addr, gdb_byte *ptr);
  xfunc = should_write ? dcache_poke_byte : dcache_peek_byte;

  for (i = 0; i < len; i++)
    {
      if (!xfunc (dcache, memaddr + i, myaddr + i))
	return 0;
    }

  /* FIXME: There may be some benefit from moving the cache writeback
     to a higher layer, as it could occur after a sequence of smaller
     writes have been completed (as when a stack frame is constructed
     for an inferior function call).  Note that only moving it up one
     level to target_xfer_memory() (also target_xfer_memory_partial())
     is not sufficent, since we want to coalesce memory transfers that
     are "logically" connected but not actually a single call to one
     of the memory transfer functions. */

  if (should_write)
    dcache_writeback (dcache);
    
  return len;
}
コード例 #3
0
ファイル: cloudlayer.c プロジェクト: xtmacbook/SGI
/*ARGSUSED1*/
void
key(unsigned char key, int x, int y) {
    switch(key) {
    case 'x': xfunc(); break;
    case 'h': help(); break;
    case '\033': exit(EXIT_SUCCESS); break;
    default: break;
    }
    glutPostRedisplay();
}
コード例 #4
0
ファイル: dcache.c プロジェクト: AhmadTux/DragonFlyBSD
int
dcache_xfer_memory (struct target_ops *ops, DCACHE *dcache,
		    CORE_ADDR memaddr, gdb_byte *myaddr,
		    int len, int should_write)
{
  int i;
  int res;
  int (*xfunc) (DCACHE *dcache, CORE_ADDR addr, gdb_byte *ptr);

  xfunc = should_write ? dcache_poke_byte : dcache_peek_byte;

  /* If this is a different inferior from what we've recorded,
     flush the cache.  */

  if (! ptid_equal (inferior_ptid, dcache->ptid))
    {
      dcache_invalidate (dcache);
      dcache->ptid = inferior_ptid;
    }

  /* Do write-through first, so that if it fails, we don't write to
     the cache at all.  */

  if (should_write)
    {
      res = target_write (ops, TARGET_OBJECT_RAW_MEMORY,
			  NULL, myaddr, memaddr, len);
      if (res <= 0)
	return res;
      /* Update LEN to what was actually written.  */
      len = res;
    }
      
  for (i = 0; i < len; i++)
    {
      if (!xfunc (dcache, memaddr + i, myaddr + i))
	{
	  /* That failed.  Discard its cache line so we don't have a
	     partially read line.  */
	  dcache_invalidate_line (dcache, memaddr + i);
	  /* If we're writing, we still wrote LEN bytes.  */
	  if (should_write)
	    return len;
	  else
	    return i;
	}
    }
    
  return len;
}
コード例 #5
0
int list_traverse_till(struct linked_list *list, void *func){
    if(list->count == 0)return 0;
    int (*xfunc)(void *) = func;
    struct linked_list_node *node;
    int i=0;
    node = list->first_node;
    do{
        if(xfunc(node->data)){
            return i;   
        }
        ++i;
        node = node->next;
    }while(i < list->count);
    return i;
}
コード例 #6
0
ファイル: relocs1.c プロジェクト: VargMon/dd-wrt
int branches (int y)
{
  int z;

  for (z = y; z < y + 10; z++)
    {
      if (z & 0x1)
	{
	  gfunc (z);
	}
      else
	{
	  xfunc (z);
	}
    }
}
コード例 #7
0
ファイル: water.c プロジェクト: xtmacbook/SGI
/*ARGSUSED1*/
void
key(unsigned char key, int x, int y) {
    switch(key) {
    case 'l': light(); break;
    case 'f': ffunc(); break;
    case 'F': Ffunc(); break;
    case 't': toggle_t(); break;
    case 'm': mfunc(); break;
    case 'w': wire(); break;
    case 'x': xfunc(); break;
    case 'h': help(); break;
    case '\033': exit(EXIT_SUCCESS); break;
    default: help(); break;
    }
    glutPostRedisplay();
}
コード例 #8
0
void *list_delete_func(struct linked_list *list, void *func){
    int (*xfunc)(void *) = func;
    int i;
    struct linked_list_node *node;
    void *data;
    node = list->first_node;
    for(i=0;i<list->count;++i){
        if(!xfunc(node->data)){
            data = node->data;
            delete_linked_list_node(list, node);
            list->count -= 1;
            return data;
        }
        node = node->next;
    }
    return NULL;
}
コード例 #9
0
ファイル: bubble.c プロジェクト: AlexGreulich/HRTFVR
/*ARGSUSED1*/
void key (unsigned char key, int x, int y) {
    switch (key) {
    case 'b': bfunc(); break;
    case 'c': cfunc(); break;
    case 'l': lfunc(); break;
    case 't': tfunc(); break;
    case 'f': ffunc(); break;
    case 'n': nfunc(); break;
    case 'u': ufunc(); break;
    case 'U': Ufunc(); break;
    case 'p': pfunc(); break;
    case 'P': Pfunc(); break;
    case 'w': wfunc(); break;
    case 'x': xfunc(); break;
    case 'X': Xfunc(); break;
    case 'y': yfunc(); break;
    case '\033': exit(EXIT_SUCCESS); break;
    default: break;
    }
}
コード例 #10
0
ファイル: relocs1.c プロジェクト: VargMon/dd-wrt
static int sfunc (int y)
{
  xfunc (y);
}