source: git/Singular/misc_ip.h @ 0df59c8

spielwiese
Last change on this file since 0df59c8 was 737a68, checked in by Oleksandr Motsak <motsak@…>, 13 years ago
CHG: moved libpolys/polys/polys.h to kernel/polys.h & updated includes ADD: moved (definition of) currRing/rChangeCurrRing to kernel/polys.cc!?
  • Property mode set to 100644
File size: 3.2 KB
Line 
1/*****************************************************************************\
2 * Computer Algebra System SINGULAR   
3\*****************************************************************************/
4/** @file misc_ip.h
5 *
6 * This file provides miscellaneous functionality.
7 *
8 * ABSTRACT: This file provides the following miscellaneous functionality:
9 *           - prime factorisation of bigints with prime factors < 2^31
10 *            (This will require at most 256 MByte of RAM.)
11 *           - approximate square root of a bigint
12 *
13 *           Most of the functioanlity implemented here had earlier been
14 *           coded in SINGULAR in some library. Due to performance reasons
15 *           these algorithms have been moved to the C/C++ kernel.
16 *
17 * @author Frank Seelisch
18 *
19 * @internal @version \$Id$
20 *
21 **/
22/*****************************************************************************/
23
24#ifndef MISC_H
25#define MISC_H
26
27#include <misc/auxiliary.h>
28
29#include <coeffs/si_gmp.h>
30#include <coeffs/coeffs.h>
31
32#include <Singular/lists.h>
33
34/**
35 * Divides 'n' as many times as possible by 'd' and returns the number
36 * of divisions (without remainder) in 'times',
37 * e.g., n = 48, d = 4, divTimes(n, d, t) = 3 produces n = 3, t = 2,
38 *       since 48 = 4*4*3;
39 * assumes that d is positive
40 **/
41void divTimes(mpz_t n,   /**< [in]  a GMP number >= 0                      */
42              mpz_t d,   /**< [in]  the divisor, a GMP number >= 0         */
43              int* times /**< [out] number of divisions without remainder  */
44             );
45
46/**
47 * Factorises a given bigint number n into its prime factors less
48 * than or equal to a given bound, with corresponding multiplicities.
49 *
50 * The method finds all prime factors with multiplicities. If a positive
51 * bound is given, then only the prime factors <= pBound are being found.
52 * In this case, there may remain an unfactored portion m of n.
53 * Also, when n is negative, m will contain the sign. If n is zero, m will
54 * be zero.
55 * The method returns a list L filled with four entries:
56 * L[1] a list; L[1][i] contains the i-th prime factor of |n| as int or
57 *                      bigint (sorted in ascending order),
58 * L[2] a list; L[2][i] contains the multiplicity of L[1, i] in |n| as int
59 * L[3] contains the remainder m as int or bigint, depending on the size,
60 * L[4] 1 iff |m| is probably a prime, 0 otherwise
61 *
62 * We thus have: n = L[1][1]^L[2][1] * ... * L[1][k]^L[2][k] * L[1], where
63 * k is the number of mutually distinct prime factors (<= a provided non-
64 * zero bound).
65 * Note that for n = 0, L[2] and L[3] will be emtpy lists and L[4] will be
66 * zero.
67 *
68 * @return the factorisation data in a SINGULAR-internal list
69 **/
70lists primeFactorisation(
71       const number n,     /**< [in]  the bigint > 0 to be factorised   */
72       const number pBound /**< [in]  bigint bound on the prime factors
73                                      seeked                            */
74                        );
75
76
77
78#ifdef PDEBUG
79#if (OM_TRACK > 2) && defined(OM_TRACK_CUSTOM)
80// #include <kernel/polys.h>
81/* Needed for debug Version of p_SetRingOfLeftv, Oliver */
82#include <kernel/structs.h>
83void p_SetRingOfLeftv(leftv l, ring r);
84#endif
85#endif
86
87#endif
88/* MISC_H */
Note: See TracBrowser for help on using the repository browser.