# Ticket #16997: infinity.patch

File infinity.patch, 4.9 KB (added by jdemeyer, 7 years ago)

Removed patch

• ## doc/usersch4.tex

commit 56a75c6789284da3a1e0cbaca1254ffcb7c43423
Author: Jeroen Demeyer <jdemeyer@cage.ugent.be>
Date:   Mon Sep 22 17:20:12 2014 +0200

Enable basic arithmetic with t_INFINITY

diff --git a/doc/usersch4.tex b/doc/usersch4.tex
index dde26b6..1592650 100644
 a variadic, $0$ else. This type has a single \typ{INT} component, which is either $1$ or $-1$, corresponding to $+\infty$ and $-\infty$ respectively. \fun{GEN}{mkmoo}{} returns $-\infty$ \fun{GEN}{mkmoo}{} returns $-\infty$. \fun{GEN}{mkoo}{} returns $\infty$ \fun{GEN}{mkoo}{} returns $\infty$. \fun{GEN}{mksoo}{long s} returns $\infty$ if $s \geq 0$ and $-\infty$ otherwise. \fun{long}{inf_get_sign}{GEN x} returns $1$ if $x$ is $+\infty$, and $-1$ if $x$ is $-\infty$.
• ## src/basemath/gen1.c

diff --git a/src/basemath/gen1.c b/src/basemath/gen1.c
index e272eb5..1464e3c 100644
 a add_rfrac_scal(GEN y, GEN x) static GEN add_scal(GEN y, GEN x, long ty) { long tx; switch(ty) { case t_POL: return RgX_Rg_add(y, x); case t_SER: return add_ser_scal(y, x); case t_RFRAC: return add_rfrac_scal(y, x); case t_INFINITY: tx = typ(x); if (tx == t_INT || tx == t_REAL || tx == t_FRAC) return mksoo(inf_get_sign(y)); break; case t_COL: return RgC_Rg_add(y, x); case t_VEC: if (isintzero(x)) return gcopy(y); gadd(GEN x, GEN y) if (lx == 1) return cgetg(1, t_MAT); if (lgcols(y) != lgcols(x)) pari_err_OP("+",x,y); return RgM_add(x,y); case t_INFINITY: if (inf_get_sign(x) == inf_get_sign(y)) return mksoo(inf_get_sign(x)); pari_err_OP("+",x,y); default: pari_err_TYPE2("+",x,y); } gsub(GEN x, GEN y) return RgM_sub(x,y); } case t_RFRAC: case t_SER: break; case t_INFINITY: if (inf_get_sign(x) != inf_get_sign(y)) return mksoo(inf_get_sign(x)); pari_err_OP("+",x,y); default: pari_err_TYPE2("+",x,y); } mul_rfrac_scal(GEN n, GEN d, GEN x) static GEN mul_scal(GEN y, GEN x, long ty) { int s; switch(ty) { case t_POL: mul_scal(GEN y, GEN x, long ty) return RgX_Rg_mul(y, x); case t_SER: return mul_ser_scal(y, x); case t_RFRAC: return mul_rfrac_scal(gel(y,1),gel(y,2), x); case t_INFINITY: s = gsigne(x) * inf_get_sign(y); if (!s) pari_err_OP("*",x,y); return mksoo(s); case t_QFI: case t_QFR: if (typ(x) == t_INT && gequal1(x)) return gcopy(y); /* fall through */ } gmul(GEN x, GEN y) } return z; case t_INFINITY: return mksoo(inf_get_sign(x) * inf_get_sign(y)); default: pari_err_TYPE2("*",x,y); GEN gdiv(GEN x, GEN y) { long tx = typ(x), ty = typ(y), lx, ly, vx, vy, i; int s; pari_sp av, tetpil; GEN z, p1, p2; gdiv(GEN x, GEN y) return z; case t_LIST: case t_STR: case t_VECSMALL: case t_CLOSURE: pari_err_TYPE2("/",x,y); case t_INFINITY: s = inf_get_sign(x) * gsigne(y); if (!s) pari_err_INV("/", y); return mksoo(s); } vy = gvar(y);
• ## src/basemath/gen2.c

diff --git a/src/basemath/gen2.c b/src/basemath/gen2.c
index 0a94fc4..d85cfda 100644
 a gneg(GEN x) case t_VEC: return RgV_neg(x); case t_COL: return RgC_neg(x); case t_MAT: return RgM_neg(x); case t_INFINITY: return inf_get_sign(x) == 1? mkmoo(): mkoo(); case t_INFINITY: return mksoo(-inf_get_sign(x)); default: pari_err_TYPE("gneg",x); return NULL; /* not reached */ gneg_i(GEN x) gel(y,1) = gneg_i(gel(x,1)); gel(y,2) = gel(x,2); break; case t_INFINITY: return mksoo(-inf_get_sign(x)); default: pari_err_TYPE("gneg_i",x); return NULL; /* not reached */
diff --git a/src/headers/paridecl.h b/src/headers/paridecl.h
index 7e02467..b4ac1c2 100644
diff --git a/src/headers/pariinl.h b/src/headers/pariinl.h
index 9a67a02..6912ae1 100644