source: git/factory/include/factory/templates/ftmpl_matrix.h @ b7d64b

jengelh-datetimespielwiese
Last change on this file since b7d64b 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: 2.6 KB
Line 
1/* emacs edit mode for this file is -*- C++ -*- */
2/* $Id$ */
3
4#ifndef INCL_MATRIX_H
5#define INCL_MATRIX_H
6
7// #include <factory/factoryconf.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
19template <class T>
20class SubMatrix;
21
22template <class T>
23class Matrix;
24
25#ifndef NOSTREAMIO
26template <class T>
27OSTREAM& operator<< (OSTREAM &, const Matrix<T> &);
28#endif
29
30template <class T>
31class Matrix
32{
33private:
34    int NR, NC;
35    T ** elems;
36#ifndef NOSTREAMIO
37    void printrow ( OSTREAM & s, int i ) const;
38#endif /* NOSTREAMIO */
39    typedef T* T_ptr;
40public:
41    Matrix() : NR(0), NC(0), elems(0) {}
42    Matrix( int nr, int nc );
43    Matrix( const Matrix<T>& M );
44    ~Matrix();
45    Matrix<T>& operator= ( const Matrix<T>& M );
46    int rows() const { return NR; }
47    int columns() const { return NC; }
48    SubMatrix<T> operator[] ( int i );
49    const SubMatrix<T> operator[] ( int i ) const;
50    T& operator() ( int row, int col );
51    T operator() ( int row, int col ) const;
52    SubMatrix<T> operator() ( int rmin, int rmax, int cmin, int cmax );
53    const SubMatrix<T> operator() ( int rmin, int rmax, int cmin, int cmax ) const;
54    void swapRow( int i, int j );
55    void swapColumn( int i, int j );
56#ifndef NOSTREAMIO
57    void print( OSTREAM& s ) const;
58    friend OSTREAM & operator<< <T>( OSTREAM & s, const Matrix<T>& M );
59#endif /* NOSTREAMIO */
60    friend class SubMatrix<T>;
61};
62    template <class T>
63    Matrix<T> operator+ ( const Matrix<T>& lhs, const Matrix<T>& rhs );
64    template <class T>
65    Matrix<T> operator- ( const Matrix<T>& lhs, const Matrix<T>& rhs );
66    template <class T>
67    Matrix<T> operator* ( const Matrix<T>& lhs, const Matrix<T>& rhs );
68    template <class T>
69    Matrix<T> operator* ( const Matrix<T>& lhs, const T& rhs );
70    template <class T>
71    Matrix<T> operator* ( const T& lhs, const Matrix<T>& rhs );
72
73template <class T>
74class SubMatrix
75{
76private:
77    int r_min, r_max, c_min, c_max;
78    Matrix<T>& M;
79    // we do not provide a default ctor, so nobody can declare an empty SubMatrix
80    SubMatrix( int rmin, int rmax, int cmin, int cmax, const Matrix<T> & m );
81public:
82    SubMatrix( const SubMatrix<T> & S );
83    SubMatrix<T>& operator= ( const SubMatrix<T>& S );
84    SubMatrix<T>& operator= ( const Matrix<T>& S );
85    operator Matrix<T>() const;
86    T operator[] ( int i ) const;
87    T& operator[] ( int i );
88    friend class Matrix<T>;
89};
90
91#ifndef NOSTREAMIO
92template <class T>
93OSTREAM & operator<< ( OSTREAM & s, const Matrix<T>& M );
94#endif /* NOSTREAMIO */
95
96#endif /* ! INCL_MATRIX_H */
Note: See TracBrowser for help on using the repository browser.