本文整理汇总了C#中MathNet.Numerics.LinearAlgebra.Double.SparseMatrix.Row方法的典型用法代码示例。如果您正苦于以下问题:C# SparseMatrix.Row方法的具体用法?C# SparseMatrix.Row怎么用?C# SparseMatrix.Row使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MathNet.Numerics.LinearAlgebra.Double.SparseMatrix
的用法示例。
在下文中一共展示了SparseMatrix.Row方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例2: SpeedOfGetRow
/// <summary>
/// List indexing is 2000x faster than Matrix.Row() or enumeration.
/// </summary>
public static void SpeedOfGetRow()
{
SparseMatrix myMatrix = new SparseMatrix(1000, 1000);
SparseVector myVector = SparseVector.OfVector(Vector.Build.Random(1000));
myVector.CoerceZero(1.8);
for (int i = 0; i < 1000; i++)
{
myMatrix.SetRow(i, myVector);
}
List<Vector<double>> myList = new List<Vector<double>>(myMatrix.EnumerateRows());
Utils.StartTimer();
for (int repeat = 0; repeat < 10; repeat++)
{
for (int i = 0; i < 1000; i++)
{
double foo = myMatrix.Row(i)[0];
}
}
Utils.StopTimer();
Utils.StartTimer();
for (int repeat = 0; repeat < 10; repeat++)
{
foreach(var row in myMatrix.EnumerateRowsIndexed())
{
double foo = row.Item2[0];
}
}
Utils.StopTimer();
Utils.StartTimer();
for (int repeat = 0; repeat < 10; repeat++)
{
for (int i = 0; i < 1000; i++)
{
double foo = myList[i][0];
}
}
Utils.StopTimer();
}
示例3: GetChains
private List<List<int>> GetChains(SparseMatrix path)
{
List<List<int>> chains = new List<List<int>>();
var unusedPoints = Enumerable.Range(0, N).ToList();
int startPoint = unusedPoints.First();
do
{
var chain = new List<int>();
int prevPoint = startPoint, nextPoint;
chain.Add(startPoint);
do
{
nextPoint = path.Row(prevPoint).GetIndexedEnumerator().Select(p => p.Item1).First();
chain.Add(nextPoint);
prevPoint = nextPoint;
} while (nextPoint != startPoint);
chains.Add(chain);
unusedPoints = unusedPoints.Except(chain).ToList();
startPoint = unusedPoints.FirstOrDefault();
} while (unusedPoints.Count != 0);
return chains;
}