Frobby
0.10.0
Toggle main menu visibility
Loading...
Searching...
No Matches
src
Matrix.h
1
/* Frobby: Software for monomial ideal computations.
2
Copyright (C) 2010 University of Aarhus
3
Contact Bjarke Hammersholt Roune for license information (www.broune.com)
4
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation; either version 2 of the License, or
8
(at your option) any later version.
9
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
14
15
You should have received a copy of the GNU General Public License
16
along with this program. If not, see http://www.gnu.org/licenses/.
17
*/
18
#ifndef MATRIX_GUARD
19
#define MATRIX_GUARD
20
21
#include <vector>
22
23
class
BigIntVector
;
24
class
ColumnPrinter
;
25
26
class
Matrix {
27
public
:
28
Matrix(
size_t
rowCount = 0,
size_t
colCount = 0);
29
30
size_t
getRowCount()
const
{
return
_rowCount;}
31
size_t
getColCount()
const
{
return
_colCount;}
32
37
void
resize
(
size_t
rowCount,
size_t
colCount);
38
39
const
mpq_class& operator()(
size_t
row,
size_t
col)
const
40
{
return
_entries[toIndex(row, col)];}
41
mpq_class& operator()(
size_t
row,
size_t
col)
42
{
return
_entries[toIndex(row, col)];}
43
44
void
swap(Matrix& mat);
45
46
private
:
47
size_t
toIndex(
size_t
row,
size_t
col)
const
{
48
ASSERT(row < _rowCount);
49
ASSERT(col < _colCount);
50
ASSERT(_entries.size() == _rowCount * _colCount);
51
size_t
index = col + row * _colCount;
52
ASSERT(index < _entries.size());
53
return
index;
54
}
55
56
size_t
_rowCount;
57
size_t
_colCount;
58
vector<mpq_class> _entries;
59
};
60
61
bool
operator==(
const
Matrix
& a,
const
Matrix
& b);
62
ostream& operator<<(ostream& out,
const
Matrix
& mat);
63
64
void
print(FILE* file,
const
Matrix
& mat);
65
void
print(
ColumnPrinter
& printer,
const
Matrix
& mat);
66
68
void
product(
Matrix
& prod,
const
Matrix
& a,
const
Matrix
& b);
69
71
void
transpose(
Matrix
& trans,
const
Matrix
& mat);
72
74
void
transpose(
Matrix
& mat);
75
77
void
addMultiplyRow(
Matrix
& mat,
size_t
resultRow,
78
size_t
sourceRow,
const
mpq_class& mult);
79
81
void
multiplyRow(
Matrix
& mat,
size_t
row,
const
mpq_class& mult);
82
84
void
swapRows(
Matrix
& mat,
size_t
row1,
size_t
row2);
85
89
bool
rowReduce(
Matrix
& mat);
90
92
size_t
matrixRank(
const
Matrix
& mat);
93
98
void
rowReduceFully(
Matrix
& mat);
99
102
void
subMatrix(
Matrix
& sub,
const
Matrix
& mat,
103
size_t
rowBegin,
size_t
rowEnd,
104
size_t
colBegin,
size_t
colEnd);
105
108
void
copyRow(
Matrix
& target,
size_t
targetRow,
109
const
Matrix
& source,
size_t
sourceRow);
110
116
bool
inverse(
Matrix
& inv,
const
Matrix
& mat);
117
119
void
nullSpace(
Matrix
& basis,
const
Matrix
& mat);
120
124
bool
solve(
Matrix
& sol,
const
Matrix
& lhs,
const
Matrix
& rhs);
125
127
bool
hasSameColSpace(
const
Matrix
& a,
const
Matrix
& b);
128
130
bool
hasSameRowSpace(
const
Matrix
& a,
const
Matrix
& b);
131
133
mpq_class determinant(
const
Matrix
& mat);
134
136
bool
isParallelogram(
const
Matrix
& mat);
137
142
mpq_class getParallelogramAreaSq(
const
Matrix
& mat);
143
144
#endif
BigIntVector
Definition
BigIntVector.h:24
ColumnPrinter
Definition
ColumnPrinter.h:27
Matrix
Definition
Matrix.h:26
Matrix::resize
void resize(size_t rowCount, size_t colCount)
Definition
Matrix.cpp:61
Generated by
1.17.0