private void CopyRegionTo(ManagedStorage <T> target, MatrixRegion region)
        {
            switch (region)
            {
            case MatrixRegion.All:
                CopySubMatrixTo(target, 0, 0, RowCount, 0, 0, ColumnCount);
                break;

            case MatrixRegion.LowerTriangle:
                for (int i = 0; i < RowCount; ++i)
                {
                    for (int j = 0; j <= i; ++j)
                    {
                        target[i, j] = this[i, j];
                    }
                }
                break;

            case MatrixRegion.UpperTriangle:
                for (int i = 0; i < RowCount; ++i)
                {
                    for (int j = i; j < ColumnCount; ++j)
                    {
                        target[i, j] = this[i, j];
                    }
                }
                break;
            }
        }
        internal override NArrayStorage <T> Clone(MatrixRegion region = MatrixRegion.All)
        {
            if (RowCount != ColumnCount && region != MatrixRegion.All)
            {
                throw new ArgumentException("only square matrices can be upper or lower triangular");
            }
            var clone = new ManagedStorage <T>(RowCount, ColumnCount);

            CopyRegionTo(clone, region);
            return(clone);
        }
Example #3
0
        public GameScene(Vector2 sceneSize, Vector2 regionSize)
        {
            MatrixRegion         = new MatrixRegion <IGameObject>(sceneSize, regionSize);
            GameObjectCollection = new GameObjectCollection();
            GamePlayerSpawnData  = new GamePlayerSpawnData();

            var lowerBound = new Vector2(-100, -100);
            var upperBound = new Vector2(100, 100);
            var gravity    = new Vector2(0, 0 /* -9.81f */);

            PhysicsWorldManager = new PhysicsWorldManager(lowerBound, upperBound, gravity);
            PhysicsExecutor     = new PhysicsExecutor(OnUpdateBodies, OnSimulatePhysics);
        }
 internal override NArrayStorage <T> Clone(MatrixRegion region = MatrixRegion.All)
 {
     throw new NotImplementedException();
 }
Example #5
0
 public void Dispose()
 {
     MatrixRegion?.Dispose();
     PhysicsExecutor?.Dispose();
     PhysicsWorldManager?.Dispose();
 }
 public void CountRegionNonZeros(MatrixRegion region, 
     int expectedResult, int nodeCount, string entries)
 {
     var fullMatrix = GetDoubleMatrix(Guid.NewGuid(), nodeCount, entries);
     Assert.Equal(expectedResult, fullMatrix.CountRegionNonZeros(region));
 }
 public void SumRegion(MatrixRegion region, double expectedResult, 
     int nodeCount, string entries)
 {
     var fullMatrix = GetDoubleMatrix(Guid.NewGuid(), nodeCount, entries);
     Assert.Equal(expectedResult, fullMatrix.SumRegion(region));
 }
 /// <summary>
 /// Crates a copy of the storage in new memory.
 /// </summary>
 /// <param name="region">THe region to clone</param>
 /// <returns></returns>
 internal abstract NArrayStorage <T> Clone(MatrixRegion region = MatrixRegion.All);