Ejemplo n.º 1
0
int
main(void)
{
    ngcomplex_t *c = NULL;
    double *d = NULL;
    short int t1;
    short int t2;
    int n1, n2;
    double eps = DBL_EPSILON;

    cp_err = stderr;
    n1 = 9;
    t1 = VF_COMPLEX;
    c = alloc_c(n1);

    realpart(c[0]) =  0.0;
    imagpart(c[0]) = +1.0;  /* i^1 */
    realpart(c[1]) = -1.0;
    imagpart(c[1]) =  0.0;  /* i^2 */
    realpart(c[2]) =  0.0;
    imagpart(c[2]) = -1.0;  /* i^3 */
    realpart(c[3]) = +1.0;
    imagpart(c[3]) =  0.0;  /* i^4 */
    realpart(c[4]) =  0.0;
    imagpart(c[4]) = +1.0;  /* i^5 */
    realpart(c[5]) = +1.0;
    imagpart(c[5]) =  0.0;  /* i^4 */
    realpart(c[6]) =  0.0;
    imagpart(c[6]) = -1.0;  /* i^3 */
    realpart(c[7]) = -1.0;
    imagpart(c[7]) =  0.0;  /* i^2 */
    realpart(c[8]) =  0.0;
    imagpart(c[8]) = +1.0;  /* i^1 */

    d = (double *) cx_cph((void *) c, t1, n1, &n2, &t2);

    if ( eq_p(1*M_PI/2, d[0], eps) &&
            eq_p(2*M_PI/2, d[1], eps) &&
            eq_p(3*M_PI/2, d[2], eps) &&
            eq_p(4*M_PI/2, d[3], eps) &&
            eq_p(5*M_PI/2, d[4], eps) &&
            eq_p(4*M_PI/2, d[5], eps) &&
            eq_p(3*M_PI/2, d[6], eps) &&
            eq_p(2*M_PI/2, d[7], eps) &&
            eq_p(1*M_PI/2, d[8], eps) )
        return 0;
    else
        return 1;
}
Ejemplo n.º 2
0
Archivo: table.c Proyecto: Archs/scheme
static void primop_table_get(long argc) {
    object tbl = *sp++;
    object key = *sp;
    object *pBindings;
    long i, imax;
    TYPE_CHECK(TABLE_P(tbl),1,"table",tbl);
    pBindings = TABLE_ELEMENTS(tbl);
    imax = TABLE_COUNT(tbl);
    while (imax-- > 0) {
      if (eq_p(*pBindings++, key)) {
	*sp = *pBindings;
	return;
      } else
	pBindings++;
    }
    *sp = false_object;
}
Ejemplo n.º 3
0
static void primop_eq_p(long argc) {
	object tmp = *sp++;
	*sp = (eq_p(tmp,*sp))? true_object : false_object;
}
Ejemplo n.º 4
0
int eqv_p(object o1, object o2) {
	if (eq_p(o1,o2)) return 1;
	if (NUMBER_P(o1) && NUMBER_P(o2))
		return (the_double(1,o1) == the_double(2,o2))? 1 : 0;
	return 0;
}
Ejemplo n.º 5
0
TEST_F (test_eq_p, string)
{
    EXPECT_FALSE (eq_p (r_string_new (r, "a"), r_string_new (r, "a")));
}
Ejemplo n.º 6
0
TEST_F (test_eq_p, null)
{
    EXPECT_TRUE (eq_p (R_NULL, R_NULL));
}
Ejemplo n.º 7
0
TEST_F (test_eq_p, character)
{
    EXPECT_TRUE (eq_p (r_char_to_sexp ('a'), r_char_to_sexp ('a')));
}
Ejemplo n.º 8
0
TEST_F (test_eq_p, symbol)
{
    EXPECT_TRUE (eq_p (r_intern (r, "a"), r_intern (r, "a")));
}