source: git/factory/singext.cc @ cc1367

spielwiese
Last change on this file since cc1367 was 2dd068, checked in by Rüdiger Stobbe <stobbe@…>, 28 years ago
Initial revision git-svn-id: file:///usr/local/Singular/svn/trunk@6 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 1.5 KB
Line 
1// emacs edit mode for this file is -*- C++ -*-
2// $Id: singext.cc,v 1.0 1996-05-17 10:59:47 stobbe Exp $
3
4/*
5$Log: not supported by cvs2svn $
6*/
7
8#include "assert.h"
9#include "cf_defs.h"
10#include "singext.h"
11#include "int_cf.h"
12#include "int_int.h"
13#include "int_rat.h"
14#include "imm.h"
15#include "cf_factory.h"
16
17MP_INT
18gmp_numerator ( const CanonicalForm & f )
19{
20    InternalCF * ff = f.getval();
21    ASSERT( ! is_imm( ff ), "illegal type" );
22    MP_INT result;
23    if ( ff->levelcoeff() == IntegerDomain ) {
24        mpz_init_set( &result, &(InternalInteger::MPI( ff )) );
25        ff->deleteObject();
26    }
27    else  if ( ff->levelcoeff() == RationalDomain ) {
28        mpz_init_set( &result, &(InternalRational::MPQNUM( ff )) );
29        ff->deleteObject();
30    }
31    else {
32        ASSERT( 0, "illegal type" );
33    }
34    return result;
35}
36
37MP_INT
38gmp_denominator ( const CanonicalForm & f )
39{
40    InternalCF * ff = f.getval();
41    ASSERT( ! is_imm( ff ), "illegal type" );
42    MP_INT result;
43    if ( ff->levelcoeff() == IntegerDomain ) {
44        mpz_init_set_si( &result, 1 );
45        ff->deleteObject();
46    }
47    else  if ( ff->levelcoeff() == RationalDomain ) {
48        mpz_init_set( &result, &(InternalRational::MPQDEN( ff )) );
49        ff->deleteObject();
50    }
51    else {
52        ASSERT( 0, "illegal type" );
53    }
54    return result;
55}
56
57CanonicalForm
58make_cf ( const MP_INT & n )
59{
60    return CanonicalForm( CFFactory::basic( n ) );
61}
62
63CanonicalForm
64make_cf ( const MP_INT & n, const MP_INT & d, bool normalize )
65{
66    return CanonicalForm( CFFactory::rational( n, d, normalize ) );
67}
Note: See TracBrowser for help on using the repository browser.