Révision 139

pobysoC-4.0/src/pobyso.c (revision 139)
39 39
  sollya_lib_autoprint(objSo, NULL);
40 40
} /* End pobyso_autoprint. */
41 41

  
42
int
43
pobyso_evaluate_constant(pobyso_func_exp_t functionSo,
44
                          mpfr_t argumentMp,
45
                          mpfr_t evaluationMp)
46
{
47
  int outcome = 0;
48
  sollya_obj_t argumentSo   = NULL;
49
  sollya_obj_t evaluationSo = NULL;
50
  mpfr_t evaluationTmpMp    = NULL;
51

  
52
  /* Test argument. */
53
  if (functionSo == NULL || argumentMp == NULL || evaluationMp == NULL)
54
  {
55
    pobyso_error_message("pobyso_evaluate_constant",
56
                        "NULL_POINTER_ARGUMENT",
57
                        "One of the arguments is a NULL pointer");
58
    return 1;
59
  }
60
  if (! sollya_lib_obj_is_function(functionSo))
61
  {
62
    pobyso_error_message("pobyso_evaluate_constant",
63
                        "INVALID_TYPE_ARGUMENT",
64
                     "The functionSo argument is not a functional expression");
65
    return 1;
66
  }
67
  argumentSo    = sollya_lib_constant(argumentMp);
68
  evaluationSo  = sollya_lib_evaluate(functionSo, argumentSo);
69
  //TODO: finish this function!
70
  // Check evaluationSo.
71
  // Depending on its type and value, convert to a MPFR number and/or
72
  // return an error value.
73
  sollya_lib_clear_obj(argumentSo);
74
  sollya_lib_clear_obj(evaluationSo);
75
  return 0;
76
}
77
/* End pobyso_evaluate_constant. */
78

  
42 79
/* @see pobyso.h#pobyso_get_verbosity */
43 80
int
44 81
pobyso_get_verbosity()
......
72 109
    return 0;
73 110
  }
74 111
  initial_verbosity_level = pobyso_set_verbosity_off();
75

  
112
  /* In Sollya, constant are functional expressions. */
76 113
  if (! sollya_lib_obj_is_function(obj_to_test))
77 114
  {
78 115
    pobyso_set_verbosity_to(initial_verbosity_level);
......
82 119
  /* Call to previous Sollya function resets verbosity. */
83 120
  /* Todo: change verbosity suppression strategy with a message call back. */
84 121
  pobyso_set_verbosity_off();
122
  /* Try to convert the would be constant into an MPFR number. */
123
  /* If OK, we indeed have a constant. If the conversion fails, return 0. */
85 124
  test = sollya_lib_get_constant(dummy, obj_to_test);
86 125
  pobyso_set_verbosity_to(initial_verbosity_level);
87 126
  if (test)
......
99 138
  }
100 139
  else
101 140
  {
141
    mpfr_clear(dummy);
102 142
    return 0;
103 143
  }
104 144
} /* End pobyso_is_constant_expression. */
pobysoC-4.0/src/pobyso.h (revision 139)
30 30
#define POBYSO_ABSOLUTE (1)
31 31
#define POBYSO_RELATIVE (2)
32 32

  
33
#define POBYSO_UNFAITHFULL (129)
34
#define POBYSO_NAN (130)
35

  
33 36
#define POBYSO_OFF (0)
34 37
#define POBYSO_ON (1)
35 38

  
......
74 77
pobyso_get_verbosity();
75 78

  
76 79
/**
80
 * Evaluate an expression for a constant.
81
 *
82
 * The result of the evaluation must be "inited" by the caller.
83
 * Its contents is modified only if the evaluation yields some usefull
84
 * result.
85
 *@param functionSo : the function to evaluate;
86
 *@param argumentMp : the argument used for the evaluation;
87
 *@param evalutionMp: the result of the evalution.
88
 *@retun 0 if 0K, 1 in case of a "generic" error, POBYSO_UNFAITHFULL if the
89
 *       result is the mean of the two bound of the range encompassing it
90
 *       and POBYSO_NAN if the result of the evaluation is not a number.
91
 */
92
int
93
pobyso_evaluate_constant(pobyso_func_exp_t functionSo,
94
                         mpfr_t argumentMp,
95
                         mpfr_t evaluationMp);
96
/**
77 97
 * Check if a sollya object is a constant expression.
78 98
 * @return 1 if true and zero otherwise
79 99
 */

Formats disponibles : Unified diff