/* Use mpz_kronecker_ui() to calculate an estimate for the quadratic class number h(d), for a given negative fundamental discriminant, using Dirichlet's analytic formula.
Copyright 1999-2002 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see https://www.gnu.org/licenses/. */
/* Usage: qcn [-p limit] <discriminant>...
A fundamental discriminant means one of the form D or 4*D with D square-free. Each argument is checked to see it's congruent to 0 or 1 mod 4 (as all discriminants must be), and that it's negative, but there's no check on D being square-free.
This program is a bit of a toy, there are better methods for calculating the class number and class group structure.
Reference:
Daniel Shanks, "Class Number, A Theory of Factorization, and Genera", Proc. Symp. Pure Math., vol 20, 1970, pages 415-440.
/* A simple but slow primality test. */ int
prime_p (unsignedlong n)
{ unsignedlong i, limit;
if (n == 2) return 1; if (n < 2 || !(n&1)) return 0;
limit = (unsignedlong) floor (sqrt ((double) n)); for (i = 3; i <= limit; i+=2) if ((n % i) == 0) return 0;
return 1;
}
/* The formula is as follows, with d < 0.
w * sqrt(-d) inf p h(d) = ------------ * product -------- 2 * pi p=2 p - (d/p)
(d/p) is the Kronecker symbol and the product is over primes p. w is 6 when d=-3, 4 when d=-4, or 2 otherwise.
Calculating the product up to p=infinity would take a long time, so for the estimate primes up to 132,000 are used. Shanks found this giving an
accuracy of about 1 part in 1000, in normal cases. */
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.