/* Type variable */ vtype *vcomplex_type = NULL; /* Declare the complex number type */ vtype * complex_declare(void) { if (vcomplex_type == NULL) { vcomplex_type = v_create("COMPLEX", "C"); v_copy_func(vcomplex_type, (void *) complex_copy); v_next_func(vcomplex_type, complex_next); v_print_func(vcomplex_type, complex_print); v_read_func(vcomplex_type, (void *) complex_read); v_write_func(vcomplex_type, complex_write); v_freeze_func(vcomplex_type, complex_freeze); v_thaw_func(vcomplex_type, (void *) complex_thaw); v_destroy_func(vcomplex_type, complex_destroy); v_traverse_func(vcomplex_type, complex_traverse); } return vcomplex_type; } /* Create and return a new complex number */ vcomplex * complex_create(double real, double imag) { static vheader *hdr = NULL; vcomplex *c; if (hdr == NULL) { complex_declare(); hdr = v_header(vcomplex_type); } c = V_ALLOC(vcomplex, 1); c->hdr = *hdr; c->real = real; c->imag = imag; return c; }