Example #1
0
        /// <summary>
        /// This method calculate the distances between all points
        /// </summary>
        private void CalculateDistancesLag()
        {
            double[] mdisv ;
            double mdis;
            double msem = 0d;

            
            Parallel.For(0,this.npoints, i =>
           {

               Parallel.For(0, this.npoints, j =>
              {
                  mdisv = this.MdistancesXY(i, j);
                  msem = this.MsemiVarEmp(i, j);
                  mdis = this.Mdistances(i, j);

                  if (mdisv[0] != 0 && mdisv[1] != 0)
                  {


                      int[] cells = lag.Cells(i, j, mdisv[0], mdisv[1], GetAzimuth(i, j));

                      int lim = lag.numLags;
                      Stat semi = new Stat(msem);
                      Covariance cov = new Covariance(this.kpoints[j].W, this.kpoints[i].W);
                      Stat dist = new Stat(mdis);

                      //distance += dist;
                      //semivariance += semi;
                      //  covariance += new cov;
                      int v = (this.NumberOfLags * 2) - 1;
                      if (CheckBorder(cells[2]) && CheckBorder(cells[0]))
                      {
                          spatConti[cells[2], cells[0]] += semi;
                          spatContiCov[cells[2], cells[0]] += cov;
                          spatDist[cells[2], cells[0]] += dist;

                          spatConti[v - cells[2], v - cells[0]] += semi;
                          spatContiCov[v - cells[2], v - cells[0]] += cov;
                          spatDist[v - cells[2], v - cells[0]] += dist;

                      }

                      if (CheckBorder(cells[3]) && CheckBorder(cells[0]))
                      {
                          spatConti[cells[3], cells[0]] += semi;
                          spatContiCov[cells[3], cells[0]] += cov;
                          spatDist[cells[3], cells[0]] += dist;

                          spatConti[v - cells[3], v - cells[0]] += semi;
                          spatContiCov[v - cells[3], v - cells[0]] += cov;
                          spatDist[v - cells[3], v - cells[0]] += dist;

                      }
                      if (CheckBorder(cells[2]) && CheckBorder(cells[1]))
                      {
                          spatConti[cells[2], cells[1]] += semi;
                          spatContiCov[cells[2], cells[1]] += cov;
                          spatDist[cells[2], cells[1]] += dist;

                          spatConti[v - cells[2], v - cells[1]] += semi;
                          spatContiCov[v - cells[2], v - cells[1]] += cov;
                          spatDist[v - cells[2], v - cells[1]] += dist;
                      }
                      if (CheckBorder(cells[3]) && CheckBorder(cells[1]))
                      {
                          spatConti[cells[3], cells[1]] += semi;
                          spatContiCov[cells[3], cells[1]] += cov;
                          spatDist[cells[3], cells[1]] += dist;

                          spatConti[v - cells[3], v - cells[1]] += semi;
                          spatContiCov[v - cells[3], v - cells[1]] += cov;
                          spatDist[v - cells[3], v - cells[1]] += dist;
                      }
                  }

              });
            });
        }
Example #2
0
		Covariance(Covariance cc1, double v1, Covariance cc2, double v2)
		{
			this.vi = cc1.vi + cc2.vi;
			this.vj = cc1.vj + cc2.vj;
			// this.value = cc1.value;
			this.value = v1 + v2;
		}
Example #3
0
        private void Grid() {

            if (lag == null)
                return;


           spatConti= new Stat[lag.numLags*2,lag.numLags*2] ;
           spatContiCov = new Covariance[lag.numLags * 2, lag.numLags * 2];
           spatDist = new Stat[lag.numLags * 2, lag.numLags * 2];
            for(int row=0; row<lag.numLags*2;row++ )
            {
              for(int col=0; col<lag.numLags*2;col++ )
              {
                 spatConti[row,col]=new Stat(true);
                 spatContiCov[row, col] = new Covariance(true);
                 spatDist[row, col] = new Stat(true);
              }
            }
        }