Révision 133 pobysoC-4.0/src/pobyso.c

pobyso.c (revision 133)
42 42
  va_end(va);
43 43
} /* End pobyso_autoprint. */
44 44

  
45
/* @see pobyso.h#pobyso_is_constant_expression*/
46
int
47
pobyso_is_constant_expression(sollya_obj_t obj_to_test)
48
{
49
  mpfr_t dummy;
50
  int test;
51
  sollya_obj_t verbosity_level      = NULL;
52
  /* Test argument. */
53
  if (obj_to_test == NULL)
54
  {
55
    pobyso_error_message("pobyso_parse_string",
56
                        "NULL_POINTER_ARGUMENT",
57
                        "The expression is a NULL pointer");
58
    return 0;
59
  }
60
  verbosity_level = pobyso_set_verbosity_off();
45 61

  
62
  if (! sollya_lib_obj_is_function(obj_to_test))
63
  {
64
    pobyso_set_verbosity_to(verbosity_level);
65
    sollya_lib_clear_obj(verbosity_level);
66
    return 0;
67
  }
68
  mpfr_init2(dummy,64);
69
  /* Call to previous Sollya function resets verbosity. */
70
  verbosity_level = pobyso_set_verbosity_off();
71
  test = sollya_lib_get_constant(dummy, obj_to_test);
72
  mpfr_clear(dummy);
73
  pobyso_set_verbosity_to(verbosity_level);
74
  sollya_lib_clear_obj(verbosity_level);
75
  return test;
76
} /* End pobyso_is_constant_expression. */
77

  
78
/** @see pobyso.h#pobyso_new_monomial. */
79
pobyso_func_exp_t
80
pobyso_new_monomial(pobyso_func_exp_t coefficientSa, long degree)
81
{
82
  sollya_obj_t degreeSa   = NULL;
83
  sollya_obj_t varToPowSa = NULL;
84
  sollya_obj_t monomialSa = NULL;
85
  if (coefficientSa == NULL)
86
  {
87
    pobyso_error_message("pobyso_parse_string",
88
                        "NULL_POINTER_ARGUMENT",
89
                        "The expression is a NULL pointer");
90
    return sollya_lib_error();
91
  }
92
  if (! pobyso_is_constant_expression(coefficientSa))
93
  {
94
    return sollya_lib_error();
95
  }
96
  if (degree < 0)
97
  {
98
    return sollya_lib_error();
99
  }
100
  degreeSa    = sollya_lib_constant_from_int64(degree);
101
  varToPowSa  = sollya_lib_build_function_pow(sollya_lib_free_variable(),
102
                                              degreeSa);
103
  monomialSa = sollya_lib_mul(coefficientSa,varToPowSa);
104
  sollya_lib_clear_obj(varToPowSa);
105
  return monomialSa;
106
} /* End pobyso_new_monomial. */
107

  
46 108
/* @see pobyso.h#pobyso_parse_string*/
47 109
pobyso_func_exp_t
48 110
pobyso_parse_string(const char* expression)

Formats disponibles : Unified diff