File: StairCaseMatrix.hh

package info (click to toggle)
topcom 1.1.2%2Bds-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 31,788 kB
  • sloc: cpp: 37,616; sh: 4,262; makefile: 497; ansic: 49
file content (147 lines) | stat: -rw-r--r-- 4,373 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
////////////////////////////////////////////////////////////////////////////////
// 
// StairCaseMatrix.hh 
//
//    produced: 21/08/97 jr
// last change: 30/10/97 jr
//
////////////////////////////////////////////////////////////////////////////////
#ifndef STAIRCASEMATRIX_HH
#define STAIRCASEMATRIX_HH

#include <assert.h>
#include <limits>

#include "CommandlineOptions.hh"

#include "Vector.hh"
#include "Matrix.hh"

namespace topcom {

  class StairCaseMatrix : public Matrix {
  protected:
    Field _coefficient;
  public:
    
    // constructors:
    inline StairCaseMatrix();
    inline StairCaseMatrix(const StairCaseMatrix&);
    inline StairCaseMatrix(StairCaseMatrix&&);
    inline StairCaseMatrix(const StairCaseMatrix&,
			   const parameter_type,
			   const parameter_type);
    inline StairCaseMatrix(const Matrix&,
			   const IntegerSet& = IntegerSet());
    inline StairCaseMatrix(const Vector&);
    inline StairCaseMatrix(const parameter_type, 
			   const parameter_type, 
			   const Field& init_entry = FieldConstants::ZERO);

    // destructor:
    inline ~StairCaseMatrix();
    
    // assignment:
    inline StairCaseMatrix& operator=(const StairCaseMatrix&);
    inline StairCaseMatrix& operator=(StairCaseMatrix&&);
    
    // accessors:
    inline const Field& coefficient() const;
    
    // in place operations:
    StairCaseMatrix& augment(const Matrix&, const IntegerSet& = IntegerSet());
    
    // out of place operations:
    inline bool has_no_zerocol() const;
    const Field left_upper_det() const;
    const Field det()            const;
    
    // iostream:
    std::ostream& pretty_print(std::ostream&) const;
    friend std::ostream& operator<<(std::ostream&, const StairCaseMatrix&);
  private:
    
    // internal elimination step:
    void _eliminate(const parameter_type, const parameter_type, const parameter_type);
    
    // forbid in place operations if result is of type StairCaseMatrix:
    inline StairCaseMatrix& add(const StairCaseMatrix&) = delete;
    inline StairCaseMatrix& scale(const Field&) = delete;
    inline StairCaseMatrix& stack(const StairCaseMatrix&) = delete;
  };

  inline StairCaseMatrix::StairCaseMatrix() : 
    Matrix(), _coefficient(FieldConstants::ONE) {
  }

  inline StairCaseMatrix::StairCaseMatrix(const StairCaseMatrix& matrix) :
    Matrix(matrix), _coefficient(matrix._coefficient) {
  }

  inline StairCaseMatrix::StairCaseMatrix(StairCaseMatrix&& matrix) : 
    Matrix(std::move(matrix)), _coefficient(std::move(matrix._coefficient)) {
  }

  inline StairCaseMatrix::StairCaseMatrix(const StairCaseMatrix& matrix,
					  const parameter_type min_col,
					  const parameter_type max_col) : 
    Matrix(matrix, min_col, max_col), _coefficient(matrix._coefficient) {
  }

  inline StairCaseMatrix::StairCaseMatrix(const Matrix&     matrix,
					  const IntegerSet& ignored_cols) :
    Matrix(), _coefficient(FieldConstants::ONE) {
    this->augment(matrix, ignored_cols);
  }
    
  
  inline StairCaseMatrix::StairCaseMatrix(const Vector& vector) : 
    Matrix(vector), _coefficient(FieldConstants::ONE) {
  }

  inline StairCaseMatrix::StairCaseMatrix(const parameter_type init_rows, 
					  const parameter_type init_cols, 
					  const Field& init_entry) :
    Matrix() , _coefficient(FieldConstants::ONE) {
    if (init_entry == FieldConstants::ZERO) {
      Matrix::operator=(Matrix(init_rows, init_cols, init_entry));
    }
    else {
      this->augment(Matrix(init_rows, init_cols, init_entry));
    }
  }
  inline StairCaseMatrix::~StairCaseMatrix() {
  }
  inline StairCaseMatrix& StairCaseMatrix::operator=(const StairCaseMatrix& matrix) {
    if (this == &matrix) {
      return *this;
    }
    Matrix::operator=(matrix);
    _coefficient = matrix._coefficient;
    return *this;
  }
  inline StairCaseMatrix& StairCaseMatrix::operator=(StairCaseMatrix&& matrix) {
    if (this == &matrix) {
      return *this;
    }
    Matrix::operator=(std::move(matrix));
    _coefficient = std::move(matrix._coefficient);
    return *this;
  }
  inline const Field& StairCaseMatrix::coefficient() const {
    return _coefficient;
  }
  inline bool StairCaseMatrix::has_no_zerocol() const {
    if (coldim() == 0) {
      return true;
    }
    else {
      return (!this->col(coldim() - 1).is_zero());
    }
  }

}; // namespace topcom

#endif

// eof StairCaseMatrix.hh