pt_lorder_type<T> t_lorder(const std::vector<std::string> &names) const { using term_type = typename T::term_type; const symbol_set::positions p(this->m_symbol_set,symbol_set(names.begin(),names.end())); auto it = std::min_element(this->m_container.begin(),this->m_container.end(),[this,&p,&names](const term_type &t1, const term_type &t2) { return this->get_t_lorder(t1,names,p,this->m_symbol_set) < this->get_t_lorder(t2,names,p,this->m_symbol_set); }); return (it == this->m_container.end()) ? pt_lorder_type<T>(0) : get_t_lorder(*it,names,p,this->m_symbol_set); }
VALUE csymbol_init(VALUE self, VALUE name_or_id) { char *str_ptr; switch (TYPE(name_or_id)) { case T_STRING: str_ptr = StringValueCStr(name_or_id); break; case T_SYMBOL: str_ptr = rb_id2name(rb_to_id(name_or_id)); break; default: rb_raise(rb_eTypeError, "wrong argument type %s (expected Symbol or String)", rb_obj_classname(name_or_id)); } basic_struct *this; Data_Get_Struct(self, basic_struct, this); symbol_set(this, str_ptr); return self; }
void symbol_set_6(Symbol *sym, float v0, float v1, float v2, float v3, float v4, float v5) { float val[6] = {v0, v1, v2, v3, v4, v5}; symbol_set(sym, val, 6); }
void symbol_set_5(Symbol *sym, float v0, float v1, float v2, float v3, float v4) { float val[5] = {v0, v1, v2, v3, v4}; symbol_set(sym, val, 5); }
void symbol_set_4(Symbol *sym, float v0, float v1, float v2, float v3) { float val[4] = {v0, v1, v2, v3}; symbol_set(sym, val, 4); }
void symbol_set_3(Symbol *sym, float v0, float v1, float v2) { float val[3] = {v0, v1, v2}; symbol_set(sym, val, 3); }
void symbol_set_2(Symbol *sym, float v0, float v1) { float val[2] = {v0, v1}; symbol_set(sym, val, 2); }
void symbol_set_1(Symbol *sym, float v0) { float val[1] = {v0}; symbol_set(sym, val, 1); }
void test_cwrapper() { char* s; basic x, y, z; basic_init(x); basic_init(y); basic_init(z); symbol_set(x, "x"); symbol_set(y, "y"); symbol_set(z, "z"); s = basic_str(x); printf("Symbol : %s\n", s); basic_str_free(s); basic e; basic_init(e); integer_set_ui(e, 123); s = basic_str(e); printf("Integer : %s\n", s); basic_str_free(s); integer_set_ui(e, 456); basic_add(e, e, x); basic_mul(e, e, y); basic_div(e, e, z); s = basic_str(e); printf("Basic : %s\n", s); basic_str_free(s); basic_diff(e, e, z); s = basic_str(e); printf("Basic : %s\n", s); basic_str_free(s); rational_set_ui(e, 100, 47); s = basic_str(e); printf("Rational : %s\n", s); printf("Is_a_Symbol %s: %d\n", s, is_a_Symbol(e)); printf("Is_a_Rational %s: %d\n", s, is_a_Rational(e)); printf("Is_a_Integer %s: %d\n", s, is_a_Integer(e)); integer_set_ui(e, 123); printf("integer_get_ui 123: %lu\n", integer_get_ui(e)); integer_set_si(e, -123); printf("integer_get_si -123: %ld\n", integer_get_si(e)); mpz_t test; mpz_init(test); integer_get_mpz(test, e); printf("integer_get_mpz(e): %ld\n", mpz_get_ui(test)); mpz_clear(test); basic_free(e); basic_free(x); basic_free(y); basic_free(z); basic_str_free(s); }