Commit 112f3bcc authored by Jiri (George) Lebl's avatar Jiri (George) Lebl Committed by George Lebl

remove the dependence on the MPF compat layer. Inline a few more


Fri Feb 27 14:42:12 2009  Jiri (George) Lebl <jirka@5z.com>

	* src/mpwrap.[ch], src/funclib.c: remove the dependence on the MPF
	  compat layer.  Inline a few more functions.  Implement mpwl_eql
	  to make comparisons of rationals quicker.  Remove certain old
	  gmp/mpfr bug workarounds, a bit of cleanup

	* src/matop.c: in the mul_sub_row, cache the tmp variable for
	  greater speed.


svn path=/trunk/; revision=742
parent a26fdaac
Fri Feb 27 14:42:12 2009 Jiri (George) Lebl <jirka@5z.com>
* src/mpwrap.[ch], src/funclib.c: remove the dependence on the MPF
compat layer. Inline a few more functions. Implement mpwl_eql
to make comparisons of rationals quicker. Remove certain old
gmp/mpfr bug workarounds, a bit of cleanup
* src/matop.c: in the mul_sub_row, cache the tmp variable for
greater speed.
Thu Feb 26 18:40:16 2009 Jiri (George) Lebl <jirka@5z.com>
* src/calc.c: don't kill newlines in descriptions. This is no longer
......
......@@ -1322,7 +1322,7 @@ ErrorFunction_op (GelCtx *ctx, GelETree * * a, gboolean *exception)
MPW_MPF_REAL (num, a[0]->val.value, tmp);
mpf_init (ret);
mpfr_init (ret);
mpfr_erf (ret, num, GMP_RNDN);
MPW_MPF_KILL (num, tmp);
......@@ -1360,7 +1360,7 @@ RiemannZeta_op (GelCtx *ctx, GelETree * * a, gboolean *exception)
MPW_MPF_REAL (num, a[0]->val.value, tmp);
mpf_init (ret);
mpfr_init (ret);
mpfr_zeta (ret, num, GMP_RNDN);
MPW_MPF_KILL (num, tmp);
......@@ -1397,7 +1397,7 @@ GammaFunction_op (GelCtx *ctx, GelETree * * a, gboolean *exception)
MPW_MPF_REAL (num, a[0]->val.value, tmp);
mpf_init (ret);
mpfr_init (ret);
mpfr_gamma (ret, num, GMP_RNDN);
MPW_MPF_KILL (num, tmp);
......
......@@ -341,31 +341,37 @@ static gboolean
mul_sub_row (GelCtx *ctx, GelMatrixW *m, int row, mpw_t mul, int row2)
{
int i, w;
mpw_t tmp;
static mpw_t tmp;
static gboolean tmp_inited = FALSE;
gboolean ret = TRUE;
/* no need for this, only used within gauss and matrix is already private
gel_matrixw_make_private(m);*/
mpw_init(tmp);
if G_UNLIKELY ( ! tmp_inited) {
mpw_init(tmp);
tmp_inited = TRUE;
}
w = gel_matrixw_width(m);
for (i = 0; i < w; i++) {
GelETree *t = gel_matrixw_get_index(m,i,row);
if (t && ! mpw_zero_p (t->val.value)) {
GelETree *t2 = gel_matrixw_get_index(m,i,row2);
mpw_mul(tmp,t->val.value,mul);
if(!t2) {
if (t2 == NULL) {
mpw_neg(tmp,tmp);
gel_matrixw_set_index(m,i,row2) = t2 = gel_makenum_use(tmp);
t2 = gel_makenum_use(tmp);
gel_matrixw_set_index(m,i,row2) = t2;
mpw_init(tmp);
} else if ( ! mpw_is_complex_float (tmp) &&
mpw_symbolic_eql (t2->val.value, tmp)) {
gel_freetree (t2);
gel_matrixw_set_index(m,i,row2) = NULL;
} else {
mpw_sub(t2->val.value,t2->val.value,tmp);
if (mpw_exact_zero_p (t2->val.value)) {
gel_freetree (t2);
gel_matrixw_set_index(m,i,row2) = NULL;
}
mpw_sub (t2->val.value,
t2->val.value, tmp);
}
if (ctx->modulo != NULL) {
if (ctx->modulo != NULL && t2 != NULL) {
gel_mod_node (ctx, t2);
/* can't mod so we have a singular matrix / system */
if (t2 != NULL && t2->type != VALUE_NODE)
......@@ -373,7 +379,6 @@ mul_sub_row (GelCtx *ctx, GelMatrixW *m, int row, mpw_t mul, int row2)
}
}
}
mpw_clear(tmp);
return ret;
}
......
This diff is collapsed.
......@@ -30,8 +30,6 @@
/* FIXME: we may need the same as above */
#include <mpfr.h>
/* FIXME: get rid of mpf usage altogether */
#include <mpf2mpfr.h>
enum {
......@@ -91,10 +89,27 @@ enum {
void mpw_set_default_prec(unsigned long int i);
/*initialize a number*/
void mpw_init(mpw_ptr op);
void mpw_init_set(mpw_ptr rop,mpw_ptr op);
/* Maybe it is overkill to try to keep bin compat? */
void mpw_init(mpw_ptr op);
static inline void
mpw_init_inline (mpw_ptr op)
{
op->r = gel_zero;
gel_zero->alloc.usage++;
op->i = gel_zero;
gel_zero->alloc.usage++;
}
#define mpw_init(op) mpw_init_inline(op)
/* don't try to decomplexify the number */
void mpw_init_set_no_uncomplex (mpw_ptr rop, mpw_ptr op);
#define mpw_init_set_no_uncomplex(rop,op) \
{ (rop)->r = (op)->r; \
(rop)->r->alloc.usage++; \
(rop)->i = (op)->i; \
(rop)->i->alloc.usage++; }
/*clear memory held by number*/
void mpw_clear(mpw_ptr op);
......@@ -285,12 +300,20 @@ void mpw_set_str (mpw_ptr rop, const char *s, int base);
gboolean mpw_is_complex(mpw_ptr op);
gboolean mpw_is_integer(mpw_ptr op);
gboolean mpw_is_complex_integer(mpw_ptr op);
gboolean mpw_is_rational(mpw_ptr op);
gboolean mpw_is_rational_or_integer(mpw_ptr op);
gboolean mpw_is_complex_rational_or_integer(mpw_ptr op);
gboolean mpw_is_float(mpw_ptr op);
gboolean mpw_is_complex_float(mpw_ptr op);
#define mpw_is_complex_float(op) \
( ((op)->r->type == MPW_FLOAT) || \
(MPW_IS_COMPLEX (op) && ((op)->i->type == MPW_FLOAT)) )
#define mpw_is_complex_rational_or_integer(op) \
( ((op)->r->type <= MPW_RATIONAL) && \
( ! MPW_IS_COMPLEX (op) || ((op)->i->type <= MPW_RATIONAL)) )
#define mpw_is_complex_integer(op) \
( ((op)->r->type == MPW_INTEGER) && \
( ! MPW_IS_COMPLEX (op) || ((op)->i->type == MPW_INTEGER)) )
void mpw_im(mpw_ptr rop, mpw_ptr op);
void mpw_re(mpw_ptr rop, mpw_ptr op);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment