GeneralBrokenLines
trunk_rev46
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Pages
src
VMatrix.h
Go to the documentation of this file.
1
/*
2
* VMatrix.h
3
*
4
* Created on: Feb 15, 2012
5
* Author: kleinwrt
6
*/
7
8
#ifndef VMATRIX_H_
9
#define VMATRIX_H_
10
11
#include<iostream>
12
#include<iomanip>
13
#include<vector>
14
#include<cstring>
15
#include<math.h>
16
18
class
VVector
{
19
public
:
20
VVector
(
const
unsigned
int
nRows = 0);
21
VVector
(
const
VVector
&aVector);
22
virtual
~VVector
();
23
void
resize
(
const
unsigned
int
nRows);
24
VVector
getVec
(
unsigned
int
len,
unsigned
int
start = 0)
const
;
25
void
putVec
(
const
VVector
&aVector,
unsigned
int
start = 0);
26
inline
double
&
operator()
(
unsigned
int
i);
27
inline
double
operator()
(
unsigned
int
i)
const
;
28
unsigned
int
getNumRows
()
const
;
29
void
print
()
const
;
30
VVector
operator-
(
const
VVector
&aVector)
const
;
31
private
:
32
unsigned
int
numRows
;
33
std::vector<double>
theVec
;
34
};
35
37
class
VMatrix
{
38
public
:
39
VMatrix
(
const
unsigned
int
nRows = 0,
const
unsigned
int
nCols = 0);
40
VMatrix
(
const
VMatrix
&aMatrix);
41
virtual
~VMatrix
();
42
void
resize
(
const
unsigned
int
nRows,
const
unsigned
int
nCols);
43
VMatrix
transpose
()
const
;
44
inline
double
&
operator()
(
unsigned
int
i,
unsigned
int
j);
45
inline
double
operator()
(
unsigned
int
i,
unsigned
int
j)
const
;
46
unsigned
int
getNumRows
()
const
;
47
unsigned
int
getNumCols
()
const
;
48
void
print
()
const
;
49
VVector
operator*
(
const
VVector
&aVector)
const
;
50
VMatrix
operator*
(
const
VMatrix
&aMatrix)
const
;
51
VMatrix
operator+
(
const
VMatrix
&aMatrix)
const
;
52
private
:
53
unsigned
int
numRows
;
54
unsigned
int
numCols
;
55
std::vector<double>
theVec
;
56
};
57
59
class
VSymMatrix
{
60
public
:
61
VSymMatrix
(
const
unsigned
int
nRows = 0);
62
virtual
~VSymMatrix
();
63
void
resize
(
const
unsigned
int
nRows);
64
unsigned
int
invert
();
65
inline
double
&
operator()
(
unsigned
int
i,
unsigned
int
j);
66
inline
double
operator()
(
unsigned
int
i,
unsigned
int
j)
const
;
67
unsigned
int
getNumRows
()
const
;
68
void
print
()
const
;
69
VSymMatrix
operator-
(
const
VMatrix
&aMatrix)
const
;
70
VVector
operator*
(
const
VVector
&aVector)
const
;
71
VMatrix
operator*
(
const
VMatrix
&aMatrix)
const
;
72
private
:
73
unsigned
int
numRows
;
74
std::vector<double>
theVec
;
75
};
76
78
inline
double
&
VMatrix::operator()
(
unsigned
int
iRow,
unsigned
int
iCol) {
79
return
theVec
[
numCols
* iRow + iCol];
80
}
81
83
inline
double
VMatrix::operator()
(
unsigned
int
iRow,
unsigned
int
iCol)
const
{
84
return
theVec
[
numCols
* iRow + iCol];
85
}
86
88
inline
double
&
VVector::operator()
(
unsigned
int
iRow) {
89
return
theVec
[iRow];
90
}
91
93
inline
double
VVector::operator()
(
unsigned
int
iRow)
const
{
94
return
theVec
[iRow];
95
}
96
98
inline
double
&
VSymMatrix::operator()
(
unsigned
int
iRow,
unsigned
int
iCol) {
99
return
theVec
[(iRow * iRow + iRow) / 2 + iCol];
// assuming iCol <= iRow
100
}
101
103
inline
double
VSymMatrix::operator()
(
unsigned
int
iRow,
104
unsigned
int
iCol)
const
{
105
return
theVec
[(iRow * iRow + iRow) / 2 + iCol];
// assuming iCol <= iRow
106
}
107
108
#endif
/* VMATRIX_H_ */
Generated on Thu Sep 20 2012 15:45:38 for GeneralBrokenLines by
1.8.1