public Helper(double massResolution, double minimumAbundance) { Masses = new MassFrequency[1]; Masses[0].Frequency = 1; MassCount = 1; MassResolution = massResolution; MinimumAbundance = minimumAbundance; }
public static MassDistribution NewInstance(IDictionary <double, double> values, double massResolution, double minimumAbundance) { var arrayValues = new MassFrequency[values.Count]; var i = 0; foreach (var value in values) { arrayValues[i].Mass = value.Key; arrayValues[i++].Frequency = value.Value; } var helper = new Helper(arrayValues, arrayValues.Length, massResolution, minimumAbundance); helper.ApplyBinning(); return(new MassDistribution(new SortedDictionary <double, double>(helper.Masses.Take(helper.MassCount).ToDictionary(m => m.Mass, m => m.Frequency)), massResolution, minimumAbundance)); }
private Helper Add(IEnumerable <MassFrequency> rhs, int rhsCount) { var list = new MassFrequency[MassCount * rhsCount]; var i = 0; foreach (var rhsEntry in rhs) { if (rhsCount-- <= 0) { break; } for (var j = MassCount - 1; j >= 0; j--) { list[i].Mass = Masses[j].Mass + rhsEntry.Mass; list[i++].Frequency = Masses[j].Frequency * rhsEntry.Frequency; } } var result = new Helper(list, list.Length, MassResolution, MinimumAbundance); result.ApplyBinning(); return(result); }