37 {
v=standard_basis<C>(
n); }
62 template <
typename C>
class Matrix;
65 class Vector :
public std::vector<C>
67 typedef std::vector<C>
base;
71 explicit Vector (
const base& b) : base(b) {}
83 template<
typename I>
Vector& add(I b,C c);
87 template<
typename C1> C1 dot (
const Vector<C1>&
v)
const;
91 __GNUC__ == 4 && ( __GNUC_MINOR__ < 8 || \ 92 __GNUC_MINOR__ == 8 && __GNUC_PATCHLEVEL__ < 1) 94 {
Vector result(*
this);
return result +=
v; }
96 {
Vector result(*
this);
return result -=
v; }
98 {
Vector result(*
this);
return result *=c; }
103 {
Vector result(*
this);
return result +=
v; }
105 {
Vector result(*
this);
return result -=
v; }
107 {
Vector result(*
this);
return result *=c; }
112 {
Vector result(std::move(*
this));
return result +=
v; }
114 {
Vector result(std::move(*
this));
return result -=
v; }
116 {
Vector result(std::move(*
this));
return result *=c; }
118 {
Vector result(std::move(*
this));
return result.
negate(); }
121 template<
typename C1>
151 Matrix_base(
size_t m,
size_t n) : d_rows(m),d_columns(n),d_data(m*n) {}
153 : d_rows(m), d_columns(n), d_data(m*n,c) {}
156 (
const std::vector<
Vector<C> >&,
size_t n_rows);
169 const C& operator() (
size_t i,
size_t j)
170 const {
return d_data[i*d_columns+j]; }
173 void get_column(
Vector<C>&,
size_t)
const;
176 std::vector<Vector<C> > rows()
const;
178 std::vector<Vector<C> > columns()
const;
183 bool is_zero()
const;
184 bool isEmpty()
const {
return d_data.size() == 0; }
186 C& operator() (
size_t i,
size_t j) {
return d_data[i*d_columns+j]; }
189 void set_column(
size_t,
const Vector<C>&);
195 void eraseColumn(
size_t);
196 void eraseRow(
size_t);
197 void reset() { d_data.assign(d_data.size(),C(0)); }
200 const C*
at (
size_t i,
size_t j)
const {
return &operator()(i,j); }
201 C*
at (
size_t i,
size_t j) {
return &operator()(i,j); }
215 #if __GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 8 220 Matrix(
size_t m,
size_t n,
const C& c) : base(m,n,c) {}
223 : base(cols,n_rows) {}
227 : base(begin,end,n_rows,tags::IteratorTag()) {}
234 #if __GNUC__ < 4 || \ 235 __GNUC__ == 4 && ( __GNUC_MINOR__ < 8 || \ 236 __GNUC_MINOR__ == 8 && __GNUC_PATCHLEVEL__ < 1) 238 Matrix transposed()
const;
241 Matrix transposed()
const &;
244 Matrix negative_transposed()
const & {
return transposed().
negate(); }
245 Matrix negative_transposed() &&
256 { v= right_prod(v); }
272 void rowOperation(
size_t,
size_t,
const C&);
273 void columnOperation(
size_t j,
size_t k,
const C& c);
275 void rowMultiply(
size_t i, C
f);
276 void columnMultiply(
size_t j,C f);
278 void swapColumns(
size_t,
size_t);
279 void swapRows(
size_t,
size_t);
294 #if __GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 8 303 : base(cols,n_rows) {}
307 : base(begin,end,n_rows,tags::IteratorTag()) {}
316 { base::operator*=(Q);
return *
this; }
318 { base::leftMult(P);
return *
this; }
321 {
if (c != C(1)) base::base::d_data /= c;
return *
this; }
330 #if __GNUC__ < 4 || \ 331 __GNUC__ == 4 && ( __GNUC_MINOR__ < 8 || \ 332 __GNUC_MINOR__ == 8 && _GNUC_PATCHLEVEL__ < 1) 336 {
return PID_Matrix(base::negative_transposed()); }
344 {
return PID_Matrix(base::negative_transposed()); }
363 bool divisible(C)
const;
364 PID_Matrix block(
size_t i0,
size_t j0,
size_t i1,
size_t j1)
const;
Definition: ctangle.c:136
Vector(const base &b)
Definition: matrix.h:71
PID_Matrix inverse() const
Definition: matrix.h:337
Vector< C > operator/(Vector< C > v, C c)
Definition: matrix.h:136
PID_Matrix negative_transposed() const
Definition: matrix.h:335
size_t d_columns
Definition: matrix.h:142
size_t rowSize() const
Definition: matrix.h:166
bool operator!=(const type_expr &x, const type_expr &y)
Definition: axis-types.h:374
PID_Matrix()
Definition: matrix.h:289
Matrix(const base &M)
Definition: matrix.h:212
Matrix negative_transposed() const
Definition: matrix.h:239
Vector & negate()
Definition: matrix.cpp:138
PID_Matrix & negate()
Definition: matrix.h:323
PID_Matrix< C > operator-(PID_Matrix< C > A, C c)
Definition: matrix.h:51
std::vector< C > base
Definition: matrix.h:67
Matrix_base(size_t m, size_t n, const C &c)
Definition: matrix.h:152
void reset()
Definition: matrix.h:197
Vector< C > & divide(Vector< C > &v, C c)
Definition: matrix.cpp:111
Matrix_base()
Definition: matrix.h:149
Matrix_base(size_t m, size_t n)
Definition: matrix.h:151
Matrix(I begin, I end, size_t n_rows, tags::IteratorTag)
Definition: matrix.h:226
Vector< C > & operator%=(Vector< C > &v, C c)
Definition: matrix.cpp:127
Matrix()
Definition: matrix.h:211
Matrix & negate()
Definition: matrix.h:267
const C * at(size_t i, size_t j) const
Definition: matrix.h:200
Matrix & leftMult(const Matrix &P)
Definition: matrix.h:265
void swap(simple_list< T, Alloc > &x, simple_list< T, Alloc > &y)
Definition: sl_list.h:674
Vector & subtract(I b, C c)
Definition: matrix.h:84
PID_Matrix & invert()
Definition: matrix.cpp:519
PID_Matrix< C > operator+(PID_Matrix< C > A, C c)
Definition: matrix.h:44
Vector()
Definition: matrix.h:69
size_t columnSize() const
Definition: matrix.h:167
Vector(size_t n, C c)
Definition: matrix.h:72
Matrix< C > base
Definition: matrix.h:286
PID_Matrix transposed() const
Definition: matrix.h:334
Vector< C > column(size_t j) const
Definition: matrix.h:177
Matrix(size_t m, size_t n, const C &c)
Definition: matrix.h:220
size_t d_rows
Definition: matrix.h:141
Matrix(base &&M)
Definition: matrix.h:213
Matrix & transpose()
Definition: matrix.cpp:503
RationalVector< C2 > operator*(const matrix::Matrix< C1 > &M, const RationalVector< C2 > &v)
Definition: ratvec.cpp:158
size_t numRows() const
Definition: matrix.h:164
PID_Matrix(size_t m, size_t n)
Definition: matrix.h:298
PID_Matrix< C > & operator+=(PID_Matrix< C > &A, C c)
Definition: matrix.cpp:733
Matrix_base< C > base
Definition: matrix.h:207
C * at(size_t i, size_t j)
Definition: matrix.h:201
void right_mult(Vector< C1 > &v) const
Definition: matrix.h:255
void apply_to(Vector< C1 > &v) const
Definition: matrix.h:253
Vector< C > d_data
Definition: matrix.h:144
void initBasis(std::vector< Vector< C > > &v, size_t n)
Definition: matrix.h:36
Matrix(size_t m, size_t n)
Definition: matrix.h:219
size_t numColumns() const
Definition: matrix.h:165
PID_Matrix(size_t m, size_t n, const C &c)
Definition: matrix.h:299
PID_Matrix< C > & operator-=(PID_Matrix< C > &A, C c)
Definition: matrix.h:48
PID_Matrix(base &&M)
Definition: matrix.h:291
Vector< C > & operator/=(Vector< C > &v, C c)
Definition: matrix.cpp:99
Vector(size_t n)
Definition: matrix.h:70
Vector< C > row(size_t i) const
Definition: matrix.h:175
PID_Matrix & transpose()
Definition: matrix.h:324
Matrix(const std::vector< Vector< C > > &cols, size_t n_rows)
Definition: matrix.h:222
std::vector< Vector< C > > standard_basis(size_t r)
Definition: matrix.cpp:722
PID_Matrix inverse(C &d) const
Definition: matrix.h:338
unsigned long n
Definition: axis.cpp:77
bool operator==(const type_expr &x, const type_expr &y)
Definition: axis-types.cpp:257
simple_list< T, Alloc >::const_iterator end(const simple_list< T, Alloc > &l)
Definition: sl_list.h:650
bool isEmpty() const
Definition: matrix.h:184
PID_Matrix(I begin, I end, size_t n_rows, tags::IteratorTag)
Definition: matrix.h:306
PID_Matrix(const base &M)
Definition: matrix.h:290
void basis(std::vector< matrix::Vector< int > > &b, const bitmap::BitMap &B, const FiniteAbelianGroup &A)
Definition: abelian.cpp:427
const expr & e
Definition: axis.cpp:95
PID_Matrix(size_t n)
Definition: matrix.h:301
PID_Matrix(const std::vector< Vector< C > > &cols, size_t n_rows)
Definition: matrix.h:302
void transpose(Endomorphism &e, const FiniteAbelianGroup &A)
Definition: abelian.cpp:675
Vector(I b, I e)
Definition: matrix.h:74
Vertex v
Definition: graph.cpp:116
PID_Matrix & leftMult(const Matrix< C > &P)
Definition: matrix.h:317