예제 #1
0
double getidle(void)
{
  u64_t stop, idle2;
  u64_t idelta, tdelta;
  double ifp, tfp, rfp;
  int r;

  if (!running) {
	if ((r = sys_getidletsc(&idle)) != OK)
		return -1.0;

	running = 1;

	read_tsc_64(&start);

	return 0.0;
  }
  else {
	read_tsc_64(&stop);

	running = 0;

	if ((r = sys_getidletsc(&idle2)) != OK)
		return -1.0;

	idelta = sub64(idle2, idle);
	tdelta = sub64(stop, start);

	if (cmp64(idelta, tdelta) >= 0)
		return 100.0;

	ifp = make_double(idelta);
	tfp = make_double(tdelta);

	rfp = ifp / tfp * 100.0;

	if (rfp < 0.0) rfp = 0.0;
	else if (rfp > 100.0) rfp = 100.0;

	return rfp;
  }

  running = !running;
}
예제 #2
0
Cell* op_plus::eval_op(Cell* operand) const
{
  // keep adding until reaches nil pointer
  int int_sum = 0;
  double double_sum = 0.0;
  bool double_exist = false;

  //to store the result of car cell if it is a list
  Cell* operand_ptr;

  //check if operand is not empty
  while(!nullp(operand))
  {
    if (nullp(car(operand)))
    {
       if (operand_ptr != NULL)
          delete operand_ptr;
       throw runtime_error("'+' can only deal with integer and double.");
    }
    else if (listp(car(operand)))
    {
       operand_ptr = eval(car(operand));
    }
    else if (symbolp(car(operand)))
    {
       operand_ptr = search_symbol(get_symbol(car(operand)),true);
    }
    else
    {
       operand_ptr = car(operand);
    }

    if (intp(operand_ptr))
    {
       int_sum += get_int(operand_ptr);
    }
    else if (doublep(operand_ptr))
    {
       double_sum += get_double(operand_ptr);
       double_exist = true;
    }
    else
    {
       delete operand_ptr;
       throw runtime_error("'+' can only deal with integer and double.");
    }

    operand = cdr(operand);
  }
  
  if (double_exist)
    return make_double(double_sum+int_sum);
  else
    return make_int(int_sum);
};
예제 #3
0
/**
 * \brief Make the cell.
 * \param str The string to represent the symbol, int or double.
 */
