当前位置: 首页>>代码示例>>C#>>正文


C# DenseVector.Normalize方法代码示例

本文整理汇总了C#中MathNet.Numerics.LinearAlgebra.Double.DenseVector.Normalize方法的典型用法代码示例。如果您正苦于以下问题:C# DenseVector.Normalize方法的具体用法?C# DenseVector.Normalize怎么用?C# DenseVector.Normalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MathNet.Numerics.LinearAlgebra.Double.DenseVector的用法示例。


在下文中一共展示了DenseVector.Normalize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BhattacharyyaDistance

        /// <summary>
        /// The bhattacharyya distance.
        /// </summary>
        /// <param name="observedIsotopicPeakList">
        /// The observed isotopic peak list.
        /// </param>
        /// <param name="expectedIsotopicPeakList">
        /// The actual isotopic peak list.
        /// </param>
        /// <returns>
        /// The <see cref="double"/>.
        /// </returns>
        private static double BhattacharyyaDistance(List<double> observedIsotopicPeakList, List<Peak> expectedIsotopicPeakList)
        {
            // calculate angle between two isotopic vectors in the isotopic space
            double[] actualIsotopicPeakListArray = expectedIsotopicPeakList.Select(x => (double)x.Height).ToArray();
            Vector<double> A = new DenseVector(observedIsotopicPeakList.ToArray());
            Vector<double> B = new DenseVector(actualIsotopicPeakListArray);
            A = A.Normalize(2);
            B = B.Normalize(2);
            Vector<double> C = A.PointwiseMultiply(B);

            // Pointwise sqrt. Implements here because Math.Net.2.5 doesn't supports Pointwise exp getting Math.Net 3.5 introducces
            // package compatibility issues with Informed Proteomics / Multidimensional peak finding, etc.
            // TODO: Use PointwiseExponent after getting Math.net 3.5
            double[] cArray = C.ToArray();
            int size = cArray.Count();
            double sum = 0;
            for (int i = 0; i < size; i++)
            {
                cArray[i] = Math.Sqrt(cArray[i]);
                sum += cArray[i];
            }

            return sum;
        }
开发者ID:PNNL-Comp-Mass-Spec,项目名称:IMS-Informed-Library,代码行数:36,代码来源:FeatureScoreUtilities.cs

示例2: EuclideanAlternative

        /// <summary>
        /// The bhattacharyya distance.
        /// </summary>
        /// <param name="observedIsotopicPeakList">
        /// The observed isotopic peak list.
        /// </param>
        /// <param name="expectedIsotopicPeakList">
        /// The actual isotopic peak list.
        /// </param>
        /// <returns>
        /// The <see cref="double"/>.
        /// </returns>
        private static double EuclideanAlternative(List<double> observedIsotopicPeakList, List<Peak> expectedIsotopicPeakList)
        {
            // calculate angle between two isotopic vectors in the isotopic space
            double[] expectedIsotopicPeakIntensityArray = expectedIsotopicPeakList.Select(x => (double)x.Height).ToArray();
            Vector<double> A = new DenseVector(observedIsotopicPeakList.ToArray());
            Vector<double> B = new DenseVector(expectedIsotopicPeakIntensityArray);
            A = A.Normalize(2);
            B = B.Normalize(2);

            // calculate the euclidean distance between theoretical distribution and observed pattern
            double isotopicScore = 0;
            for (int i = 1; i < expectedIsotopicPeakList.Count; i++)
            {
                double diff = A[i] - B[i];
                isotopicScore += diff * diff;
            }

            // Map the score to [0, 1]
            return ScoreUtil.MapToZeroOneTrignometry(Math.Sqrt(isotopicScore), true, 0.03);
        }
开发者ID:PNNL-Comp-Mass-Spec,项目名称:IMS-Informed-Library,代码行数:32,代码来源:FeatureScoreUtilities.cs

示例3: computeTransform

        private void computeTransform()
        {
            Func<SkeletonPoint, Vector<double>> conv = (sp) => new DenseVector(new double[] { sp.X, sp.Y, sp.Z });
            p0 = conv(dBlue.Value);
            var p1 = conv(dRed.Value);
            var p2 = conv(dYellow.Value);

            f2 = (p1 - p0).Normalize(1);
            f1 = (p2 - p0).Normalize(1);
            f1 = (f1 - (f1.DotProduct(f2) * f2)).Normalize(1);
            f3 = new DenseVector(new double[] { f1[1] * f2[2] - f1[2] * f2[1], f1[2] * f2[0] - f1[0] * f2[2], f1[0] * f2[1] - f1[1] * f2[0] });
            f3 = f3.Normalize(1);
            IsValid = true;
        }
开发者ID:virrkharia,项目名称:dynamight,代码行数:14,代码来源:KinectCalibrationWindow.xaml.cs


注:本文中的MathNet.Numerics.LinearAlgebra.Double.DenseVector.Normalize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。