44 unsigned int subDiags,
unsigned int superDiags)
51 if( diags != std::numeric_limits<unsigned int>::max() )
55 else if( totalRows > 0 )
71 unsigned int totalColumns,
72 unsigned int row,
unsigned int column,
73 unsigned int sub,
unsigned int super)
79 unsigned int elementColumn = column;
85 return std::numeric_limits<unsigned int>::max();
90 boost::tuples::tuple<unsigned int, unsigned int>
92 const unsigned int curRow,
const unsigned int curColumn)
94 unsigned int nextRow = curRow;
95 unsigned int nextColumn = curColumn;
117 return boost::tuples::tuple<unsigned int, unsigned int>(nextRow, nextColumn);
128 return curColumn*totalRows + curRow;
132 boost::tuples::tuple<unsigned int, unsigned int>
134 const unsigned int curRow,
const unsigned int curColumn)
136 unsigned int nextRow = curRow;
137 unsigned int nextColumn = curColumn;
139 if( nextRow < totalRows )
144 if( nextRow >= totalRows )
150 if( nextColumn >= totalColumns )
152 nextRow = std::numeric_limits<unsigned int>::max();
153 nextColumn = std::numeric_limits<unsigned int>::max();
156 return boost::tuples::tuple<unsigned int, unsigned int>(nextRow, nextColumn);
162 ASSERTL0(rows==columns,
"Triangular matrices must be square.");
163 return rows*(rows+1)/2;
168 if( curRow <= curColumn )
170 return curRow + curColumn*(curColumn+1)/2;
174 return std::numeric_limits<unsigned int>::max();
178 boost::tuples::tuple<unsigned int, unsigned int>
180 const unsigned int curRow,
const unsigned int curColumn)
182 ASSERTL1(totalRows == totalColumns,
"Triangular matrices must be square.");
183 ASSERTL1(curRow < totalRows,
"Attemping to iterate through an element on row " +
184 boost::lexical_cast<std::string>(curRow) +
" of a (" +
185 boost::lexical_cast<std::string>(totalRows) +
", " +
186 boost::lexical_cast<std::string>(totalColumns) +
" upper triangular matrix.");
187 ASSERTL1(curColumn < totalColumns,
"Attemping to iterate through an element on row " +
188 boost::lexical_cast<std::string>(curColumn) +
" of a (" +
189 boost::lexical_cast<std::string>(totalRows) +
", " +
190 boost::lexical_cast<std::string>(totalColumns) +
" upper triangular matrix.");
191 ASSERTL1(curRow <= curColumn,
"Attemping to iterate through element (" +
192 boost::lexical_cast<std::string>(curRow) +
", " +
193 boost::lexical_cast<std::string>(curColumn) +
") of a (" +
194 boost::lexical_cast<std::string>(totalRows) +
", " +
195 boost::lexical_cast<std::string>(totalColumns) +
" upper triangular matrix.");
197 unsigned int nextRow = curRow;
198 unsigned int nextColumn = curColumn;
200 if( nextRow <= nextColumn )
205 if( nextRow > nextColumn )
211 if( nextColumn >= totalColumns )
213 nextRow = std::numeric_limits<unsigned int>::max();
214 nextColumn = std::numeric_limits<unsigned int>::max();
217 return boost::tuples::tuple<unsigned int, unsigned int>(nextRow, nextColumn);
223 if( curRow >= curColumn )
225 return curRow + (2*totalColumns - curColumn - 1)*(curColumn)/2;
229 return std::numeric_limits<unsigned int>::max();
233 boost::tuples::tuple<unsigned int, unsigned int>
235 const unsigned int curRow,
const unsigned int curColumn,
238 ASSERTL1(totalRows == totalColumns,
"Triangular matrices must be square.");
239 ASSERTL1(curRow < totalRows,
"Attemping to iterate through an element on row " +
240 boost::lexical_cast<std::string>(curRow) +
" of a (" +
241 boost::lexical_cast<std::string>(totalRows) +
", " +
242 boost::lexical_cast<std::string>(totalColumns) +
" lower triangular matrix.");
243 ASSERTL1(curColumn < totalColumns,
"Attemping to iterate through an element on row " +
244 boost::lexical_cast<std::string>(curColumn) +
" of a (" +
245 boost::lexical_cast<std::string>(totalRows) +
", " +
246 boost::lexical_cast<std::string>(totalColumns) +
" lower triangular matrix.");
247 ASSERTL1(curRow >= curColumn,
"Attemping to iterate through element (" +
248 boost::lexical_cast<std::string>(curRow) +
", " +
249 boost::lexical_cast<std::string>(curColumn) +
") of a (" +
250 boost::lexical_cast<std::string>(totalRows) +
", " +
251 boost::lexical_cast<std::string>(totalColumns) +
" lower triangular matrix.");
253 if( transpose ==
'T' )
256 totalColumns, totalRows, curColumn, curRow);
259 unsigned int nextRow = curRow;
260 unsigned int nextColumn = curColumn;
262 if( nextRow < totalRows )
267 if( nextRow >= totalRows )
270 nextRow = nextColumn;
273 if( nextColumn >= totalColumns )
275 nextRow = std::numeric_limits<unsigned int>::max();
276 nextColumn = std::numeric_limits<unsigned int>::max();
279 return boost::tuples::tuple<unsigned int, unsigned int>(nextRow, nextColumn);
285 if( curRow <= curColumn )
287 return curRow + curColumn*(curColumn+1)/2;
291 return curColumn + curRow*(curRow + 1)/2;
295 boost::tuples::tuple<unsigned int, unsigned int>
297 const unsigned int curRow,
const unsigned int curColumn)
299 ASSERTL1(totalRows == totalColumns,
"Symmetric matrices must be square.");
300 ASSERTL1(curRow < totalRows,
"Attemping to iterate through an element on row " +
301 boost::lexical_cast<std::string>(curRow) +
" of a (" +
302 boost::lexical_cast<std::string>(totalRows) +
", " +
303 boost::lexical_cast<std::string>(totalColumns) +
" symmetric matrix.");
304 ASSERTL1(curColumn < totalColumns,
"Attemping to iterate through an element on row " +
305 boost::lexical_cast<std::string>(curColumn) +
" of a (" +
306 boost::lexical_cast<std::string>(totalRows) +
", " +
307 boost::lexical_cast<std::string>(totalColumns) +
" symmetric matrix.");
309 unsigned int nextRow = curRow;
310 unsigned int nextColumn = curColumn;
312 if( nextRow < totalRows )
317 if( nextRow >= totalRows )
323 if( nextColumn >= totalColumns )
325 nextRow = std::numeric_limits<unsigned int>::max();
326 nextColumn = std::numeric_limits<unsigned int>::max();
329 return boost::tuples::tuple<unsigned int, unsigned int>(nextRow, nextColumn);
332 boost::tuples::tuple<unsigned int, unsigned int>
334 const unsigned int curRow,
const unsigned int curColumn)
336 ASSERTL0(curRow == curColumn,
"Iteration of a diagonal matrix is only valid along the diagonal.");
338 unsigned int nextRow = curRow;
339 unsigned int nextColumn = curColumn;
341 if( nextRow < totalRows )
347 if( nextRow >= totalRows )
349 nextRow = std::numeric_limits<unsigned int>::max();
350 nextColumn = std::numeric_limits<unsigned int>::max();
353 return boost::tuples::tuple<unsigned int, unsigned int>(nextRow, nextColumn);
358 ASSERTL0(rows==columns,
"Diagonal matrices must be square.");
370 return std::numeric_limits<unsigned int>::max();
375 unsigned int nSubSuperDiags)
377 ASSERTL0(rows==columns,
"Triangular matrices must be square.");
378 return (nSubSuperDiags+1)*columns;
382 unsigned int nSuperDiags)
384 if( curRow <= curColumn )
386 if( (curColumn - curRow) <= nSuperDiags )
388 unsigned int elementRow = nSuperDiags - (curColumn - curRow);
389 unsigned int elementColumn = curColumn;
391 return elementRow + elementColumn*(nSuperDiags+1);
395 return std::numeric_limits<unsigned int>::max();