Ejemplo n.º 1
0
        public static double[][] Convolute(double[][] distrib1, double[][] distrib2,
                                           double massPrecision, double weightCutoff)
        {
            double[] masses1  = distrib1[0];
            double[] masses2  = distrib2[0];
            double[] weights1 = distrib1[1];
            double[] weights2 = distrib2[1];
            double[] masses   = new double[masses1.Length * masses2.Length];
            double[] weights  = new double[masses1.Length * masses2.Length];
            int      count    = 0;

            for (int i = 0; i < masses1.Length; i++)
            {
                for (int j = 0; j < masses2.Length; j++)
                {
                    masses[count]  = masses1[i] + masses2[j];
                    weights[count] = weights1[i] * weights2[j];
                    count++;
                }
            }
            int[] o = ArrayUtil.Order(masses);
            masses  = ArrayUtil.SubArray(masses, o);
            weights = ArrayUtil.SubArray(weights, o);
            double[][] x = ChemElement.FilterMasses(masses, weights, null, massPrecision);
            masses  = x[0];
            weights = x[1];
            if (!Double.IsNaN(weightCutoff))
            {
                x       = ChemElement.FilterWeights(masses, weights, null, weightCutoff);
                masses  = x[0];
                weights = x[1];
            }
            return(new double[][] { masses, weights });
        }