コード例 #1
0
ファイル: aug-bg.c プロジェクト: cantora/aug-bg
void post_scroll(int rows, int cols, int direction, aug_action *action, void *user) {
	int rmax, cmin;

	(void)(direction);
	(void)(user);
	(void)(action);
	
	if(!g_on)
		return;

	rmax = row_max();
	if(direction == 0)
		return;
	else if(direction < 0)
		rmax += -direction;
	/* else it got scrolled off top edge */

	if(rmax > rows)
		rmax = rows;

	cmin = column_min(cols);

	if(rmax >= 0 && cmin > 10)
		aug_primary_term_damage(cmin, cols-1, 0, rmax);
}
コード例 #2
0
ファイル: aug-bg.c プロジェクト: cantora/aug-bg
void cell_update(int rows, int cols, int *row, int *col, wchar_t *wch, 
		attr_t *attr, int *color_pair, aug_action *action, void *user) {
	int col_min, row_min, r, c;
	(void)(rows);
	(void)(color_pair);
	(void)(wch);
	(void)(action);
	(void)(user);
	
	/*aug_log("cell_update: g_on=%d, %d/%d, %d/%d\n", g_on, *col, cols, *row, rows);*/
	if(!g_on)
		return;

	col_min = column_min(cols);
	row_min = 1;
	if(col_min > 10 
			&& *col >= col_min && *col < (cols-1)
			&& *row >= row_min && *row < row_max() ) {
		r = *row - 1;
		c = *col - col_min;
		if(g_boo_map[r][c/2] != 0) {
			*attr = *attr | A_REVERSE;
		}
	}
}
コード例 #3
0
ファイル: aug-bg.c プロジェクト: cantora/aug-bg
static void on_cmd_key(uint32_t ch, void *user) {
	int rmax, cmin;

	(void)(ch);
	(void)(user);

	/*aug_log("on_cmd_key: ch=0x%02x, g_on=%d\n", ch, g_on);*/
	/* do nothing if we havent been notified of the 
	 * screen size yet */
	if(g_rows < 1 || g_cols < 1) {
		aug_log("havent gotten dims yet, do nothing\n");
		return;
	}

	g_on = !g_on;
	rmax = row_max();

	if(rmax > g_rows)
		rmax = g_rows;

	cmin = column_min(g_cols);

	if(rmax > 0)
		aug_primary_term_damage(cmin, g_cols-1, 0, rmax);

}
コード例 #4
0
ファイル: cloud_math.cpp プロジェクト: cutun/kazoo
void sparsify_soft_relative_to_row_col_max (
    const MatrixXf & dense,
    MatrixSf & sparse,
    float relthresh,
    bool ignore_diagonal)
{
  ASSERT_LT(0, relthresh);

  LOG("sparsifying " << dense.rows() << " x " << dense.cols()
      << " positive matrix to relative threshold " << relthresh);

  VectorXf row_max;
  VectorXf col_max;

  if (ignore_diagonal) {

    VectorXf diag = dense.diagonal();
    const_cast<MatrixXf &>(dense).diagonal().setZero();

    row_max = dense.rowwise().maxCoeff();
    col_max = dense.colwise().maxCoeff();

    const_cast<MatrixXf &>(dense).diagonal() = diag;

  } else {

    row_max = dense.rowwise().maxCoeff();
    col_max = dense.colwise().maxCoeff();

  }

  const int I = dense.rows();
  const int J = dense.cols();

  sparse.resize(I,J);

  double sum_dense = 0;
  double sum_sparse = 0;

  for (int j = 0; j < J; ++j) {
    for (int i = 0; i < I; ++i) {

      const float dense_ij = dense(i,j);
      sum_dense += dense_ij;

      const float thresh = relthresh * min(row_max(i), col_max(j));
      if (dense_ij > thresh) {

        sparse.insert(i,j) = dense_ij;
        sum_sparse += dense_ij;
      }
    }
  }

  sparse.finalize();

  float density = sparse.nonZeros() / float(I * J);
  float loss = (sum_dense - sum_sparse) / sum_dense;
  LOG("sparsifying to density " << density
      << " loses " << (100 * loss) << "% of mass");
}