本文整理汇总了C++中mat::is_empty方法的典型用法代码示例。如果您正苦于以下问题:C++ mat::is_empty方法的具体用法?C++ mat::is_empty怎么用?C++ mat::is_empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mat
的用法示例。
在下文中一共展示了mat::is_empty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pushMatrix_row
void pushMatrix_row(mat& MATRIX, mat ToBePushed) {
// cout<< "MATRIX" << MATRIX.n_rows<< ", " <<MATRIX.n_cols <<endl;
// cout<< "ToBePushed" << ToBePushed.n_rows << ", " << ToBePushed.n_cols <<endl;
if (MATRIX.is_empty()) {
// cout <<__LINE__<<endl;
MATRIX.resize(ToBePushed.n_rows, ToBePushed.n_cols);
for(int i = 0; i < ToBePushed.n_rows; i ++) {
for (int j = 0; j < ToBePushed.n_cols; j ++) {
MATRIX.at(i, j) = ToBePushed.at(i, j);
}
}
return;
}
if (MATRIX.n_rows != ToBePushed.n_rows) {
cout << " wrong dimension!" <<endl;
abort();
}
mat tmp;
tmp.zeros(MATRIX.n_rows, MATRIX.n_cols + ToBePushed.n_cols);
// cout<<"tmp: " << tmp.n_rows <<", " <<tmp.n_cols <<endl;
for(int i = 0; i < MATRIX.n_rows; i ++) {
// cout << i <<endl;
for(int j = 0; j < MATRIX.n_cols; j ++) {
tmp.at(i,j) = MATRIX.at(i,j);
}
}
for(int i = 0; i < ToBePushed.n_rows; i ++) {
for(int j = 0; j < ToBePushed.n_cols; j ++) {
tmp.at(i, j + MATRIX.n_cols) = ToBePushed.at(i, j);
// cout<<__LINE__<<endl;
}
}
MATRIX = tmp;
}
示例2: pushMatrix_col
void pushMatrix_col(mat& MATRIX, mat ToBePushed) {
if (MATRIX.is_empty()) {
MATRIX.resize(ToBePushed.n_rows, ToBePushed.n_cols);
for(int i = 0; i < ToBePushed.n_rows; i ++) {
for (int j = 0; j < ToBePushed.n_cols; j ++) {
MATRIX.at(i, j) = ToBePushed.at(i, j);
}
}
return;
}
if(MATRIX.n_cols != ToBePushed.n_cols) {
cout << " wrong dimension!" <<endl;
abort();
}
mat tmp;
tmp.zeros(MATRIX.n_rows + ToBePushed.n_rows, MATRIX.n_cols);
for (int i = 0; i < MATRIX.n_rows; i ++) {
for (int j = 0; j < MATRIX.n_cols; j ++) {
tmp.at(i,j) = MATRIX.at(i,j);
}
}
for (int i = 0; i < ToBePushed.n_rows; i ++) {
for ( int j = 0; j < ToBePushed.n_rows; j ++) {
tmp.at(i + MATRIX.n_rows, j) = ToBePushed.at(i,j);
}
}
MATRIX = tmp;
}