source: git/factory/int_rat.h @ 69fdf90

spielwiese
Last change on this file since 69fdf90 was ee668e, checked in by Jan Engelhardt <jengelh@…>, 12 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: 3.3 KB
Line 
1/* emacs edit mode for this file is -*- C++ -*- */
2/* $Id$ */
3
4#ifndef INCL_INT_RAT_H
5#define INCL_INT_RAT_H
6
7// #include "config.h"
8
9#ifndef NOSTREAMIO
10#ifdef HAVE_IOSTREAM
11#include <iostream>
12#define OSTREAM std::ostream
13#elif defined(HAVE_IOSTREAM_H)
14#include <iostream.h>
15#define OSTREAM ostream
16#endif
17#endif /* NOSTREAMIO */
18
19#include "cf_assert.h"
20
21#include "canonicalform.h"
22#include "int_cf.h"
23#include "imm.h"
24// #include <factory/cf_gmp.h>
25
26class InternalRational : public InternalCF
27{
28private:
29    mpz_t _num;
30    mpz_t _den;
31    static int initialized;
32    static mpz_ptr MPQNUM( const InternalCF * const c );
33    static mpz_ptr MPQDEN( const InternalCF * const c );
34    static void normalize( const mpz_ptr, const mpz_ptr, mpz_ptr, mpz_ptr );
35public:
36    InternalRational();
37    InternalRational( const InternalCF& )
38    {
39        ASSERT( 0, "ups there is something wrong in your code" );
40    }
41    InternalRational( const int i );
42    InternalRational( const int n, const int d );
43    InternalRational( const char * str );
44    InternalRational( const mpz_ptr );
45    InternalRational( const mpz_ptr , const mpz_ptr );
46    ~InternalRational();
47    InternalCF* deepCopyObject() const;
48    const char * classname() const { return "InternalRational"; }
49#ifndef NOSTREAMIO
50    void print( OSTREAM&, char* );
51#endif /* NOSTREAMIO */
52    InternalCF* genZero();
53    InternalCF* genOne();
54
55    bool is_imm() const;
56    int levelcoeff() const { return RationalDomain; }
57
58    InternalCF* num();
59    InternalCF* den();
60
61    InternalCF* neg();
62
63    int comparesame( InternalCF* );
64
65    InternalCF* addsame( InternalCF* );
66    InternalCF* subsame( InternalCF* );
67    InternalCF* mulsame( InternalCF* );
68    InternalCF* dividesame( InternalCF* );
69    InternalCF* modulosame( InternalCF* );
70    InternalCF* divsame( InternalCF* );
71    InternalCF* modsame( InternalCF* );
72    void divremsame( InternalCF*, InternalCF*&, InternalCF*& );
73    bool divremsamet( InternalCF*, InternalCF*&, InternalCF*& );
74
75    int comparecoeff( InternalCF* );
76
77    InternalCF* addcoeff( InternalCF* );
78    InternalCF* subcoeff( InternalCF*, bool );
79    InternalCF* mulcoeff( InternalCF* );
80    InternalCF* dividecoeff( InternalCF*, bool );
81    InternalCF* modulocoeff( InternalCF*, bool );
82    InternalCF* divcoeff( InternalCF*, bool );
83    InternalCF* modcoeff( InternalCF*, bool );
84    void divremcoeff( InternalCF*, InternalCF*&, InternalCF*&, bool );
85    bool divremcoefft( InternalCF*, InternalCF*&, InternalCF*&, bool );
86
87    InternalCF * bgcdsame ( const InternalCF * const ) const;
88    InternalCF * bgcdcoeff ( const InternalCF * const );
89
90    InternalCF * bextgcdsame ( InternalCF *, CanonicalForm &, CanonicalForm & );
91    InternalCF * bextgcdcoeff ( InternalCF *, CanonicalForm &, CanonicalForm & );
92
93    int intval() const;
94
95    int sign() const;
96
97    InternalCF * normalize_myself();
98
99    friend class InternalInteger;
100    friend void gmp_numerator ( const CanonicalForm & f, mpz_ptr result );
101    friend void gmp_denominator ( const CanonicalForm & f, mpz_ptr result );
102    friend CanonicalForm make_cf ( const mpz_ptr n, const mpz_ptr d );
103};
104
105inline mpz_ptr InternalRational::MPQNUM( const InternalCF * const c )
106{
107    return (((InternalRational*)c)->_num);
108}
109
110inline mpz_ptr InternalRational::MPQDEN( const InternalCF * const c )
111{
112    return (((InternalRational*)c)->_den);
113}
114
115#endif /* ! INCL_INT_RAT_H */
Note: See TracBrowser for help on using the repository browser.