source: git/Singular/misc_ip.h @ b0732eb

spielwiese
Last change on this file since b0732eb was 6ce030f, checked in by Oleksandr Motsak <motsak@…>, 12 years ago
removal of the $Id$ svn tag from everywhere NOTE: the git SHA1 may be used instead (only on special places) NOTE: the libraries Singular/LIB/*.lib still contain the marker due to our current use of svn
  • Property mode set to 100644
File size: 3.1 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 *
20 **/
21/*****************************************************************************/
22
23#ifndef MISC_H
24#define MISC_H
25
26#include <misc/auxiliary.h>
27
28#include <coeffs/si_gmp.h>
29#include <coeffs/coeffs.h>
30
31#include <Singular/lists.h>
32
33/**
34 * Divides 'n' as many times as possible by 'd' and returns the number
35 * of divisions (without remainder) in 'times',
36 * e.g., n = 48, d = 4, divTimes(n, d, t) = 3 produces n = 3, t = 2,
37 *       since 48 = 4*4*3;
38 * assumes that d is positive
39 **/
40void divTimes(mpz_t n,   /**< [in]  a GMP number >= 0                      */
41              mpz_t d,   /**< [in]  the divisor, a GMP number >= 0         */
42              int* times /**< [out] number of divisions without remainder  */
43             );
44
45/**
46 * Factorises a given bigint number n into its prime factors less
47 * than or equal to a given bound, with corresponding multiplicities.
48 *
49 * The method finds all prime factors with multiplicities. If a positive
50 * bound is given, then only the prime factors <= pBound are being found.
51 * In this case, there may remain an unfactored portion m of n.
52 * Also, when n is negative, m will contain the sign. If n is zero, m will
53 * be zero.
54 * The method returns a list L filled with four entries:
55 * L[1] a list; L[1][i] contains the i-th prime factor of |n| as int or
56 *                      bigint (sorted in ascending order),
57 * L[2] a list; L[2][i] contains the multiplicity of L[1, i] in |n| as int
58 * L[3] contains the remainder m as int or bigint, depending on the size,
59 * L[4] 1 iff |m| is probably a prime, 0 otherwise
60 *
61 * We thus have: n = L[1][1]^L[2][1] * ... * L[1][k]^L[2][k] * L[1], where
62 * k is the number of mutually distinct prime factors (<= a provided non-
63 * zero bound).
64 * Note that for n = 0, L[2] and L[3] will be emtpy lists and L[4] will be
65 * zero.
66 *
67 * @return the factorisation data in a SINGULAR-internal list
68 **/
69lists primeFactorisation(
70       const number n,     /**< [in]  the bigint > 0 to be factorised   */
71       const number pBound /**< [in]  bigint bound on the prime factors
72                                      seeked                            */
73                        );
74
75
76
77#ifdef PDEBUG
78#if (OM_TRACK > 2) && defined(OM_TRACK_CUSTOM)
79// #include <kernel/polys.h>
80/* Needed for debug Version of p_SetRingOfLeftv, Oliver */
81#include <kernel/structs.h>
82void p_SetRingOfLeftv(leftv l, ring r);
83#endif
84#endif
85
86#endif
87/* MISC_H */
Note: See TracBrowser for help on using the repository browser.