63 |
|
data_[i][j] = s; |
64 |
|
} |
65 |
|
|
66 |
+ |
RectMatrix(Real* array) { |
67 |
+ |
for (unsigned int i = 0; i < Row; i++) |
68 |
+ |
for (unsigned int j = 0; j < Col; j++) |
69 |
+ |
data_[i][j] = array[i * Row + j]; |
70 |
+ |
} |
71 |
+ |
|
72 |
|
/** copy constructor */ |
73 |
|
RectMatrix(const RectMatrix<Real, Row, Col>& m) { |
74 |
|
*this = m; |
92 |
|
* Return the reference of a single element of this matrix. |
93 |
|
* @return the reference of a single element of this matrix |
94 |
|
* @param i row index |
95 |
< |
* @param j colum index |
95 |
> |
* @param j Column index |
96 |
|
*/ |
97 |
|
Real& operator()(unsigned int i, unsigned int j) { |
98 |
|
//assert( i < Row && j < Col); |
103 |
|
* Return the value of a single element of this matrix. |
104 |
|
* @return the value of a single element of this matrix |
105 |
|
* @param i row index |
106 |
< |
* @param j colum index |
106 |
> |
* @param j Column index |
107 |
|
*/ |
108 |
|
Real operator()(unsigned int i, unsigned int j) const { |
109 |
|
|
110 |
|
return data_[i][j]; |
111 |
|
} |
112 |
|
|
113 |
+ |
/** |
114 |
+ |
* Copy the internal data to an array |
115 |
+ |
* @param array the pointer of destination array |
116 |
+ |
*/ |
117 |
+ |
void getArray(Real* array) { |
118 |
+ |
for (unsigned int i = 0; i < Row; i++) { |
119 |
+ |
for (unsigned int j = 0; j < Col; j++) { |
120 |
+ |
array[i * Row + j] = data_[i][j]; |
121 |
+ |
} |
122 |
+ |
} |
123 |
+ |
} |
124 |
+ |
|
125 |
+ |
|
126 |
|
/** Returns the pointer of internal array */ |
127 |
|
Real* getArrayPointer() { |
128 |
|
return &data_[0][0]; |
158 |
|
* @return a column of this matrix as a vector |
159 |
|
* @param col the column index |
160 |
|
*/ |
161 |
< |
Vector<Real, Col> getColum(unsigned int col) { |
161 |
> |
Vector<Real, Col> getColumn(unsigned int col) { |
162 |
|
Vector<Real, Col> v; |
163 |
|
|
164 |
|
for (unsigned int j = 0; j < Col; j++) |
172 |
|
* @param col the column index |
173 |
|
* @param v the vector to be set |
174 |
|
*/ |
175 |
< |
void setColum(unsigned int col, const Vector<Real, Col>& v){ |
175 |
> |
void setColumn(unsigned int col, const Vector<Real, Col>& v){ |
176 |
|
|
177 |
|
for (unsigned int j = 0; j < Col; j++) |
178 |
|
data_[j][col] = v[j]; |
191 |
|
} |
192 |
|
|
193 |
|
/** |
194 |
< |
* swap two colums of this matrix |
195 |
< |
* @param i the first colum |
196 |
< |
* @param j the second colum |
194 |
> |
* swap two Columns of this matrix |
195 |
> |
* @param i the first Column |
196 |
> |
* @param j the second Column |
197 |
|
*/ |
198 |
< |
void swapColum(unsigned int i, unsigned int j){ |
198 |
> |
void swapColumn(unsigned int i, unsigned int j){ |
199 |
|
assert(i < Col && j < Col); |
200 |
|
|
201 |
|
for (unsigned int k = 0; k < Row; k++) |
365 |
|
} |
366 |
|
|
367 |
|
/** Return the transpose of this matrix */ |
368 |
< |
RectMatrix<Real, Col, Row> transpose(){ |
368 |
> |
RectMatrix<Real, Col, Row> transpose() const{ |
369 |
|
RectMatrix<Real, Col, Row> result; |
370 |
|
|
371 |
|
for (unsigned int i = 0; i < Row; i++) |