Changeset 19fc57b in git


Ignore:
Timestamp:
Jun 13, 2005, 11:46:35 AM (18 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
Children:
9b2e40337f961f59313156623380c600a101bb81
Parents:
f6202187ee8c7e5f4a1be04fd61af7b6987429bc
Message:
*hannes: c++ std::


git-svn-id: file:///usr/local/Singular/svn/trunk@8352 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
factory
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • factory/ftmpl_matrix.h

    rf620218 r19fc57b  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: ftmpl_matrix.h,v 1.1 1998-03-10 14:43:26 schmidt Exp $ */
     2/* $Id: ftmpl_matrix.h,v 1.2 2005-06-13 09:46:35 Singular Exp $ */
    33
    44#ifndef INCL_MATRIX_H
     5#define INCL_MATRIX_H
    56
    6 //{{{ docu
    7 //
    8 // ftmpl_matrix.h - wrapper for `templates/ftmpl_matrix.h'.
    9 //
    10 // This file exists for convenience only.
    11 //
    12 // `INCL_MATRIX_H' is defined in `templates/ftmpl_matrix.h'.
    13 //
    14 //}}}
     7#include <factoryconf.h>
    158
    16 #ifdef macintosh
    17 #include <:templates:ftmpl_matrix.h>
    18 #else
    19 #include "templates/ftmpl_matrix.h"
     9#ifndef NOSTREAMIO
     10#include <iostream.h>
     11#endif /* NOSTREAMIO */
     12
     13template <class T>
     14class SubMatrix;
     15
     16template <class T>
     17class Matrix;
     18
     19#ifndef NOSTREAMIO
     20template <class T>
     21ostream& operator<< (ostream &, const Matrix<T> &);
    2022#endif
    2123
     24template <class T>
     25class Matrix
     26{
     27private:
     28    int NR, NC;
     29    T ** elems;
     30#ifndef NOSTREAMIO
     31    void printrow ( ostream & s, int i ) const;
     32#endif /* NOSTREAMIO */
     33    typedef T* T_ptr;
     34public:
     35    Matrix() : NR(0), NC(0), elems(0) {}
     36    Matrix( int nr, int nc );
     37    Matrix( const Matrix<T>& M );
     38    ~Matrix();
     39    Matrix<T>& operator= ( const Matrix<T>& M );
     40    int rows() const { return NR; }
     41    int columns() const { return NC; }
     42    SubMatrix<T> operator[] ( int i );
     43    const SubMatrix<T> operator[] ( int i ) const;
     44    T& operator() ( int row, int col );
     45    T operator() ( int row, int col ) const;
     46    SubMatrix<T> operator() ( int rmin, int rmax, int cmin, int cmax );
     47    const SubMatrix<T> operator() ( int rmin, int rmax, int cmin, int cmax ) const;
     48    void swapRow( int i, int j );
     49    void swapColumn( int i, int j );
     50#ifndef NOSTREAMIO
     51    void print( ostream& s ) const;
     52    friend ostream & operator<< <T>( ostream & s, const Matrix<T>& M );
     53#endif /* NOSTREAMIO */
     54    friend class SubMatrix<T>;
     55};
     56    template <class T>
     57    Matrix<T> operator+ ( const Matrix<T>& lhs, const Matrix<T>& rhs );
     58    template <class T>
     59    Matrix<T> operator- ( const Matrix<T>& lhs, const Matrix<T>& rhs );
     60    template <class T>
     61    Matrix<T> operator* ( const Matrix<T>& lhs, const Matrix<T>& rhs );
     62    template <class T>
     63    Matrix<T> operator* ( const Matrix<T>& lhs, const T& rhs );
     64    template <class T>
     65    Matrix<T> operator* ( const T& lhs, const Matrix<T>& rhs );
     66
     67template <class T>
     68class SubMatrix
     69{
     70private:
     71    int r_min, r_max, c_min, c_max;
     72    Matrix<T>& M;
     73    // we do not provide a default ctor, so nobody can declare an empty SubMatrix
     74    SubMatrix( int rmin, int rmax, int cmin, int cmax, const Matrix<T> & m );
     75public:
     76    SubMatrix( const SubMatrix<T> & S );
     77    SubMatrix<T>& operator= ( const SubMatrix<T>& S );
     78    SubMatrix<T>& operator= ( const Matrix<T>& S );
     79    operator Matrix<T>() const;
     80    T operator[] ( int i ) const;
     81    T& operator[] ( int i );
     82    friend class Matrix<T>;
     83};
     84
     85#ifndef NOSTREAMIO
     86template <class T>
     87ostream & operator<< ( ostream & s, const Matrix<T>& M );
     88#endif /* NOSTREAMIO */
     89
    2290#endif /* ! INCL_MATRIX_H */
  • factory/templates/ftmpl_matrix.h

    rf620218 r19fc57b  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: ftmpl_matrix.h,v 1.10 2005-01-13 15:11:36 Singular Exp $ */
     2/* $Id: ftmpl_matrix.h,v 1.11 2005-06-13 09:46:35 Singular Exp $ */
    33
    44#ifndef INCL_MATRIX_H
     
    1919#ifndef NOSTREAMIO
    2020template <class T>
    21 std::ostream& operator<< (std::ostream &, const Matrix<T> &);
     21ostream& operator<< (ostream &, const Matrix<T> &);
    2222#endif
    2323
Note: See TracChangeset for help on using the changeset viewer.