Cell* makecell(string str)
{
    Cell* root;
    if (((str[0] >= '0') && (str[0] <= '9')) || (str[0] == '.')
            || ((('+'==str[0]) || ('-'==str[0]))&&(str.length()>1))) {
        if (false == is_legalnumeric(str)) {
            cout << "error: illegal numeric literal" << endl;
            exit(1);
        }
        // this is a numeric literal
        if (string::npos == str.find('.')) {
            // int number
            char* fchar = const_cast<char*>(str.c_str());
            int value = atoi(fchar);
            root = make_int(value);
        } else {
            // this is a double
            char* fchar = const_cast<char*>(str.c_str());
            double value = atof(fchar);
            root = make_double(value);
        }
    }

    // we don't deal with literal strings right now, so they are commented out
    // else if (str[0] == '\"') {
//     // this is a string literal
//     string strval = str.substr(1, str.size() - 2);
//     root = make_string(const_cast<char*>(strval.data()));
//   }
    else {
        // this is a symbol
        if (false == is_legaloperator(str)) {
            cout << "error: illegal operator" << endl;
            exit(1);
        }
        root = make_symbol(const_cast<char*>(str.data()));
    }
    return root;
}
예제 #4
0
파일: rsqrtd2.c 프로젝트: Mashewnutz/Slo
int main()
{
   TEST_SET_START("20040928174038EJL","EJL", "rsqrtd2");
   
   unsigned long long i6 =   0x7464fff515d76f87ull;
   unsigned long long i6r =  0x25b3c03b72dba06cull;
   unsigned long long i7 =   0x7606a4533cf5605eull;
   unsigned long long i7r =  0x24e3056f4b45f6a9ull;
   unsigned long long i8 =   0x4beae58c6f48733eull;
   unsigned long long i8r =  0x39f173b787396c5full;
   unsigned long long i9 =   0x3999ed5c8316b00bull;
   unsigned long long i9r =  0x43192359a70ec761ull;
   unsigned long long i10 =  0x68f7885c4b84b793ull;
   unsigned long long i10r = 0x2b6a62d48c269d90ull;
   unsigned long long i11 =  0x1aabc083c5c26227ull;
   unsigned long long i11r = 0x52912e543817fabbull;

   double x0 = hide_double(-HUGE_VAL);           // -Inf -> NaN
   double x1 = hide_double(HUGE_VAL);            // Inf -> +0
   double x2 = hide_double(0.0);                // +0  -> Inf
   double x3 = hide_double(-0.0);               // -0  -> -Inf
   double x4 = hide_double(nan(""));            // NaN -> NaN
   double x5 = hide_double(4.0);
   double x5r = hide_double(0.5);
   double x6 = hide_double(make_double(i6));
   double x6r = hide_double(make_double(i6r));
   double x7 = hide_double(make_double(i7));
   double x7r = hide_double(make_double(i7r));
   double x8 = hide_double(make_double(i8));
   double x8r = hide_double(make_double(i8r));
   double x9 = hide_double(make_double(i9));
   double x9r = hide_double(make_double(i9r));   
   double x10 = hide_double(make_double(i10));     
   double x10r = hide_double(make_double(i10r));   
   double x11 = hide_double(make_double(i11));     
   double x11r = hide_double(make_double(i11r));   
   
   vec_double2 x0_v = spu_splats(x0);
   vec_double2 x1_v = spu_splats(x1);
   vec_double2 x2_v = spu_splats(x2);
   vec_double2 x3_v = spu_splats(x3);
   vec_double2 x4_v = spu_splats(x4);
   vec_double2 x5_v = spu_splats(x5);
   vec_double2 x5r_v = spu_splats(x5r);
   vec_double2 x6_v = spu_splats(x6);
   vec_double2 x6r_v = spu_splats(x6r);
   vec_double2 x7_v = spu_splats(x7);
   vec_double2 x7r_v = spu_splats(x7r);
   vec_double2 x8_v = spu_splats(x8);
   vec_double2 x8r_v = spu_splats(x8r);
   vec_double2 x9_v = spu_splats(x9);
   vec_double2 x9r_v = spu_splats(x9r);
   vec_double2 x10_v = spu_splats(x10);
   vec_double2 x10r_v = spu_splats(x10r);
   vec_double2 x11_v = spu_splats(x11);
   vec_double2 x11r_v = spu_splats(x11r);
   
   vec_double2 res_v;

   TEST_START("rsqrtd2");
   res_v = rsqrtd2(x0_v);
   TEST_CHECK("20040928174042EJL", allnan_double2( res_v ), 0);
   res_v = rsqrtd2(x1_v);
   TEST_CHECK("20040928174045EJL", allposzero_double2( res_v ), 0);
   res_v = rsqrtd2(x2_v);
   TEST_CHECK("20040928174047EJL", allposinf_double2( res_v ), 0);
   res_v = rsqrtd2(x3_v);
   TEST_CHECK("20040928174049EJL", allneginf_double2( res_v ), 0);
   res_v = rsqrtd2(x4_v);
   TEST_CHECK("20040928174054EJL", allnan_double2( res_v ), 0);
   res_v = rsqrtd2(x5_v);
   TEST_CHECK("20040928174058EJL", allequal_double2( res_v, x5r_v ), 0);
   res_v = rsqrtd2(x6_v);
   TEST_CHECK("20040928174101EJL", allequal_ulps_double2( res_v, x6r_v, 1 ), 0);
   res_v = rsqrtd2(x7_v);
   TEST_CHECK("20040928174104EJL", allequal_ulps_double2( res_v, x7r_v, 1 ), 0);
   res_v = rsqrtd2(x8_v);
   TEST_CHECK("20040928174106EJL", allequal_ulps_double2( res_v, x8r_v, 1 ), 0);
   res_v = rsqrtd2(x9_v);
   TEST_CHECK("20040928174108EJL", allequal_ulps_double2( res_v, x9r_v, 1 ), 0);
   res_v = rsqrtd2(x10_v);
   TEST_CHECK("20040928174110EJL", allequal_ulps_double2( res_v, x10r_v, 1 ), 0);
   res_v = rsqrtd2(x11_v);
   TEST_CHECK("20040928174113EJL", allequal_ulps_double2( res_v, x11r_v, 1 ), 0);
      
   TEST_SET_DONE();

   TEST_EXIT();
}
예제 #5
0
Node* list_insert_double(Node* n, Node* pos, const double value) {
  return list_insert(n, pos, make_double(value));
}
예제 #6
0
파일: recipd2.c 프로젝트: BlackYoup/medusa
int main()
{
   TEST_SET_START("20040920095218EJL","EJL", "recipd2");
   
   unsigned long long i6 = 0x7fd0000000000001ull;   // 2^1022 + 1 ulp
   unsigned long long i7 = 0xffd0000000000000ull;   // -2^1022
   unsigned long long i7r = 0x8010000000000000ull;  // -2^-1022
   unsigned long long i8 =   0x7606a4533cf5605eull; // random values
   unsigned long long i8r =  0x09d69cea2b5b5b57ull;
   unsigned long long i9 =   0x4c042c295376566eull;
   unsigned long long i9r =  0x33d9618e87b961f4ull;
   unsigned long long i10 =  0x39b3720562510408ull;
   unsigned long long i10r = 0x462a54842d7f9b5dull;
   unsigned long long i11 =  0x6911a64538a389aeull;
   unsigned long long i11r = 0x16cd02637ed13ff2ull;
   unsigned long long i12 =  0x1ac4d062d451c99dull;
   unsigned long long i12r = 0x6518994c26ebbb3eull;

   double x0 = hide_double(-HUGE_VAL);           // -Inf
   double x1 = hide_double(HUGE_VAL);            // Inf
   double x2 = hide_double(0.0);                // 0
   double x3 = hide_double(-0.0);               // -0
   double x4 = hide_double(nan(""));            // NaN
   double x5 = hide_double(2.0);
   double x5r = hide_double(0.5);
   double x6 = hide_double(make_double(i6));
   double x7 = hide_double(make_double(i7));
   double x7r = hide_double(make_double(i7r));
   double x8 = hide_double(make_double(i8));
   double x8r = hide_double(make_double(i8r));
   double x9 = hide_double(make_double(i9));
   double x9r = hide_double(make_double(i9r));   
   double x10 = hide_double(make_double(i10));     
   double x10r = hide_double(make_double(i10r));   
   double x11 = hide_double(make_double(i11));     
   double x11r = hide_double(make_double(i11r));   
   double x12 = hide_double(make_double(i12));     
   double x12r = hide_double(make_double(i12r));   
   
   vec_double2 x0_v = spu_splats(x0);
   vec_double2 x1_v = spu_splats(x1);
   vec_double2 x2_v = spu_splats(x2);
   vec_double2 x3_v = spu_splats(x3);
   vec_double2 x4_v = spu_splats(x4);
   vec_double2 x5_v = spu_splats(x5);
   vec_double2 x5r_v = spu_splats(x5r);
   vec_double2 x6_v = spu_splats(x6);
   vec_double2 x7_v = spu_splats(x7);
   vec_double2 x7r_v = spu_splats(x7r);
   vec_double2 x8_v = spu_splats(x8);
   vec_double2 x8r_v = spu_splats(x8r);
   vec_double2 x9_v = spu_splats(x9);
   vec_double2 x9r_v = spu_splats(x9r);
   vec_double2 x10_v = spu_splats(x10);
   vec_double2 x10r_v = spu_splats(x10r);
   vec_double2 x11_v = spu_splats(x11);
   vec_double2 x11r_v = spu_splats(x11r);
   vec_double2 x12_v = spu_splats(x12);
   vec_double2 x12r_v = spu_splats(x12r);
   
   vec_double2 res_v;

   TEST_START("recipd2");
   res_v = recipd2(x0_v);
   TEST_CHECK("20040920095224EJL", allnegzero_double2( res_v ), 0);
   res_v = recipd2(x1_v);
   TEST_CHECK("20040920095226EJL", allposzero_double2( res_v ), 0);
   res_v = recipd2(x2_v);
   TEST_CHECK("20040920095228EJL", allposinf_double2( res_v ), 0);
   res_v = recipd2(x3_v);
   TEST_CHECK("20040920095233EJL", allneginf_double2( res_v ), 0);
   res_v = recipd2(x4_v);
   TEST_CHECK("20040920095235EJL", allnan_double2( res_v ), 0);
   res_v = recipd2(x5_v);
   TEST_CHECK("20040920095237EJL", allequal_double2( res_v, x5r_v ), 0);
   res_v = recipd2(x6_v);
   TEST_CHECK("20040920095239EJL", allzerodenorm_double2( res_v ), 0);
   res_v = recipd2(x7_v);
   TEST_CHECK("20040920095242EJL", allequal_double2( res_v, x7r_v ), 0);
   res_v = recipd2(x8_v);
   TEST_CHECK("20040920095245EJL", allequal_ulps_double2( res_v, x8r_v, 1 ), 0);
   res_v = recipd2(x9_v);
   TEST_CHECK("20040920095247EJL", allequal_ulps_double2( res_v, x9r_v, 1 ), 0);
   res_v = recipd2(x10_v);
   TEST_CHECK("20040920095248EJL", allequal_ulps_double2( res_v, x10r_v, 1 ), 0);
   res_v = recipd2(x11_v);
   TEST_CHECK("20040920095250EJL", allequal_ulps_double2( res_v, x11r_v, 1 ), 0);
   res_v = recipd2(x12_v);
   TEST_CHECK("20040920095252EJL", allequal_ulps_double2( res_v, x12r_v, 1 ), 0);
      
   TEST_SET_DONE();

   TEST_EXIT();
}
예제 #7
0
파일: fmad2.c 프로젝트: BlackYoup/medusa
int main()
{
   TEST_SET_START("20060828114000MH","MH", "fmad2");

//   double denorm_min = hide_double(make_double(0x0000000000000001ull));
   double denorm_max = hide_double(make_double(0x000fffffffffffffull));
//   double norm_min   = hide_double(make_double(0x0010000000000000ull));
   double norm_max   = hide_double(make_double(0x7fefffffffffffffull));
   
   double x0 = hide_double(1760.135);
   double y0 = hide_double(19355.03);
   double z0 = hide_double(-12351.9);
   double a0 = hide_double(34055113.82905);

   double x1 = hide_double(-139.035);
   double y1 = hide_double(0.0);
   double z1 = hide_double(-1.0);

   double x2 = hide_double(nan(""));
   double y2 = hide_double(-1.0);
   double z2 = hide_double(-0.0);

   double x3 = hide_double(1.0);
   double y3 = hide_double(HUGE_VAL);
   double z3 = hide_double(-1.0);

   double x4 = norm_max;
   double y4 = norm_max;
   double z4 = hide_double(0.0);

   double x5 = hide_double(100.0);
   double y5 = denorm_max;
   double z5 = hide_double(0.0);
   double a5 = hide_double(make_double(0x0078fffffffffffeull));

   vec_double2 x0_v = spu_splats(x0); 
   vec_double2 y0_v = spu_splats(y0); 
   vec_double2 z0_v = spu_splats(z0); 
   vec_double2 x1_v = spu_splats(x1); 
   vec_double2 y1_v = spu_splats(y1); 
   vec_double2 z1_v = spu_splats(z1); 
   vec_double2 x2_v = spu_splats(x2); 
   vec_double2 y2_v = spu_splats(y2); 
   vec_double2 z2_v = spu_splats(z2); 
   vec_double2 x3_v = spu_splats(x3); 
   vec_double2 y3_v = spu_splats(y3); 
   vec_double2 z3_v = spu_splats(z3); 
   vec_double2 x4_v = spu_splats(x4); 
   vec_double2 y4_v = spu_splats(y4); 
   vec_double2 z4_v = spu_splats(z4); 
   vec_double2 x5_v = spu_splats(x5); 
   vec_double2 y5_v = spu_splats(y5); 
   vec_double2 z5_v = spu_splats(z5); 

   vec_double2 a0_v = spu_splats(a0); 
   vec_double2 a1_v = spu_splats(z1); 
   vec_double2 a5_v = spu_splats(a5); 

   vec_double2 res_v;

   TEST_START("fmad2");
   res_v = fmad2(x0_v, y0_v, z0_v);
   TEST_CHECK("20060828114001MH", allequal_ulps_double2( res_v, a0_v, 1 ), 0);
   res_v = fmad2(y0_v, x0_v, z0_v);
   TEST_CHECK("20060828114002MH", allequal_ulps_double2( res_v, a0_v, 1 ), 0);
   res_v = fmad2(x1_v, y1_v, z1_v);
   TEST_CHECK("20060828114003MH", allequal_ulps_double2( res_v, a1_v, 1 ), 0);
   res_v = fmad2(y1_v, x1_v, z1_v);
   TEST_CHECK("20060828114004MH", allequal_ulps_double2( res_v, a1_v, 1 ), 0);
   res_v = fmad2(x2_v, y2_v, z2_v);
   TEST_CHECK("20060828114005MH", allnan_double2( res_v ), 0);
   res_v = fmad2(y2_v, x2_v, z2_v);
   TEST_CHECK("20060828114006MH", allnan_double2( res_v ), 0);
   res_v = fmad2(x3_v, y3_v, z3_v);
   TEST_CHECK("20060828114007MH", allposinf_double2( res_v ), 0);
   res_v = fmad2(y3_v, x3_v, z3_v);
   TEST_CHECK("20060828114008MH", allposinf_double2( res_v ), 0);
   res_v = fmad2(x4_v, y4_v, z4_v);
   TEST_CHECK("20060828114009MH", allposinf_double2( res_v ), 0);
   res_v = fmad2(y4_v, x4_v, z4_v);
   TEST_CHECK("20060828114010MH", allposinf_double2( res_v ), 0);
   res_v = fmad2(x5_v, y5_v, z5_v);
   TEST_CHECK("20060828114011MH", allequal_ulps_double2( res_v, a5_v, 1 ), 0);
   res_v = fmad2(y5_v, x5_v, z5_v);
   TEST_CHECK("20060828114012MH", allequal_ulps_double2( res_v, a5_v, 1 ), 0);
//printf("res:%.10le, a5:%.10le\n", spu_extract(res_v, 0), spu_extract(a5_v, 0));

   TEST_SET_DONE();
   
   TEST_EXIT();
}
예제 #8
0
V_EXPORT int VIOBT_parse_double(VIOBT *in, double *ret)
{
	int ch = 0, mark, int_sign = 1, exponent_sign = 1;
	V_UINT32 int_part = 0, fraction_part = 0, exponent_part = 0;
		
	VIOBT_parse_skip_spaces( in );

	mark = VIOBT_get_mark( in );

	if (VIOBT_getchar(in) == '-') {
		int_sign = -1;
	} else {
		ch = VIOBT_getchar(in);
	}

	if (ch != '0') {

		if (isdigit(ch)) {
		
			do {
				
				ch = VIOBT_getchar(in);
				if (!isdigit(ch)) {
					break;
				}
				int_part = ch + (int_part * 10);

			} while( 1 );

		} else {
			VIOBT_unget( in, mark);
			return -1;
		}
	}

	if (ch == '.') {

		do {
			
			ch = VIOBT_getchar(in);
			if (!isdigit(ch)) {
				break;
			}
			fraction_part = ch + (fraction_part * 10);

		} while( 1 );	}

	if (ch == 'e' || ch == 'E') {

		ch = VIOBT_getchar(in);
		if (ch == '+') {

		} else if (ch == '-') {
			exponent_sign = -1;
		} else {
			
		}

		do {

			ch = VIOBT_getchar(in);
			if (!isdigit(ch)) {
				break;
			}
			exponent_part = ch + (exponent_part * 10);

		} while( 1 );	

	} else {
		VIOBT_unget( in, mark);
		return -1;
	}
	
	
	*ret = make_double(int_sign, int_part, fraction_part, exponent_sign, exponent_part);
	return 0;

}
예제 #9
0
/**
 * \brief The evaluation function that calculates the parsed s-expression tree
 * \param c A constant pointer to a Cell instance, which is the root of the tree to be computed
 * \return A pointer to the Cell containing the final answer.
 */
