source: git/factory/singext.cc @ ee668e

jengelh-datetimespielwiese
Last change on this file since ee668e was ee668e, checked in by Jan Engelhardt <jengelh@…>, 11 years ago
factory/build: restore out-of-tree build support When attempting an OOT build, it fails to find <factory/cplusplus.h>, because cplusplus.h is always (even in in-tree builds) produced in "${builddir}", and not "${top_srcdir}/../factory". Furthermore, one must not rely on the basename of ${top_srcdir}, and going above ${top_srcdir} is undefined and may lead to spurious build failures. (Consider a hypothetical chroot on ${top_srcdir}). Therefore, create a directory include/factory and use -Iinclude such that <factory/*> yields a buildable state, move all exported header files there. Previous OOT build log: 17:22 seven:../factory/obj > make CXX cplusplus.o CXXLD cplusplus ./cplusplus > ./cplusplus.h ../bin/makeheader ../factory.template factory.h ../bin/makeheader ../factoryconf.template factoryconf.h YACC readcf.cc make all-am make[1]: Entering directory `/home/jengelh/obs/zu/home/jengelh/science/singsource/factory/obj' CXX libfactory_a-algext.o CXX libfactory_a-canonicalform.o In file included from ../cf_factory.h:12:0, from ../canonicalform.cc:7: ../../factory/cf_gmp.h:14:33: fatal error: factory/cplusplus.h: Ingen slik fil eller filkatalog compilation terminated. make[1]: *** [libfactory_a-canonicalform.o] Error 1 make[1]: Leaving directory `/home/jengelh/obs/zu/home/jengelh/science/singsource/factory/obj' make: *** [all] Error 2
  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[493c477]1/* emacs edit mode for this file is -*- C++ -*- */
[341696]2/* $Id$ */
[2dd068]3
[e4fe2b]4#include "config.h"
[9d7aaa]5
[650f2d8]6#include "cf_assert.h"
[9d7aaa]7
[2dd068]8#include "cf_defs.h"
9#include "singext.h"
10#include "int_cf.h"
11#include "int_int.h"
12#include "int_rat.h"
13#include "imm.h"
14#include "cf_factory.h"
15
[ee668e]16#include <factory/cf_gmp.h>
[daa556]17
18
[8357930]19void gmp_numerator ( const CanonicalForm & f, mpz_ptr result )
[2dd068]20{
21    InternalCF * ff = f.getval();
22    ASSERT( ! is_imm( ff ), "illegal type" );
[8357930]23    if ( ff->levelcoeff() == IntegerDomain )
24    {
[a52291]25        mpz_init_set( result, (InternalInteger::MPI( ff )) );
[8357930]26        ff->deleteObject();
[2dd068]27    }
[8357930]28    else  if ( ff->levelcoeff() == RationalDomain )
29    {
[a52291]30        mpz_init_set( result, (InternalRational::MPQNUM( ff )) );
[8357930]31        ff->deleteObject();
[2dd068]32    }
[8357930]33    else
34    {
35        ASSERT( 0, "illegal type" );
[2dd068]36    }
37}
38
[8357930]39void gmp_denominator ( const CanonicalForm & f, mpz_ptr result )
[2dd068]40{
41    InternalCF * ff = f.getval();
42    ASSERT( ! is_imm( ff ), "illegal type" );
[8357930]43    if ( ff->levelcoeff() == IntegerDomain )
44    {
45        mpz_init_set_si( result, 1 );
46        ff->deleteObject();
[2dd068]47    }
[8357930]48    else  if ( ff->levelcoeff() == RationalDomain )
49    {
[a52291]50        mpz_init_set( result, (InternalRational::MPQDEN( ff )) );
[8357930]51        ff->deleteObject();
[2dd068]52    }
[8357930]53    else
54    {
55        ASSERT( 0, "illegal type" );
[2dd068]56    }
57}
58
[8838ab]59int gf_value (const CanonicalForm & f )
60{
61    InternalCF * ff = f.getval();
[8357930]62    return ((long)ff) >>2;
[8838ab]63}
64
[2dd068]65CanonicalForm
[a52291]66make_cf ( const mpz_ptr n )
[2dd068]67{
[186402]68    return CanonicalForm( CFFactory::basic( n ) );
[2dd068]69}
70
71CanonicalForm
[a52291]72make_cf ( const mpz_ptr n, const mpz_ptr d, bool normalize )
[2dd068]73{
[186402]74    return CanonicalForm( CFFactory::rational( n, d, normalize ) );
[2dd068]75}
[8838ab]76
77CanonicalForm make_cf_from_gf ( const int z )
78{
79    return CanonicalForm(int2imm_gf(z));
80}
Note: See TracBrowser for help on using the repository browser.