Esempio n. 1
0
/*
 * call-seq:
 *   native_call(this, *args)
 *
 * Call this Ruby Object as a function, with the given +this+ object and
 * arguments. Equivalent to the call method in JavaScript.
 */
static VALUE
native_call(int argc, VALUE* argv, VALUE self)
{
  if (!function_p(self))
    rb_raise(rb_eRuntimeError,
      "This Johnson::SpiderMonkey::RubyLandProxy isn't a function.");

  if (argc < 1)
    rb_raise(rb_eArgError, "Target object required");

  RubyLandProxy* proxy;
  Data_Get_Struct(self, RubyLandProxy, proxy);

  jsval proxy_value;

  if (!get_jsval_for_proxy(proxy, &proxy_value))
    raise_js_error_in_ruby(proxy->runtime);

  jsval global;

  if (!convert_to_js(proxy->runtime, argv[0], &global))
    raise_js_error_in_ruby(proxy->runtime);

  return call_js_function_value(proxy->runtime, global, proxy_value,
    argc - 1, &(argv[1]));
}
Esempio n. 2
0
enum dylan_type_enum
dylan_type (D instance) {
  if ((DUMINT)instance & 3) {
    if ((DUMINT)instance & 1)
      return(integer_type);
    else if ((DUMINT)instance & 2)
      return(character_type);
    else
      return(unknown_type);
  } else { /* dylan pointer */
    if (float_p(instance))
      return(float_type);
    else if (boolean_p(instance))
      return(dylan_boolean_type);
    else if (string_p(instance))
      return(string_type);
    else if (vector_p(instance))
      return(vector_type);
    else if (pair_p(instance))
      return(pair_type);
    else if (empty_list_p(instance))
      return(empty_list_type);
    else if (symbol_p(instance))
      return(symbol_type);
    else if (simple_condition_p(instance))
      return(simple_condition_type);
    else if (class_p(instance))
      return(class_type);
    else if (function_p(instance))
      return(function_type);
    else
      return(user_defined_type);
  }
}
Esempio n. 3
0
//----------------------------------------------------------------------
void anisotropic_kernel(){
	for(int k=0;k<PARTICLES;k++){

	 /*
	 このままだと粒子近傍の有効範囲が正方形になってしまう。
	 */
	 int x_min = int(x[k] * GRID_SIZE_X - DISTANCE * GRID_SIZE_X);
	 int y_min = int(y[k] * GRID_SIZE_Y - DISTANCE * GRID_SIZE_Y);
	 int x_max = int(x[k] * GRID_SIZE_X + DISTANCE * GRID_SIZE_X);
	 int y_max = int(y[k] * GRID_SIZE_Y + DISTANCE * GRID_SIZE_Y);

	 if(x_min < 0)
		 x_min =0;
	 if(y_min < 0)
		 y_min =0;
	 if(x_max > GRID_SIZE_X)
		 x_max = GRID_SIZE_X;
	 if(y_max > GRID_SIZE_Y)
		 x_max = GRID_SIZE_Y;
	 

	 int i = x_min;
	 int j = y_min;

	 double sigma = 1.0;//スケーリング定数
	 double h = DISTANCE;//有効範囲
	 double h_square = h * h;//h^2

	 weighted_mean();
	 calc_covariance_matrix(k);
     calc_svd();
     calc_matrix_G();
	 double determinant = matrix_G[0][0] * matrix_G[1][1] - matrix_G[1][0] * matrix_G[0][1];
	 double Gr = sqrt( pow(matrix_G[0][0] * (x[k] - x_smoothing[k]) + matrix_G[1][0] * (y[k] - y_smoothing[k]),2) 
						+ pow(matrix_G[0][1] * (x[k] - x_smoothing[k]) + matrix_G[1][1] * (y[k] - y_smoothing[k]),2) );

	 //ここで固有値などを調整する必要がある。

	for(i =x_min;i<x_max;i++){
		int l=0;
		for(j=y_min;j<y_max;j++){
			double distance = sqrt( pow(fabs((double)j / GRID_SIZE_X -  y[k]),2) + pow(fabs( (double)i/ GRID_SIZE_Y - x[k]),2)  );
			grid[i][j] = grid[i][j] + sigma  * determinant * function_p(Gr);
			l++;
		}
	    particle_number[i][j] = l;
	}
 }


}
Esempio n. 4
0
void isotropic_kernel(){
	 for(int k=0;k<PARTICLES;k++){

	 /*
	 このままだと粒子近傍の有効範囲が正方形になってしまう。
	 */
	 int x_min = int(x[k] * GRID_SIZE_X - DISTANCE * GRID_SIZE_X);
	 int y_min = int(y[k] * GRID_SIZE_Y - DISTANCE * GRID_SIZE_Y);
	 int x_max = int(x[k] * GRID_SIZE_X + DISTANCE * GRID_SIZE_X);
	 int y_max = int(y[k] * GRID_SIZE_Y + DISTANCE * GRID_SIZE_Y);

	 if(x_min < 0)
		 x_min =0;
	 if(y_min < 0)
		 y_min =0;
	 if(x_max > GRID_SIZE_X)
		 x_max = GRID_SIZE_X;
	 if(y_max > GRID_SIZE_Y)
		 x_max = GRID_SIZE_Y;
	 

	 int i = x_min;
	 int j = y_min;

	 double sigma = 1.0;//スケーリング定数
	 double h = DISTANCE;//有効範囲
	 double h_square = h * h;//h^2

	for(i =x_min;i<x_max;i++){
		int l=0;
		for(j=y_min;j<y_max;j++){
			double distance = sqrt( pow(fabs((double)j / GRID_SIZE_X -  y[k]),2) + pow(fabs( (double)i/ GRID_SIZE_Y - x[k]),2)  );
			grid[i][j] = grid[i][j] + sigma / h_square * function_p(distance / h);
			l++;
		}
	    particle_number[i][j] = l;
	}
 }
}
Esempio n. 5
0
static VALUE
callable_test_p(VALUE self, VALUE proxy)
{
  return function_p(proxy);
}