From 251c2a8ca169c9dad1cdef582953311460ecb4c0 Mon Sep 17 00:00:00 2001 From: Richard Kreckel Date: Thu, 1 Jan 2004 15:59:30 +0000 Subject: [PATCH] 2004-01-01 Richard B. Kreckel * include/cln/univpoly.h, include/cln/univpoly_complex.h, include/cln//univpoly_integer.h, include/cln/univpoly_modint.h, include/cln/univpoly_rational.h, include/cln/univpoly_real.h, src/polynomial/elem/cl_UP_GF2.h, src/polynomial/elem/cl_UP_MI.h, src/polynomial/elem/cl_UP_gen.h, src/polynomial/elem/cl_UP_no_ring.cc, src/polynomial/elem/cl_UP_number.h (ldegree): New function. * doc/cln.tex: Document `ldegree'. --- ChangeLog | 19 ++++++++++++++++++- README | 2 +- configure.ac | 4 ++-- doc/cln.tex | 11 ++++++++--- include/cln/univpoly.h | 17 +++++++++++++++++ include/cln/univpoly_complex.h | 4 ++++ include/cln/univpoly_integer.h | 4 ++++ include/cln/univpoly_modint.h | 4 ++++ include/cln/univpoly_rational.h | 4 ++++ include/cln/univpoly_real.h | 4 ++++ src/base/cl_free.cc | 2 +- src/polynomial/elem/cl_UP_GF2.h | 1 + src/polynomial/elem/cl_UP_MI.h | 13 +++++++++++++ src/polynomial/elem/cl_UP_gen.h | 12 ++++++++++++ src/polynomial/elem/cl_UP_no_ring.cc | 6 ++++++ src/polynomial/elem/cl_UP_number.h | 13 +++++++++++++ 16 files changed, 112 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1cefca2..87d8e0f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2004-01-01 Richard B. Kreckel + + * include/cln/univpoly.h, include/cln/univpoly_complex.h, + include/cln//univpoly_integer.h, include/cln/univpoly_modint.h, + include/cln/univpoly_rational.h, include/cln/univpoly_real.h, + src/polynomial/elem/cl_UP_GF2.h, src/polynomial/elem/cl_UP_MI.h, + src/polynomial/elem/cl_UP_gen.h, src/polynomial/elem/cl_UP_no_ring.cc, + src/polynomial/elem/cl_UP_number.h (ldegree): New function. + * doc/cln.tex: Document `ldegree'. + 2003-12-29 Richard B. Kreckel Rework of autoconfiscation infrastructure @@ -34,7 +44,14 @@ * examples/perfnum.cc: update to presumed 40th Mersenne prime. -2003-08-06 Richard Kreckel +2003-11-20 Christian Bauer + + Added pkg-config support + * cln.pc.in: New file. + * Makefile.in: Take care of cln.pc. + * configure.ac: Likewise. + +2003-08-06 Richard B. Kreckel * src/numtheory/cl_nt_sqrtmodp.cc: #undef _R. Reported by Andrew Rechnitzer . diff --git a/README b/README index bdc51b4..d043fa0 100644 --- a/README +++ b/README @@ -1,7 +1,7 @@ Class Library for Numbers Copyright (c) Bruno Haible 1988-2002 -Copyright (c) Richard Kreckel 2000-2003 +Copyright (c) Richard Kreckel 2000-2004 GPL diff --git a/configure.ac b/configure.ac index a52b58c..d6ba968 100644 --- a/configure.ac +++ b/configure.ac @@ -78,8 +78,8 @@ dnl * if any functions/classes have been added, removed or changed, increment dnl CL_CURRENT and set CL_REVISION to 0, dnl * if any functions/classes have been added, increment CL_AGE, dnl * if backwards compatibility has been broken, set CL_AGE to 0. -CL_CURRENT=2 -CL_REVISION=5 +CL_CURRENT=3 +CL_REVISION=0 CL_AGE=0 dnl make substitutions AC_SUBST(CL_CURRENT) diff --git a/doc/cln.tex b/doc/cln.tex index a6c1975..63bdd08 100644 --- a/doc/cln.tex +++ b/doc/cln.tex @@ -32,10 +32,10 @@ This file documents @sc{cln}, a Class Library for Numbers. Published by Bruno Haible, @code{} and -Richard Kreckel, @code{}. +Richard B. Kreckel, @code{}. Copyright (C) Bruno Haible 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002. -Copyright (C) Richard Kreckel 2000, 2001, 2002. +Copyright (C) Richard B. Kreckel 2000, 2001, 2002, 2003, 2004. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice @@ -3092,7 +3092,7 @@ This returns @code{0 in R}, a polynomial of degree -1. @item cl_UP R->one() @cindex @code{one ()} -This returns @code{1 in R}, a polynomial of degree <= 0. +This returns @code{1 in R}, a polynomial of degree == 0. @item cl_UP R->canonhom (const cl_I& x) @cindex @code{canonhom ()} @@ -3174,6 +3174,11 @@ Returns true if @code{x} is @code{0 in R}. @cindex @code{degree ()} Returns the degree of the polynomial. The zero polynomial has degree @code{-1}. +@item sintL ldegree (const cl_UP& x) +@cindex @code{degree ()} +Returns the low degree of the polynomial. This is the degree of the first +non-vanishing polynomial coefficient. The zero polynomial has ldegree @code{-1}. + @item cl_ring_element coeff (const cl_UP& x, uintL index) @cindex @code{coeff ()} Returns the coefficient of @code{X^index} in the polynomial @code{x}. diff --git a/include/cln/univpoly.h b/include/cln/univpoly.h index 23bd033..7547c06 100644 --- a/include/cln/univpoly.h +++ b/include/cln/univpoly.h @@ -147,6 +147,8 @@ struct _cl_univpoly_modulops { struct _cl_univpoly_polyops { // degree sintL (* degree) (cl_heap_univpoly_ring* R, const _cl_UP& x); + // low degree + sintL (* ldegree) (cl_heap_univpoly_ring* R, const _cl_UP& x); // monomial const _cl_UP (* monomial) (cl_heap_univpoly_ring* R, const cl_ring_element& x, uintL e); // coefficient (0 if index>degree) @@ -212,6 +214,8 @@ public: { return modulops->scalmul(this,x,y); } sintL _degree (const _cl_UP& x) { return polyops->degree(this,x); } + sintL _ldegree (const _cl_UP& x) + { return polyops->ldegree(this,x); } const _cl_UP _monomial (const cl_ring_element& x, uintL e) { return polyops->monomial(this,x,e); } const cl_ring_element _coeff (const _cl_UP& x, uintL index) @@ -296,6 +300,11 @@ public: if (!(x.ring() == this)) cl_abort(); return _degree(x); } + sintL ldegree (const cl_UP& x) + { + if (!(x.ring() == this)) cl_abort(); + return _ldegree(x); + } const cl_UP monomial (const cl_ring_element& x, uintL e) { return cl_UP(this,_monomial(x,e)); @@ -415,6 +424,10 @@ inline const cl_UP operator* (const cl_UP& x, const cl_ring_element& y) inline sintL degree (const cl_UP& x) { return x.ring()->degree(x); } +// Low degree. +inline sintL ldegree (const cl_UP& x) + { return x.ring()->ldegree(x); } + // Coefficient. inline const cl_ring_element coeff (const cl_UP& x, uintL index) { return x.ring()->coeff(x,index); } @@ -585,6 +598,10 @@ class cl_heap_univpoly_specialized_ring : public cl_heap_univpoly_ring { { return cl_heap_univpoly_ring::degree(x); } + sintL ldegree (const cl_UP_specialized& x) + { + return cl_heap_univpoly_ring::ldegree(x); + } const cl_UP_specialized monomial (const T& x, uintL e) { return The2(cl_UP_specialized)(cl_heap_univpoly_ring::monomial(cl_ring_element(cl_C_ring??,x),e)); diff --git a/include/cln/univpoly_complex.h b/include/cln/univpoly_complex.h index 5de6dac..6b8355b 100644 --- a/include/cln/univpoly_complex.h +++ b/include/cln/univpoly_complex.h @@ -116,6 +116,10 @@ class cl_heap_univpoly_complex_ring : public cl_heap_univpoly_ring { { return cl_heap_univpoly_ring::degree(x); } + sintL ldegree (const cl_UP_N& x) + { + return cl_heap_univpoly_ring::ldegree(x); + } const cl_UP_N monomial (const cl_N& x, uintL e) { return The2(cl_UP_N)(cl_heap_univpoly_ring::monomial(cl_ring_element(cl_C_ring,x),e)); diff --git a/include/cln/univpoly_integer.h b/include/cln/univpoly_integer.h index d227fa5..ae9db0e 100644 --- a/include/cln/univpoly_integer.h +++ b/include/cln/univpoly_integer.h @@ -115,6 +115,10 @@ class cl_heap_univpoly_integer_ring : public cl_heap_univpoly_ring { { return cl_heap_univpoly_ring::degree(x); } + sintL ldegree (const cl_UP_I& x) + { + return cl_heap_univpoly_ring::ldegree(x); + } const cl_UP_I monomial (const cl_I& x, uintL e) { return The2(cl_UP_I)(cl_heap_univpoly_ring::monomial(cl_ring_element(cl_I_ring,x),e)); diff --git a/include/cln/univpoly_modint.h b/include/cln/univpoly_modint.h index 4fcd1cd..e312f06 100644 --- a/include/cln/univpoly_modint.h +++ b/include/cln/univpoly_modint.h @@ -107,6 +107,10 @@ class cl_heap_univpoly_modint_ring : public cl_heap_univpoly_ring { { return cl_heap_univpoly_ring::degree(x); } + sintL ldegree (const cl_UP_MI& x) + { + return cl_heap_univpoly_ring::ldegree(x); + } const cl_UP_MI monomial (const cl_MI& x, uintL e) { return The2(cl_UP_MI)(cl_heap_univpoly_ring::monomial(x,e)); diff --git a/include/cln/univpoly_rational.h b/include/cln/univpoly_rational.h index 0c53590..1eb1a24 100644 --- a/include/cln/univpoly_rational.h +++ b/include/cln/univpoly_rational.h @@ -116,6 +116,10 @@ class cl_heap_univpoly_rational_ring : public cl_heap_univpoly_ring { { return cl_heap_univpoly_ring::degree(x); } + sintL ldegree (const cl_UP_RA& x) + { + return cl_heap_univpoly_ring::ldegree(x); + } const cl_UP_RA monomial (const cl_RA& x, uintL e) { return The2(cl_UP_RA)(cl_heap_univpoly_ring::monomial(cl_ring_element(cl_RA_ring,x),e)); diff --git a/include/cln/univpoly_real.h b/include/cln/univpoly_real.h index 4f2419f..8954e0e 100644 --- a/include/cln/univpoly_real.h +++ b/include/cln/univpoly_real.h @@ -116,6 +116,10 @@ class cl_heap_univpoly_real_ring : public cl_heap_univpoly_ring { { return cl_heap_univpoly_ring::degree(x); } + sintL ldegree (const cl_UP_R& x) + { + return cl_heap_univpoly_ring::ldegree(x); + } const cl_UP_R monomial (const cl_R& x, uintL e) { return The2(cl_UP_R)(cl_heap_univpoly_ring::monomial(cl_ring_element(cl_R_ring,x),e)); diff --git a/src/base/cl_free.cc b/src/base/cl_free.cc index d235145..f72c6da 100644 --- a/src/base/cl_free.cc +++ b/src/base/cl_free.cc @@ -34,7 +34,7 @@ void cl_free_heap_object (cl_heap* pointer) static const char * copyright_notice[] = { " \n" "Copyright (c) Bruno Haible 1988-2002 \n" - "Copyright (c) Richard Kreckel 2000-2003 \n" + "Copyright (c) Richard Kreckel 2000-2004 \n" " \n" "This program is free software; you can redistribute it and/or modify\n" "it under the terms of the GNU General Public License as published by\n" diff --git a/src/polynomial/elem/cl_UP_GF2.h b/src/polynomial/elem/cl_UP_GF2.h index 71caa21..8ca6f21 100644 --- a/src/polynomial/elem/cl_UP_GF2.h +++ b/src/polynomial/elem/cl_UP_GF2.h @@ -1028,6 +1028,7 @@ static cl_univpoly_modulops gf2_modulops = { static cl_univpoly_polyops gf2_polyops = { modint_degree, + modint_ldegree, modint_monomial, modint_coeff, modint_create, diff --git a/src/polynomial/elem/cl_UP_MI.h b/src/polynomial/elem/cl_UP_MI.h index 7e4faf3..0b4d62f 100644 --- a/src/polynomial/elem/cl_UP_MI.h +++ b/src/polynomial/elem/cl_UP_MI.h @@ -353,6 +353,18 @@ static sintL modint_degree (cl_heap_univpoly_ring* UPR, const _cl_UP& x) return (sintL) x.length() - 1; }} +static sintL modint_ldegree (cl_heap_univpoly_ring* UPR, const _cl_UP& x) +{{ + DeclarePoly(cl_GV_MI,x); + var cl_heap_modint_ring* R = TheModintRing(UPR->basering()); + var sintL xlen = x.length(); + for (sintL i = 0; i < xlen; i++) { + if (!R->_zerop(x[i])) + return i; + } + return -1; +}} + static const _cl_UP modint_monomial (cl_heap_univpoly_ring* UPR, const cl_ring_element& x, uintL e) { if (!(UPR->basering() == x.ring())) cl_abort(); @@ -456,6 +468,7 @@ static cl_univpoly_modulops modint_modulops = { static cl_univpoly_polyops modint_polyops = { modint_degree, + modint_ldegree, modint_monomial, modint_coeff, modint_create, diff --git a/src/polynomial/elem/cl_UP_gen.h b/src/polynomial/elem/cl_UP_gen.h index 6379a4c..1917f5b 100644 --- a/src/polynomial/elem/cl_UP_gen.h +++ b/src/polynomial/elem/cl_UP_gen.h @@ -337,6 +337,17 @@ static sintL gen_degree (cl_heap_univpoly_ring* UPR, const _cl_UP& x) return (sintL) x.length() - 1; }} +static sintL gen_ldegree (cl_heap_univpoly_ring* UPR, const _cl_UP& x) +{{ DeclarePoly(cl_SV_ringelt,x); + var cl_heap_ring* R = TheRing(UPR->basering()); + var sintL xlen = x.length(); + for (sintL i = 0; i < xlen; i++) { + if (!R->_zerop(x[i])) + return i; + } + return -1; +}} + static const _cl_UP gen_monomial (cl_heap_univpoly_ring* UPR, const cl_ring_element& x, uintL e) { if (!(UPR->basering() == x.ring())) cl_abort(); @@ -436,6 +447,7 @@ static cl_univpoly_modulops gen_modulops = { static cl_univpoly_polyops gen_polyops = { gen_degree, + gen_ldegree, gen_monomial, gen_coeff, gen_create, diff --git a/src/polynomial/elem/cl_UP_no_ring.cc b/src/polynomial/elem/cl_UP_no_ring.cc index 2e1f543..f04886e 100644 --- a/src/polynomial/elem/cl_UP_no_ring.cc +++ b/src/polynomial/elem/cl_UP_no_ring.cc @@ -109,6 +109,11 @@ static sintL dummy_degree (cl_heap_univpoly_ring* R, const _cl_UP& x) unused R; uninitialized_error(x); return 0; } +static sintL dummy_ldegree (cl_heap_univpoly_ring* R, const _cl_UP& x) +{ + unused R; + uninitialized_error(x); return 0; +} static const _cl_UP dummy_monomial (cl_heap_univpoly_ring* R, const cl_ring_element& x, uintL e) { unused R; @@ -170,6 +175,7 @@ static cl_univpoly_modulops dummy_modulops = { }; static cl_univpoly_polyops dummy_polyops = { dummy_degree, + dummy_ldegree, dummy_monomial, dummy_coeff, dummy_create, diff --git a/src/polynomial/elem/cl_UP_number.h b/src/polynomial/elem/cl_UP_number.h index 861e976..c5b5183 100644 --- a/src/polynomial/elem/cl_UP_number.h +++ b/src/polynomial/elem/cl_UP_number.h @@ -335,6 +335,18 @@ static sintL num_degree (cl_heap_univpoly_ring* UPR, const _cl_UP& x) return (sintL) x.length() - 1; }} +static sintL num_ldegree (cl_heap_univpoly_ring* UPR, const _cl_UP& x) +{{ + DeclarePoly(cl_SV_number,x); + var cl_number_ring_ops& ops = *TheNumberRing(UPR->basering())->ops; + var sintL xlen = x.length(); + for (sintL i = 0; i < xlen; i++) { + if (!ops.zerop(x[i])) + return i; + } + return -1; +}} + static const _cl_UP num_monomial (cl_heap_univpoly_ring* UPR, const cl_ring_element& x, uintL e) { if (!(UPR->basering() == x.ring())) cl_abort(); @@ -438,6 +450,7 @@ static cl_univpoly_modulops num_modulops = { static cl_univpoly_polyops num_polyops = { num_degree, + num_ldegree, num_monomial, num_coeff, num_create, -- 2.45.0