43 unsigned int totalRows,
unsigned int totalColumns,
unsigned int subDiags,
44 unsigned int superDiags)
53 if (diags != std::numeric_limits<unsigned int>::max())
57 else if (totalRows > 0)
68 unsigned int subDiags,
69 unsigned int superDiags)
76 unsigned int totalRows, [[maybe_unused]]
unsigned int totalColumns,
77 unsigned int row,
unsigned int column,
unsigned int sub,
unsigned int super)
84 unsigned int elementRow =
86 unsigned int elementColumn = column;
93 return std::numeric_limits<unsigned int>::max();
98 [[maybe_unused]]
const unsigned int totalRows,
99 [[maybe_unused]]
const unsigned int totalColumns,
const unsigned int curRow,
100 const unsigned int curColumn)
102 unsigned int nextRow = curRow;
103 unsigned int nextColumn = curColumn;
105 return std::tuple<unsigned int, unsigned int>(nextRow, nextColumn);
109 unsigned int columns)
111 return rows * columns;
115 unsigned int totalRows, [[maybe_unused]]
unsigned int totalColumns,
116 unsigned int curRow,
unsigned int curColumn)
118 return curColumn * totalRows + curRow;
122 const unsigned int totalRows,
const unsigned int totalColumns,
123 const unsigned int curRow,
const unsigned int curColumn)
125 unsigned int nextRow = curRow;
126 unsigned int nextColumn = curColumn;
128 if (nextRow < totalRows)
133 if (nextRow >= totalRows)
139 if (nextColumn >= totalColumns)
141 nextRow = std::numeric_limits<unsigned int>::max();
142 nextColumn = std::numeric_limits<unsigned int>::max();
145 return std::tuple<unsigned int, unsigned int>(nextRow, nextColumn);
149 unsigned int columns)
151 ASSERTL0(rows == columns,
"Triangular matrices must be square.");
152 return rows * (rows + 1) / 2;
156 unsigned int curColumn)
158 if (curRow <= curColumn)
160 return curRow + curColumn * (curColumn + 1) / 2;
164 return std::numeric_limits<unsigned int>::max();
169 [[maybe_unused]]
const unsigned int totalRows,
170 const unsigned int totalColumns,
const unsigned int curRow,
171 const unsigned int curColumn)
173 ASSERTL1(totalRows == totalColumns,
"Triangular matrices must be square.");
175 "Attemping to iterate through an element on row " +
176 std::to_string(curRow) +
" of a (" +
177 std::to_string(totalRows) +
", " +
178 std::to_string(totalColumns) +
" upper triangular matrix.");
180 "Attemping to iterate through an element on row " +
181 std::to_string(curColumn) +
" of a (" +
182 std::to_string(totalRows) +
", " +
183 std::to_string(totalColumns) +
" upper triangular matrix.");
185 "Attemping to iterate through element (" + std::to_string(curRow) +
186 ", " + std::to_string(curColumn) +
") of a (" +
187 std::to_string(totalRows) +
", " +
188 std::to_string(totalColumns) +
" upper triangular matrix.");
190 unsigned int nextRow = curRow;
191 unsigned int nextColumn = curColumn;
193 if (nextRow <= nextColumn)
198 if (nextRow > nextColumn)
204 if (nextColumn >= totalColumns)
206 nextRow = std::numeric_limits<unsigned int>::max();
207 nextColumn = std::numeric_limits<unsigned int>::max();
210 return std::tuple<unsigned int, unsigned int>(nextRow, nextColumn);
214 unsigned int totalColumns,
unsigned int curRow,
unsigned int curColumn)
216 if (curRow >= curColumn)
218 return curRow + (2 * totalColumns - curColumn - 1) * (curColumn) / 2;
222 return std::numeric_limits<unsigned int>::max();
227 const unsigned int totalRows,
const unsigned int totalColumns,
228 const unsigned int curRow,
const unsigned int curColumn,
char transpose)
230 ASSERTL1(totalRows == totalColumns,
"Triangular matrices must be square.");
232 "Attemping to iterate through an element on row " +
233 std::to_string(curRow) +
" of a (" +
234 std::to_string(totalRows) +
", " +
235 std::to_string(totalColumns) +
" lower triangular matrix.");
237 "Attemping to iterate through an element on row " +
238 std::to_string(curColumn) +
" of a (" +
239 std::to_string(totalRows) +
", " +
240 std::to_string(totalColumns) +
" lower triangular matrix.");
242 "Attemping to iterate through element (" + std::to_string(curRow) +
243 ", " + std::to_string(curColumn) +
") of a (" +
244 std::to_string(totalRows) +
", " +
245 std::to_string(totalColumns) +
" lower triangular matrix.");
247 if (transpose ==
'T')
253 unsigned int nextRow = curRow;
254 unsigned int nextColumn = curColumn;
256 if (nextRow < totalRows)
261 if (nextRow >= totalRows)
264 nextRow = nextColumn;
267 if (nextColumn >= totalColumns)
269 nextRow = std::numeric_limits<unsigned int>::max();
270 nextColumn = std::numeric_limits<unsigned int>::max();
273 return std::tuple<unsigned int, unsigned int>(nextRow, nextColumn);
277 unsigned int curColumn)
279 if (curRow <= curColumn)
281 return curRow + curColumn * (curColumn + 1) / 2;
285 return curColumn + curRow * (curRow + 1) / 2;
290 const unsigned int totalRows,
const unsigned int totalColumns,
291 const unsigned int curRow,
const unsigned int curColumn)
293 ASSERTL1(totalRows == totalColumns,
"Symmetric matrices must be square.");
295 "Attemping to iterate through an element on row " +
296 std::to_string(curRow) +
" of a (" +
297 std::to_string(totalRows) +
", " +
298 std::to_string(totalColumns) +
" symmetric matrix.");
300 "Attemping to iterate through an element on row " +
301 std::to_string(curColumn) +
" of a (" +
302 std::to_string(totalRows) +
", " +
303 std::to_string(totalColumns) +
" symmetric matrix.");
305 unsigned int nextRow = curRow;
306 unsigned int nextColumn = curColumn;
308 if (nextRow < totalRows)
313 if (nextRow >= totalRows)
319 if (nextColumn >= totalColumns)
321 nextRow = std::numeric_limits<unsigned int>::max();
322 nextColumn = std::numeric_limits<unsigned int>::max();
325 return std::tuple<unsigned int, unsigned int>(nextRow, nextColumn);
329 const unsigned int totalRows,
330 [[maybe_unused]]
const unsigned int totalColumns,
const unsigned int curRow,
331 const unsigned int curColumn)
335 "Iteration of a diagonal matrix is only valid along the diagonal.");
337 unsigned int nextRow = curRow;
338 unsigned int nextColumn = curColumn;
340 if (nextRow < totalRows)
346 if (nextRow >= totalRows)
348 nextRow = std::numeric_limits<unsigned int>::max();
349 nextColumn = std::numeric_limits<unsigned int>::max();
352 return std::tuple<unsigned int, unsigned int>(nextRow, nextColumn);
356 unsigned int columns)
358 ASSERTL0(rows == columns,
"Diagonal matrices must be square.");
371 return std::numeric_limits<unsigned int>::max();
376 unsigned int rows,
unsigned int columns,
unsigned int nSubSuperDiags)
378 ASSERTL0(rows == columns,
"Triangular matrices must be square.");
379 return (nSubSuperDiags + 1) * columns;
383 unsigned int curRow,
unsigned int curColumn,
unsigned int nSuperDiags)
385 if (curRow <= curColumn)
387 if ((curColumn - curRow) <= nSuperDiags)
389 unsigned int elementRow = nSuperDiags - (curColumn - curRow);
390 unsigned int elementColumn = curColumn;
392 return elementRow + elementColumn * (nSuperDiags + 1);
396 return std::numeric_limits<unsigned int>::max();
#define ASSERTL0(condition, msg)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
static unsigned int CalculateNumberOfRows(unsigned int totalRows, unsigned int subDiags, unsigned int superDiags)
static unsigned int CalculateIndex(unsigned int totalRows, unsigned int totalColumns, unsigned int row, unsigned int column, unsigned int sub, unsigned int super)
static unsigned int CalculateNumberOfDiags(unsigned int totalRows, unsigned int diags)
static unsigned int GetRequiredStorageSize(unsigned int totalRows, unsigned int totalColumns, unsigned int subDiags, unsigned int superDiags)
Calculates and returns the storage size required.
static std::tuple< unsigned int, unsigned int > Advance(const unsigned int totalRows, const unsigned int totalColumns, const unsigned int curRow, const unsigned int curColumn)
static std::tuple< unsigned int, unsigned int > Advance(const unsigned int totalRows, const unsigned int totalColumns, const unsigned int curRow, const unsigned int curColumn)
static unsigned int GetRequiredStorageSize(unsigned int rows, unsigned int columns)
static unsigned int CalculateIndex(unsigned int row, unsigned int col)
static unsigned int GetRequiredStorageSize(unsigned int rows, unsigned int columns)
static std::tuple< unsigned int, unsigned int > Advance(const unsigned int totalRows, const unsigned int totalColumns, const unsigned int curRow, const unsigned int curColumn)
static unsigned int CalculateIndex(unsigned int totalRows, unsigned int totalColumns, unsigned int curRow, unsigned int curColumn)
static std::tuple< unsigned int, unsigned int > Advance(const unsigned int totalRows, const unsigned int totalColumns, const unsigned int curRow, const unsigned int curColumn, char transpose='N')
static unsigned int CalculateIndex(unsigned int totalColumns, unsigned int curRow, unsigned int curColumn)
static unsigned int CalculateIndex(unsigned int curRow, unsigned int curColumn, unsigned int nSuperDiags)
static std::tuple< unsigned int, unsigned int > Advance(const unsigned int totalRows, const unsigned int totalColumns, const unsigned int curRow, const unsigned int curColumn)
static unsigned int CalculateIndex(unsigned int curRow, unsigned int curColumn)
static unsigned int GetRequiredStorageSize(unsigned int rows, unsigned int columns, unsigned int nSubSuperDiags)
static unsigned int GetRequiredStorageSize(unsigned int rows, unsigned int columns)
static std::tuple< unsigned int, unsigned int > Advance(const unsigned int totalRows, const unsigned int totalColumns, const unsigned int curRow, const unsigned int curColumn)
static unsigned int CalculateIndex(unsigned int curRow, unsigned int curColumn)