}//end BuildCovarianceMatrix private Double[,] ResizeDistanceMatrix(IEnumerable<string> sites) { List<string> siteList = IndexGages.Select(g => g.ID).ToList(); List<Int32> NotIncludedSiteList = new List<Int32>(); siteList.Except(sites).ToList().ForEach(i => NotIncludedSiteList.Add(siteList.FindIndex(id => id.Trim().Equals(i, StringComparison.Ordinal)))); double[,] updatedDistMatrix = new double[this.IndexGages.Count - NotIncludedSiteList.Count, this.IndexGages.Count - NotIncludedSiteList.Count]; Int32 row = 0; Int32 column = 0; try { for (int r = 0; r < DistanceMatrix.GetLength(0); r++) { if (NotIncludedSiteList.Contains(r)) continue; for (int c = 0; c < DistanceMatrix.GetLength(1); c++) { if (NotIncludedSiteList.Contains(c)) continue; updatedDistMatrix[row, column] = DistanceMatrix[r, c]; column++; }//next c column = 0; row++; }//next r } catch (Exception e) { throw new Exception ("Error resizing distance matrix"); } return updatedDistMatrix; }//end MakeGageMatrix
}//end MakeGageMatrix private Double[,] ResizeSiteMatrix(IEnumerable<string> sites) { KrigIndexSite gage; try { IEnumerable<string> excludedSiteList = IndexGages.Select(g => g.ID).Except(sites); List<string> siteList = sites.Except(excludedSiteList).ToList(); double[,] siteMatrix = new double[siteList.Count, 1]; for (int i = 0; i < siteList.Count(); i++) { gage = IndexGages.FirstOrDefault(g => siteList[i].Equals(g.ID, StringComparison.Ordinal)); siteMatrix[i, 0] = gage.DistanceToUngagedPoint; }//next gage return siteMatrix; } catch (Exception) { throw new Exception("Error resizing site Matrix"); } }//end MakeGageMatrix