source: git/factory/include/factory/templates/ftmpl_matrix.h @ 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: 2.6 KB
RevLine 
[6ab5981]1/* emacs edit mode for this file is -*- C++ -*- */
[341696]2/* $Id$ */
[c5f2101]3
4#ifndef INCL_MATRIX_H
5#define INCL_MATRIX_H
6
[e4fe2b]7// #include <factory/factoryconf.h>
[8c0163]8
[175e355]9#ifndef NOSTREAMIO
[1dc616]10#ifdef HAVE_IOSTREAM
11#include <iostream>
[181148]12#define OSTREAM std::ostream
[1dc616]13#elif defined(HAVE_IOSTREAM_H)
[c5f2101]14#include <iostream.h>
[181148]15#define OSTREAM ostream
[1dc616]16#endif
[175e355]17#endif /* NOSTREAMIO */
[c5f2101]18
19template <class T>
20class SubMatrix;
21
[22347b6]22template <class T>
23class Matrix;
24
25#ifndef NOSTREAMIO
26template <class T>
[181148]27OSTREAM& operator<< (OSTREAM &, const Matrix<T> &);
[22347b6]28#endif
29
[c5f2101]30template <class T>
31class Matrix
32{
33private:
34    int NR, NC;
35    T ** elems;
[175e355]36#ifndef NOSTREAMIO
[181148]37    void printrow ( OSTREAM & s, int i ) const;
[175e355]38#endif /* NOSTREAMIO */
[8840725]39    typedef T* T_ptr;
[c5f2101]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 );
[175e355]56#ifndef NOSTREAMIO
[181148]57    void print( OSTREAM& s ) const;
58    friend OSTREAM & operator<< <T>( OSTREAM & s, const Matrix<T>& M );
[175e355]59#endif /* NOSTREAMIO */
[c5f2101]60    friend class SubMatrix<T>;
61};
[2457a8]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 );
[c5f2101]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
[5bb462]91#ifndef NOSTREAMIO
92template <class T>
[181148]93OSTREAM & operator<< ( OSTREAM & s, const Matrix<T>& M );
[5bb462]94#endif /* NOSTREAMIO */
95
[6ab5981]96#endif /* ! INCL_MATRIX_H */
Note: See TracBrowser for help on using the repository browser.