本文整理汇总了C#中MatrixD类的典型用法代码示例。如果您正苦于以下问题:C# MatrixD类的具体用法?C# MatrixD怎么用?C# MatrixD使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MatrixD类属于命名空间,在下文中一共展示了MatrixD类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ConstructorException2
public void ConstructorException2()
{
MatrixD m = new MatrixD(new double[,] {{ 1, 2 },
{ 3, 4 },
{ 5, 6 }});
new EigenvalueDecompositionD(m);
}
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:7,代码来源:EigenvalueDecompositionDTest.cs
示例2: Test1
public void Test1()
{
MatrixD a = new MatrixD(new double[,] { { 2, -1, 0},
{ -1, 2, -1},
{ 0, -1, 2} });
CholeskyDecompositionD d = new CholeskyDecompositionD(a);
Assert.AreEqual(true, d.IsSymmetricPositiveDefinite);
MatrixD l = d.L;
Assert.AreEqual(0, l[0, 1]);
Assert.AreEqual(0, l[0, 2]);
Assert.AreEqual(0, l[1, 2]);
Assert.IsTrue(MatrixD.AreNumericallyEqual(a, l * l.Transposed));
Assert.IsTrue(MatrixD.AreNumericallyEqual(a, l * l.Transposed));
// Check solving of linear equations.
MatrixD x = new MatrixD(new double[,] { { 1, 2},
{ 3, 4},
{ 5, 6} });
MatrixD b = a * x;
Assert.IsTrue(MatrixD.AreNumericallyEqual(x, d.SolveLinearEquations(b)));
}
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:28,代码来源:CholeskyDecompositionDTest.cs
示例3: TestRandomA
public void TestRandomA()
{
RandomHelper.Random = new Random(1);
for (int i = 0; i < 100; i++)
{
// Create A.
MatrixD a = new MatrixD(3, 3);
RandomHelper.Random.NextMatrixD(a, 0, 1);
LUDecompositionD d = new LUDecompositionD(a);
if (d.IsNumericallySingular == false)
{
// Check solving of linear equations.
MatrixD b = new MatrixD(3, 2);
RandomHelper.Random.NextMatrixD(b, 0, 1);
MatrixD x = d.SolveLinearEquations(b);
MatrixD b2 = a * x;
Assert.IsTrue(MatrixD.AreNumericallyEqual(b, b2, 0.01));
MatrixD aPermuted = d.L * d.U;
Assert.IsTrue(MatrixD.AreNumericallyEqual(aPermuted, a.GetSubmatrix(d.PivotPermutationVector, 0, 2)));
}
}
}
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:27,代码来源:LUDecompositionDTest.cs
示例4: TestMatricesWithoutFullRank
public void TestMatricesWithoutFullRank()
{
MatrixD a = new MatrixD(3, 3);
SingularValueDecompositionD svd = new SingularValueDecompositionD(a);
Assert.AreEqual(0, svd.NumericalRank);
Assert.AreEqual(svd.SingularValues[0], svd.Norm2);
double condNumber = svd.ConditionNumber;
a = new MatrixD(new double[,] { { 1, 2, 3 }, { 4, 5, 6 }, { 4, 5, 6 } });
svd = new SingularValueDecompositionD(a);
Assert.AreEqual(2, svd.NumericalRank);
Assert.AreEqual(svd.SingularValues[0], svd.Norm2);
Assert.IsTrue(MatrixD.AreNumericallyEqual(a, svd.U * svd.S * svd.V.Transposed));
svd = new SingularValueDecompositionD(a.Transposed);
Assert.AreEqual(2, svd.NumericalRank);
Assert.IsTrue(MatrixD.AreNumericallyEqual(a.Transposed, svd.U * svd.S * svd.V.Transposed));
Assert.IsTrue(MatrixD.AreNumericallyEqual(a.Transposed, svd.U * svd.S * svd.V.Transposed)); // Repeat to test with cached values.
Assert.AreEqual(svd.SingularValues[0], svd.Norm2);
condNumber = svd.ConditionNumber;
a = new MatrixD(new double[,] { { 1, 2 }, { 1, 2 }, { 1, 2 } });
svd = new SingularValueDecompositionD(a);
Assert.AreEqual(1, svd.NumericalRank);
Assert.IsTrue(MatrixD.AreNumericallyEqual(a, svd.U * svd.S * svd.V.Transposed));
Assert.AreEqual(svd.SingularValues[0], svd.Norm2);
condNumber = svd.ConditionNumber;
}
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:27,代码来源:SingularValueDecompositionDTest.cs
示例5: MyClipmapHandler
internal MyClipmapHandler(uint id, MyClipmapScaleEnum scaleGroup, MatrixD worldMatrix, Vector3I sizeLod0, RenderFlags additionalFlags)
{
m_clipmapBase = new MyClipmap(id, scaleGroup, worldMatrix, sizeLod0, this);
m_renderFlags = additionalFlags;
MyClipmap.AddToUpdate(MyEnvironment.CameraPosition, m_clipmapBase);
}
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:7,代码来源:MyClipmapHandler.cs
示例6: OnWorldPositionChanged
public override void OnWorldPositionChanged(ref MatrixD worldMatrix)
{
var forward = worldMatrix.Forward;
m_origin = worldMatrix.Translation + forward * m_originOffset;
FrontPoint = m_origin + m_rayLength * forward;
Center = (m_origin + FrontPoint) * 0.5f;
}
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:7,代码来源:MyDrillSensorRaycast.cs
示例7: MyRenderAtmosphere
public MyRenderAtmosphere(uint id, string debugName, string model, MatrixD worldMatrix, MyMeshDrawTechnique drawTechnique, RenderFlags renderFlags, float atmosphereRadius, float planetRadius, Vector3 atmosphereWavelengths)
: base(id, debugName,model, worldMatrix,drawTechnique, renderFlags)
{
m_atmosphereWavelengths = atmosphereWavelengths;
m_atmosphereRadius = atmosphereRadius;
m_planetRadius = planetRadius;
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:7,代码来源:MyRenderAtmosphere.cs
示例8: CreateCell
public IMyClipmapCell CreateCell(MyClipmapScaleEnum scaleGroup, MyCellCoord cellCoord, ref MatrixD worldMatrix)
{
var cell = new MyClipmapCellProxy(cellCoord, ref worldMatrix, m_massiveCenter, m_massiveRadius, m_renderFlags);
cell.SetVisibility(false);
cell.ScaleGroup = scaleGroup;
return cell;
}
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:7,代码来源:MyClipmapHandler.cs
示例9: TestToVector
public void TestToVector()
{
var m1 = new MatrixD(new double[] { 1, 2, 3, 4 }, 2, 2);
var v1 = m1.ToVector();
Assert.AreEqual<VectorD>(new VectorD(1, 2, 3, 4), v1);
}
开发者ID:umebayashi,项目名称:mathmatix.net,代码行数:7,代码来源:MatrixTest.cs
示例10: MyLodMeshMerge
internal MyLodMeshMerge(MyClipmap parentClipmap, int lod, int lodDivisions, ref MatrixD worldMatrix, ref Vector3D massiveCenter, float massiveRadius, RenderFlags renderFlags)
{
Debug.Assert(parentClipmap != null, "Parent clipmap cannot be null");
Debug.Assert(lod >= 0, "Lod level must be non-negative");
Debug.Assert(lodDivisions >= 0, "Invalid number of lod divisions");
m_parentClipmap = parentClipmap;
m_lod = lod;
m_lodDivisions = lodDivisions;
if (m_lodDivisions <= 0)
return;
m_dirtyProxyIndices = new HashSet<int>();
m_cellProxyToAabbProxy = new Dictionary<MyClipmapCellProxy, int>();
m_boundingBoxes = new MyDynamicAABBTreeD(Vector3D.Zero);
int cellCount = lodDivisions*lodDivisions*lodDivisions;
m_mergeJobs = new MergeJobInfo[cellCount];
m_mergedLodMeshProxies = new MyClipmapCellProxy[cellCount];
m_trackedActors = new HashSet<MyActor>[cellCount];
for (int divideIndex = 0; divideIndex < cellCount; ++divideIndex)
{
m_mergedLodMeshProxies[divideIndex] = new MyClipmapCellProxy(new MyCellCoord(Lod, GetCellFromDivideIndex(divideIndex)), ref worldMatrix, massiveCenter, massiveRadius, renderFlags, true);
m_mergeJobs[divideIndex] = new MergeJobInfo { CurrentWorkId = 0, LodMeshesBeingMerged = new List<LodMeshId>(), NextPossibleMergeStartTime = MyCommon.FrameCounter };
m_trackedActors[divideIndex] = new HashSet<MyActor>();
m_dirtyProxyIndices.Add(divideIndex);
}
}
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:29,代码来源:MyLodMeshMergeHandler.cs
示例11: MyRenderBatch
public MyRenderBatch(uint id, string debugName, MatrixD worldMatrix, RenderFlags renderFlags, List<MyRenderBatchPart> batchParts)
: base(id, debugName, worldMatrix, renderFlags)
{
m_localAABB = BoundingBoxD.CreateInvalid();
m_batchParts.Clear();
m_batchParts.AddList(batchParts);
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:7,代码来源:MyRenderBatch.cs
示例12: PrincipalComponentAnalysisD
//--------------------------------------------------------------
/// <summary>
/// Creates the principal component analysis for the given list of points.
/// </summary>
/// <param name="points">
/// The list of data points. All points must have the same
/// <see cref="VectorD.NumberOfElements"/>.
/// </param>
/// <exception cref="ArgumentNullException">
/// <paramref name="points"/> is <see langword="null"/>.
/// </exception>
/// <exception cref="ArgumentException">
/// <paramref name="points"/> is empty.
/// </exception>
public PrincipalComponentAnalysisD(IList<VectorD> points)
{
if (points == null)
throw new ArgumentNullException("points");
if (points.Count == 0)
throw new ArgumentException("The list of points is empty.");
// Compute covariance matrix.
MatrixD covarianceMatrix = StatisticsHelper.ComputeCovarianceMatrix(points);
// Perform Eigenvalue decomposition.
EigenvalueDecompositionD evd = new EigenvalueDecompositionD(covarianceMatrix);
int numberOfElements = evd.RealEigenvalues.NumberOfElements;
Variances = new VectorD(numberOfElements);
V = new MatrixD(numberOfElements, numberOfElements);
// Sort eigenvalues by decreasing value.
// Since covarianceMatrix is symmetric, we have no imaginary eigenvalues.
for (int i = 0; i < Variances.NumberOfElements; i++)
{
int index = evd.RealEigenvalues.IndexOfLargestElement;
Variances[i] = evd.RealEigenvalues[index];
V.SetColumn(i, evd.V.GetColumn(index));
evd.RealEigenvalues[index] = double.NegativeInfinity;
}
}
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:43,代码来源:PrincipalComponentAnalysisD.cs
示例13: Spawn
public MyEntity Spawn(MyFixedPoint amount, MatrixD worldMatrix, MyEntity owner = null)
{
if (Content is MyObjectBuilder_BlockItem)
{
Debug.Assert(MyFixedPoint.IsIntegral(amount), "Spawning fractional number of grids!");
var blockItem = Content as MyObjectBuilder_BlockItem;
var builder = MyObjectBuilderSerializer.CreateNewObject(typeof(MyObjectBuilder_CubeGrid)) as MyObjectBuilder_CubeGrid;
builder.GridSizeEnum = MyCubeSize.Small;
builder.IsStatic = false;
builder.PersistentFlags |= MyPersistentEntityFlags2.InScene | MyPersistentEntityFlags2.Enabled;
builder.PositionAndOrientation = new MyPositionAndOrientation(worldMatrix);
var block = MyObjectBuilderSerializer.CreateNewObject(blockItem.BlockDefId) as MyObjectBuilder_CubeBlock;
builder.CubeBlocks.Add(block);
MyCubeGrid firstGrid = null;
for (int i = 0; i < amount; ++i)
{
builder.EntityId = MyEntityIdentifier.AllocateId();
block.EntityId = MyEntityIdentifier.AllocateId();
MyCubeGrid newGrid = MyEntities.CreateFromObjectBuilder(builder) as MyCubeGrid;
firstGrid = firstGrid ?? newGrid;
MyEntities.Add(newGrid);
Sandbox.Game.Multiplayer.MySyncCreate.SendEntityCreated(builder);
}
return firstGrid;
}
else
return MyFloatingObjects.Spawn(new MyPhysicalInventoryItem(amount, Content),worldMatrix, owner != null ? owner.Physics : null);
}
开发者ID:notten,项目名称:SpaceEngineers,代码行数:31,代码来源:MyPhysicalInventoryItem.cs
示例14:
void IMyClipmapCell.UpdateWorldMatrix(ref VRageMath.MatrixD worldMatrix, bool sortIntoCullObjects)
{
m_worldMatrix = worldMatrix;
Matrix m = m_worldMatrix * Matrix.CreateScale(m_scale) * Matrix.CreateTranslation(m_translation);
m_actor.SetMatrix(ref m);
}
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:7,代码来源:MyClipmapHandler.cs
示例15: DeterminantException
public void DeterminantException()
{
MatrixD a = new MatrixD(new double[,] { { 1, 2 }, { 5, 6 }, { 0, 1 } });
LUDecompositionD d = new LUDecompositionD(a);
double det = d.Determinant;
}
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:7,代码来源:LUDecompositionDTest.cs
示例16: SolveLinearEquationsException1
public void SolveLinearEquationsException1()
{
// Create A.
MatrixD a = new MatrixD(new double[,] { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, -9 } });
QRDecompositionD decomp = new QRDecompositionD(a);
decomp.SolveLinearEquations(null);
}
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:8,代码来源:QRDecompositionDTest.cs
示例17: MyRenderVoxelCell
public MyRenderVoxelCell(MyClipmapScaleEnum scaleGroup, MyCellCoord coord, ref MatrixD worldMatrix)
: base(0, "MyRenderVoxelCell", RenderFlags.Visible | RenderFlags.CastShadows, CullingOptions.VoxelMap)
{
m_scaleGroup = scaleGroup;
m_coord = coord;
m_worldMatrix = worldMatrix;
m_fakeVoxelMaterial.DrawTechnique = MyMeshDrawTechnique.VOXEL_MAP;
}
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:8,代码来源:MyRenderVoxelCell.cs
示例18: SetViewMatrix
public void SetViewMatrix(ref MatrixD viewMatrix)
{
MyUtils.AssertIsValid(viewMatrix);
this.m_viewMatrix = viewMatrix;
MatrixD.Invert(ref viewMatrix, out m_worldMatrix);
MyUtils.AssertIsValid(m_worldMatrix);
Update();
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:8,代码来源:MyBaseShadowCamera.cs
示例19: AddMatrix
public void AddMatrix()
{
MatrixD m1 = new MatrixD(3, 4, rowMajor, MatrixOrder.RowMajor);
MatrixD m2 = new MatrixD(3, 4, rowMajor, MatrixOrder.RowMajor) * (-3);
MatrixD result = MatrixD.Add(m1, m2);
for (int i = 0; i < 12; i++)
Assert.AreEqual(-rowMajor[i] * 2, result[i]);
}
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:8,代码来源:MatrixDTest.cs
示例20:
void IMyClipmapCell.UpdateWorldMatrix(ref VRageMath.MatrixD worldMatrix, bool sortIntoCullObjects)
{
m_worldMatrix = worldMatrix;
MatrixD m = MatrixD.CreateScale(m_scale) * MatrixD.CreateTranslation(m_translation) * m_worldMatrix;
m_actor.SetMatrix(ref m);
m_actor.SetAabb((BoundingBoxD)m_localAabb.Transform(m_worldMatrix));
}
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:8,代码来源:MyClipmapCellProxy.cs
注:本文中的MatrixD类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论