Cell* eval(Cell* const c)
{
  if (nullp(c)) {
    error_handler("s-expression invalid: root of tree is nil");
  }

  if (intp(c) || doublep(c) || symbolp(c)){
    return deep_copy(c);
  }
  
  if (listp(c)) {
    //get car of c
    //using eval will automatically evaluate the subtree, if car(c) is itself a conspair
    Cell* car_value = eval(car(c));
    
    //if car is a symbol cell (it must, otherwise the eval() begins at wrong place)
    if (symbolp(car_value)){
      //get the symbol
      //case 1: +
      if (get_symbol(car_value) == "+"){
	
	//delete car_value as it's not needed any more
	delete car_value;

	//temporary sums variables
	double double_sum = 0;
	int int_sum = 0;
	bool sum_is_double = false;

	//Cell pointer to the current working cell
	Cell* current_cell = cdr(c);

	//iterate every cons pair until meet a nil cdr
	while (!nullp(current_cell)) {

	  //current_cell is not nil, and it should be a conspair
	  if (!listp(current_cell)) {
	    error_handler("cdr must be nil or conspair");
	  }

	  //pointer to the cell that contains the value to be added
	  //here eval could be used against a conspair or a int/double cell
	  Cell* value_cell = eval(car(current_cell));
	  
	  //deal with value_cell, see if it's int or not
	  if (intp(value_cell)) {
	    if (sum_is_double) {
	      double_sum += get_int(value_cell);
	    } else {
	      int_sum += get_int(value_cell);
	    }
	  } else if (doublep(value_cell)) {
	    //if value_cell is not a double cell
	    if (sum_is_double) {
	      double_sum += get_double(value_cell);
	    } else {
	      //migrate int_sum to double_sum and do related clean-ups
	      double_sum = int_sum;
	      int_sum = 0;
	      sum_is_double = true;
	      
	      double_sum += get_double(value_cell);
	    }
	  } else {
	    if (!nullp(value_cell)) delete value_cell;
	    error_handler("s-expression invalid: + operands invalid");
	  }
	  if (!nullp(value_cell)) delete value_cell;
	  //move current_cell forward;
	  current_cell = cdr(current_cell);
	}
	
	return sum_is_double ? make_double(double_sum) : make_int(int_sum);
      }
      //case 2: ceiling
      else if (get_symbol(car_value) == "ceiling") {
	//delete car_value as it's no longer needed
	delete car_value;

	//current working cell
	Cell* current_cell = cdr(c);

	if (nullp(current_cell) || !listp(current_cell)) error_handler("s-expression invalid: invalid ceiling operand!");

	if (!nullp(cdr(current_cell))) error_handler("s-expression invalid: ceiling on more than one operands");
	
	//take the ceiling and return
	Cell* returned_value = eval(car(current_cell));
	if (intp(returned_value)){
	  delete returned_value;
	  error_handler("s-expression invalid: ceiling on integer!");
	} else if (doublep(returned_value)){
	  int ceilinged_value = int(get_double(returned_value));
	  if (ceilinged_value < get_double(returned_value)) ++ceilinged_value;
	  delete returned_value;
	  return make_int(ceilinged_value);
	} else {
	  if(!nullp(returned_value)) delete returned_value;
	  error_handler("s-expression invalid: ceiling on symbol!");
	}
      }
      //case 3: if
      else if (get_symbol(car_value) == "if") {
	//delete car_value as it's no longer needed
	delete car_value;
	
	//temporary Cell pointers;
	Cell* condition = cdr(c);
	if (nullp(condition) || !listp(condition)) error_handler("s-expression invalid: condition is not a conspair");
	Cell* if_true = cdr(condition);
	if (nullp(if_true) || !listp(if_true)) error_handler("s-expression invalid: the true return value is not a cospair");
	Cell* if_false = cdr(if_true); 

	//directly return the second parameter if the third doesn't exist
	if (nullp(if_false)) {
	  return eval(car(if_true));
	} else {
	  if (!nullp(cdr(if_false))) error_handler("s-expression invalid: if operator on more than three operands");
	  
	  Cell* condition_cell = eval(car(condition));
	  bool flag = false;
	  
	  //retrieve values according to their types
	  if (intp(condition_cell)){
	    flag = get_int(condition_cell) ? true : false;
	  } else if (doublep(condition_cell)) {
	    flag = get_double(condition_cell) ? true : false;
	  } else if (symbolp(condition_cell)) {
	    flag = get_symbol(condition_cell)!="" ? true : false;
	  } else {
	    if(!nullp(car_value)) delete condition_cell;
	    error_handler("s-expression invalid: condition operand invalid to if");
	  }

	  if(!nullp(car_value)) delete condition_cell;
	  
	  return flag ? eval(car(if_true)) : eval(car(if_false));
	}
      } else {
	//delete car_value as it's no longer needed
	delete car_value;
	
	error_handler("s-expression invalid: operator not one of +, ceiling or if");
      }
    } else {
      //delete car_value as it's no longer needed
      if(!nullp(car_value)) delete car_value;
	
      //value_car is not a symbol cell
      error_handler("s-expression invalid: the first element of the tree/subtree is not a proper operator");
    }
  }
}
예제 #10
0
int main()
{
   TEST_SET_START("20060824103000MH","MH", "fmind2_fmaxd2");
   
   double denorm_min = hide_double(make_double(0x0000000000000001ull));
   double denorm_max = hide_double(make_double(0x000fffffffffffffull));
   double norm_min   = hide_double(make_double(0x0010000000000000ull));
   double norm_max   = hide_double(make_double(0x7fefffffffffffffull));

   double x0min = hide_double(1760.135);
   double x0max = hide_double(19355.03);

   double x1min = hide_double(-12351.9);
   double x1max = hide_double(-139.035);

   double x2min = hide_double(-1.0);
   double x2max = hide_double(0.0);

   double x3min = hide_double(nan(""));
   double x3max = hide_double(-1.0);

   double x4min = hide_double(-0.0);
   double x4max = hide_double(0.0);

   double x5min = denorm_min;
   double x5max = hide_double(1.0e-323);

   double x6min = norm_max;
   double x6max = hide_double(HUGE_VAL);

   double x7min = hide_double(-HUGE_VAL);
   double x7max = hide_double(19355.03);

   double x8min = hide_double(-HUGE_VAL);
   double x8max = hide_double(HUGE_VAL);

   double x9min = denorm_max;
   double x9max = norm_min;

   vec_double2 x0min_v = spu_splats(x0min);
   vec_double2 x0max_v = spu_splats(x0max);

   vec_double2 x1min_v = spu_splats(x1min); 
   vec_double2 x1max_v = spu_splats(x1max); 

   vec_double2 x2min_v = spu_splats(x2min); 
   vec_double2 x2max_v = spu_splats(x2max); 

   vec_double2 x3min_v = spu_splats(x3min); 
   vec_double2 x3max_v = spu_splats(x3max); 

   vec_double2 x4min_v = spu_splats(x4min); 
   vec_double2 x4max_v = spu_splats(x4max); 

   vec_double2 x5min_v = spu_splats(x5min); 
   vec_double2 x5max_v = spu_splats(x5max); 

   vec_double2 x6min_v = spu_splats(x6min); 
   vec_double2 x6max_v = spu_splats(x6max); 

   vec_double2 x7min_v = spu_splats(x7min); 
   vec_double2 x7max_v = spu_splats(x7max); 

   vec_double2 x8min_v = spu_splats(x8min); 
   vec_double2 x8max_v = spu_splats(x8max); 

   vec_double2 x9min_v = spu_splats(x9min); 
   vec_double2 x9max_v = spu_splats(x9max); 

   vec_double2 x51min_v = (vec_double2){x5min, x1min};
   vec_double2 x51max_v = (vec_double2){x5max, x1max};

   vec_double2 res_v;

   TEST_START("fmind2");
   res_v = fmind2(x0min_v, x0max_v);
   TEST_CHECK("20060824103001MH", allequal_double2( res_v, x0min_v ), 0);
   res_v = fmind2(x0max_v, x0min_v);      
   TEST_CHECK("20060824103002MH", allequal_double2( res_v, x0min_v ), 0);
   res_v = fmind2(x1min_v, x1max_v);
   TEST_CHECK("20060824103003MH", allequal_double2( res_v, x1min_v ), 0);
   res_v = fmind2(x1max_v, x1min_v);      
   TEST_CHECK("20060824103004MH", allequal_double2( res_v, x1min_v ), 0);
   res_v = fmind2(x2min_v, x2max_v);
   TEST_CHECK("20060824103005MH", allequal_double2( res_v, x2min_v ), 0);
   res_v = fmind2(x2max_v, x2min_v);      
   TEST_CHECK("20060824103006MH", allequal_double2( res_v, x2min_v ), 0);
   res_v = fmind2(x3min_v, x3max_v);
   TEST_CHECK("20060824103007MH", allequal_double2( res_v, x3max_v ), 0);
   res_v = fmind2(x3max_v, x3min_v);
   TEST_CHECK("20060824103008MH", allequal_double2( res_v, x3max_v ), 0);
   res_v = fmind2(x4min_v, x4max_v);
   TEST_CHECK("20060824103009MH", allequal_double2( res_v, x4min_v ), 0);
   res_v = fmind2(x4max_v, x4min_v);
   TEST_CHECK("20060824103010MH", allequal_double2( res_v, x4min_v ), 0);
   res_v = fmind2(x5min_v, x5max_v);
   TEST_CHECK("20060824103011MH", allequal_double2( res_v, x5min_v ), 0);
   res_v = fmind2(x5max_v, x5min_v);
   TEST_CHECK("20060824103012MH", allequal_double2( res_v, x5min_v ), 0);
   res_v = fmind2(x6min_v, x6max_v);
   TEST_CHECK("20060824103013MH", allequal_double2( res_v, x6min_v ), 0);
   res_v = fmind2(x6max_v, x6min_v);
   TEST_CHECK("20060824103014MH", allequal_double2( res_v, x6min_v ), 0);
   res_v = fmind2(x7min_v, x7max_v);
   TEST_CHECK("20060824103015MH", allequal_double2( res_v, x7min_v ), 0);
   res_v = fmind2(x7max_v, x7min_v);
   TEST_CHECK("20060824103016MH", allequal_double2( res_v, x7min_v ), 0);
   res_v = fmind2(x8min_v, x8max_v);
   TEST_CHECK("20060824103017MH", allequal_double2( res_v, x8min_v ), 0);
   res_v = fmind2(x8max_v, x8min_v);
   TEST_CHECK("20060824103018MH", allequal_double2( res_v, x8min_v ), 0);
   res_v = fmind2(x9min_v, x9max_v);
   TEST_CHECK("20060824103019MH", allequal_double2( res_v, x9min_v ), 0);
   res_v = fmind2(x9max_v, x9min_v);
   TEST_CHECK("20060824103020MH", allequal_double2( res_v, x9min_v ), 0);
   res_v = fmind2(x51min_v, x51max_v);
   TEST_CHECK("20060824103021MH", allequal_double2( res_v, x51min_v ), 0);
   res_v = fmind2(x51max_v, x51min_v);
   TEST_CHECK("20060824103022MH", allequal_double2( res_v, x51min_v ), 0);
   
   TEST_START("fmaxd2");
   res_v = fmaxd2(x0min_v, x0max_v);
   TEST_CHECK("20060824103101MH", allequal_double2( res_v, x0max_v ), 0);
   res_v = fmaxd2(x0max_v, x0min_v);      
   TEST_CHECK("20060824103102MH", allequal_double2( res_v, x0max_v ), 0);
   res_v = fmaxd2(x1min_v, x1max_v);
   TEST_CHECK("20060824103103MH", allequal_double2( res_v, x1max_v ), 0);
   res_v = fmaxd2(x1max_v, x1min_v);      
   TEST_CHECK("20060824103104MH", allequal_double2( res_v, x1max_v ), 0);
   res_v = fmaxd2(x2min_v, x2max_v);
   TEST_CHECK("20060824103105MH", allequal_double2( res_v, x2max_v ), 0);
   res_v = fmaxd2(x2max_v, x2min_v);      
   TEST_CHECK("20060824103106MH", allequal_double2( res_v, x2max_v ), 0);
   res_v = fmaxd2(x3min_v, x3max_v);
   TEST_CHECK("20060824103107MH", allequal_double2( res_v, x3max_v ), 0);
   res_v = fmaxd2(x3max_v, x3min_v);
   TEST_CHECK("20060824103108MH", allequal_double2( res_v, x3max_v ), 0);
   res_v = fmaxd2(x4min_v, x4max_v);
   TEST_CHECK("20060824103109MH", allequal_double2( res_v, x4max_v ), 0);
   res_v = fmaxd2(x4max_v, x4min_v);
   TEST_CHECK("20060824103110MH", allequal_double2( res_v, x4max_v ), 0);
   res_v = fmaxd2(x5min_v, x5max_v);
   TEST_CHECK("20060824103111MH", allequal_double2( res_v, x5max_v ), 0);
   res_v = fmaxd2(x5max_v, x5min_v);
   TEST_CHECK("20060824103112MH", allequal_double2( res_v, x5max_v ), 0);
   res_v = fmaxd2(x6min_v, x6max_v);
   TEST_CHECK("20060824103113MH", allequal_double2( res_v, x6max_v ), 0);
   res_v = fmaxd2(x6max_v, x6min_v);
   TEST_CHECK("20060824103114MH", allequal_double2( res_v, x6max_v ), 0);
   res_v = fmaxd2(x7min_v, x7max_v);
   TEST_CHECK("20060824103115MH", allequal_double2( res_v, x7max_v ), 0);
   res_v = fmaxd2(x7max_v, x7min_v);
   TEST_CHECK("20060824103116MH", allequal_double2( res_v, x7max_v ), 0);
   res_v = fmaxd2(x8min_v, x8max_v);
   TEST_CHECK("20060824103117MH", allequal_double2( res_v, x8max_v ), 0);
   res_v = fmaxd2(x8max_v, x8min_v);
   TEST_CHECK("20060824103118MH", allequal_double2( res_v, x8max_v ), 0);
   res_v = fmaxd2(x9min_v, x9max_v);
   TEST_CHECK("20060824103119MH", allequal_double2( res_v, x9max_v ), 0);
   res_v = fmaxd2(x9max_v, x9min_v);
   TEST_CHECK("20060824103120MH", allequal_double2( res_v, x9max_v ), 0);
   res_v = fmaxd2(x51min_v, x51max_v);
   TEST_CHECK("20060824103121MH", allequal_double2( res_v, x51max_v ), 0);
   res_v = fmaxd2(x51max_v, x51min_v);
   TEST_CHECK("20060824103122MH", allequal_double2( res_v, x51max_v ), 0);
   
   TEST_SET_DONE();
   
   TEST_EXIT();
}