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


C# SparseVector.DotProduct方法代码示例

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


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

示例1: TestVelocityOnPlane

        public void TestVelocityOnPlane()
        {
            Frisbee.SimulationState st = new Frisbee.SimulationState
                                             {
                                                 VX = 1,
                                                 VY = 1,
                                                 Theta = Math.PI / 4
                                             };

            Matrix<double> transformation =
                new SparseMatrix(new [,]
                                     {
                                         {st.CosTheta, st.SinTheta*st.SinPhi, -st.SinTheta*st.CosPhi},
                                         {0, st.CosPhi, st.SinPhi},
                                         {st.SinTheta, -st.CosTheta*st.SinPhi, st.CosTheta*st.CosPhi}
                                     });

            SparseVector c3 = new SparseVector(transformation.Row(2));

            SparseVector velocity = new SparseVector(new[] { st.VX, st.VY, st.VZ });
            double velocityMagnitude = velocity.Norm(2);

            double velocityC3 = velocity.DotProduct(c3);

            Vector<double> vp = velocity.Subtract(c3.Multiply(velocityC3));
            double vpMagnitude = vp.Norm(2);
        }
开发者ID:joproulx,项目名称:FrisbeeSimulator,代码行数:27,代码来源:UnitTest1.cs

示例2: CosineR

 private static double CosineR(SparseVector Vector_a, SparseVector Vector_b)
 {
     return Vector_a.DotProduct(Vector_b) / (Vector_a.L2Norm() * Vector_b.L2Norm());
     //return Distance.Cosine(R.Row(a).ToArray(), R.Row(b).ToArray());
 }
开发者ID:lawrencewu,项目名称:RecSys,代码行数:5,代码来源:Metric.cs

示例3: CanDotProductOfTwoSparseVectors

        public void CanDotProductOfTwoSparseVectors()
        {
            var vectorA = new SparseVector(10000);
            vectorA[200] = 1;
            vectorA[500] = 3;
            vectorA[800] = 5;
            vectorA[100] = 7;
            vectorA[900] = 9;

            var vectorB = new SparseVector(10000);
            vectorB[300] = 3;
            vectorB[500] = 5;
            vectorB[800] = 7;

            Assert.AreEqual(50.0, vectorA.DotProduct(vectorB));
        }
开发者ID:jhashemi,项目名称:mathnet-numerics,代码行数:16,代码来源:SparseVectorTest.cs

示例4: Window_Loaded

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            double theta = 45D*Math.PI/180D, phi = 0D*Math.PI/180D;

            //double x = Math.Sin(angle);
            //double y = -Math.Cos(angle) * Math.Sin(0D);
            //double z = Math.Cos(angle) * Math.Cos(0D);

            //SparseVector vectorSpeed = new SparseVector(new double[]{1D, 1D, 1D });
            //SparseVector vectorC3 = new SparseVector(new double[]{x, y, z });
            //double dotProduct = vectorSpeed.DotProduct(vectorC3);
            //Vector<double> subtract = vectorSpeed.Subtract(vectorC3.Multiply(dotProduct));

            //m_axeXZ.AddPoint(0.5, 0.5);
            //m_axeXZ.AddPoint(subtract[0], subtract[1]);

            Matrix<double> transformation =
                //new SparseMatrix(new double[,]
                //                     {
                //                         {Math.Cos(theta), Math.Sin(theta)*Math.Sin(phi), -Math.Sin(theta)*Math.Cos(phi)},
                //                         {0, Math.Cos(phi), Math.Cos(phi)},
                //                         {Math.Sin(theta), -Math.Cos(theta)*Math.Cos(phi), Math.Cos(theta)*Math.Cos(phi)}
                //                     });

                new SparseMatrix(new double[,]
                                     {
                                         {0, 0, 0},
                                         {0, 0, 0},
                                         {Math.Sin(theta), -Math.Cos(theta)*Math.Cos(phi), Math.Cos(theta)*Math.Cos(phi)}
                                     });

            //SparseVector vectorSpeed = new SparseVector(new double[] { 1D, 0D, 0D });

            //Vector<double> multiply = transformation.Multiply(vectorSpeed);

            //DisplayVector(multiply);

            SparseVector vectorC3 = new SparseVector(new double[] { 0D, 0D, 1D });
            SparseVector vectorSpeed = new SparseVector(new double[] { Math.Cos(Math.PI / 4), 0D, Math.Sin(Math.PI / 4) });

            double dotProduct = vectorSpeed.DotProduct(vectorC3);
        }
开发者ID:joproulx,项目名称:FrisbeeSimulator,代码行数:42,代码来源:MainWindow.xaml.cs


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