2014-08-30 03:21:42 +04:00
|
|
|
//
|
|
|
|
// <copyright file="Helpers.h" company="Microsoft">
|
|
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
// </copyright>
|
|
|
|
//
|
2015-09-14 23:18:44 +03:00
|
|
|
|
2014-08-30 03:21:42 +04:00
|
|
|
//helpful macros
|
2015-09-14 23:18:44 +03:00
|
|
|
// TODO: the file's name is too general to be included from outside; MathHelpers.h?
|
|
|
|
|
2014-08-30 03:21:42 +04:00
|
|
|
//iterators
|
|
|
|
#pragma once
|
|
|
|
#undef foreach_row
|
|
|
|
#undef foreach_column
|
2016-01-18 11:36:14 +03:00
|
|
|
#undef foreach_coord
|
2014-08-30 03:21:42 +04:00
|
|
|
#undef foreach_row_in_submat
|
2016-01-18 11:36:14 +03:00
|
|
|
#define foreach_row(_i, _m) for (long _i = 0; _i < (_m).GetNumRows(); _i++)
|
|
|
|
#define foreach_column(_j, _m) for (long _j = 0; _j < (_m).GetNumCols(); _j++)
|
|
|
|
#define foreach_coord(_i, _j, _m) \
|
|
|
|
for (long _j = 0; _j < (_m).GetNumCols(); _j++) \
|
|
|
|
for (long _i = 0; _i < (_m).GetNumRows(); _i++)
|
|
|
|
#define foreach_row_in_submat(_i, _istart, _iend, _m) for (long _i = _istart; _i < min(_iend, (_m).GetNumRows()); _i++)
|
2014-08-30 03:21:42 +04:00
|
|
|
|
|
|
|
//this functions returns the index of the first column element in the columnwise array representing matrix with _numRows rows
|
2016-01-18 11:36:14 +03:00
|
|
|
#define column_s_ind_colwisem(_colNum, _numRows) ((_numRows) * (_colNum))
|