예제 #1
0
bool cans(int lx, int ly, int rx, int ry)
{
  int lz = z[lx][ly]*2+1, dx = (rx-lx)*2, dy = (ry-ly)*2, dz = (z[rx][ry] - z[lx][ly]) * 2, sx = abs(dx), sy = abs(dy), xsgn = dx > 0 ?1 : -1, ysgn = dy > 0 ? 1 : -1;

  if (dx)
    for (int i = 1, ny, ty, nx, nz; i < sx; i += 2) {
      nx = lx + i / 2 * xsgn, ny = ly + calc(sx, sy, i) * ysgn, ty = ly + calcc(sx, sy, i) * ysgn;
      nz = dz * i;
      if (nz < (z[nx][ny] * 2 - lz) * sx || nz < (z[nx + xsgn][ty] * 2 - lz) * sx) return 0;
    }

  if (dy)
    for (int i = 1, ny, tx, nx, nz; i < sy; i += 2) {
      ny = ly + i / 2 * ysgn, nx = lx + calc(sy, sx, i) * xsgn, tx = lx + calcc(sy, sx, i) * xsgn;
      nz = dz * i;
      if (nz < (z[nx][ny] * 2 - lz) * sy || nz < (z[tx][ny + ysgn] * 2 - lz) * sy) return 0;
    }

  return 1;
}
예제 #2
0
파일: CalcWmML.cpp 프로젝트: mghandi/gkmSVM
CCalcWmML::CCalcWmML(int L, int K, int b)
{
	this->L = L; 
	this->K = K; 
	this->b = b; 

	wm = new double [K+1]; 
	kernel = new double [L+1]; 
	kernelTruncated = new double [L+1]; 


	c = new double [L+1]; //c_m : the inner product of all L-merEsts for two L-mer with m mismatches 
	cTr = new double [L+1]; // c using truncated g. 
	h = new double [L+1]; // h_m : for inner product of all gapped-kmer counts . 

	calcwm(); 
	calcKernel(); 
	calcc(); 

}