예제 #1
0
        public virtual void SetShort(short[,,,] v, BAsyncResult <Object> asyncResult)
        {
            BRequest_RemoteArrayTypes4dim_setShort req = new BRequest_RemoteArrayTypes4dim_setShort();

            req.vValue = v;
            transport.sendMethod(req, asyncResult);
        }
예제 #2
0
        public virtual void SetShort(short[,,,] v)
        {
            BSyncResult <Object> asyncResult = new BSyncResult <Object>();

            SetShort(v, BAsyncResultHelper.ToDelegate <Object>(asyncResult));
            asyncResult.GetResult();
        }
예제 #3
0
        public override void write(Object obj1, BOutput bout1, long version)
        {
            BOutputBin bout = (BOutputBin)bout1;
            BBufferBin bbuf = bout.bbuf;

            short[,,,] arr = (short[, , , ])obj1;

            // lengths
            int n3 = arr.GetLength(0);
            int n2 = arr.GetLength(1);
            int n1 = arr.GetLength(2);
            int n0 = arr.GetLength(3);

            bbuf.putLength(n3);
            bbuf.putLength(n2);
            bbuf.putLength(n1);
            bbuf.putLength(n0);

            // write
            for (int i3 = 0; i3 < n3; i3++)
            {
                for (int i2 = 0; i2 < n2; i2++)
                {
                    for (int i1 = 0; i1 < n1; i1++)
                    {
                        for (int i0 = 0; i0 < n0; i0++)
                        {
                            bbuf.putShort(arr[i3, i2, i1, i0]);
                        }
                    }
                }
            }
        }
예제 #4
0
 public void Init(short a_kClock, short a_16NumOfCops, short a_16NumOfWalls, short a_16NumOfGates, short a_16SizeOfWalls, short a_16SizeOfGates)
 {
     kClock   = a_kClock;
     ThiefPos = new short[kClock, 2];
     CopsPos  = new short[kClock, a_16NumOfCops, 2];
     WallsPos = new short[kClock, a_16NumOfWalls, a_16SizeOfWalls, 2];
     GatesPos = new short[kClock, a_16NumOfGates, a_16SizeOfGates, 2];
 }
예제 #5
0
        // checkpoint byps.gen.cs.GenRemoteStub:133
        public async Task SetShortAsync(short[,,,] v)
        {
            BRequest_RemoteArrayTypes4dim_setShort req = new BRequest_RemoteArrayTypes4dim_setShort();

            req.vValue = v;
            Task <Object> task = Task <Object> .Factory.FromAsync(transport.BeginSend <Object>, transport.EndSend <Object>, req, null);

            await task;
        }
예제 #6
0
 public static SuperArray Create(short[,,,] data) => Data.CreateArray(data);
예제 #7
0
 public static extern af_err af_get_data_ptr([Out] short[,,,] data, IntPtr array_arr);
예제 #8
0
 public static extern af_err af_write_array(IntPtr array_arr, [In] short[,,,] data, UIntPtr size_bytes, af_source src);
예제 #9
0
 public static extern af_err af_create_array(out IntPtr array_arr, [In] short[,,,] data, uint ndims, [In] long[] dim_dims, af_dtype type);
예제 #10
0
    void UpdateInterWaterParticleCollision(float3 minPosition, float3 maxPosition)
    {
        //cache it
        int resolutionCube = marchingCubeResolution * marchingCubeResolution * marchingCubeResolution;

        if (waterParticleCountPerVoxel == null || waterParticleCountPerVoxel.Length != resolutionCube)
        {
            waterParticleCollisionTensor     = new short[marchingCubeResolution, marchingCubeResolution, marchingCubeResolution, maxWaterParticlePerZone];
            waterParticleCountPerVoxel       = new byte[marchingCubeResolution, marchingCubeResolution, marchingCubeResolution];
            particleIndicesInCollisionTensor = new int3[particleCount];
        }
        else
        {
            Array.Clear(waterParticleCollisionTensor, 0, resolutionCube * maxWaterParticlePerZone);
            Array.Clear(waterParticleCountPerVoxel, 0, resolutionCube);
            Array.Clear(particleIndicesInCollisionTensor, 0, particleCount);
        }

        //float3 minPosition = cubeMarchineZone.bounds.min;
        //float3 maxPosition = cubeMarchineZone.bounds.max;
        float invResolution = 1f / marchingCubeResolution;
        float step          = math.distance(minPosition, maxPosition) * invResolution;
        float invStep       = 1f / step;

        //Broad phase
        for (int i = 0; i < particleCount; i++)
        {
            WaterParticle particle = waterParticles[i];
            int3          index    = WaterMarchingCube.GetPositionIndex(particle.position, minPosition, maxPosition, marchingCubeResolution, invStep);
            int           numberOfParticleInVoxel = waterParticleCountPerVoxel[index.x, index.y, index.z];
            if (numberOfParticleInVoxel < maxWaterParticlePerZone)
            {
                //Store the index of the particle in the grid
                particleIndicesInCollisionTensor[i] = index;
                waterParticleCollisionTensor[index.x, index.y, index.z, numberOfParticleInVoxel] = (short)i;
                waterParticleCountPerVoxel[index.x, index.y, index.z]++;
            }
        }

        //Narrow phase
        for (int i = 0; i < particleCount; i++)
        {
            //TODO check all 26 adjacent cells

            WaterParticle currentParticle         = waterParticles[i];
            int3          index                   = particleIndicesInCollisionTensor[i];
            int           numberOfParticleInVoxel = waterParticleCountPerVoxel[index.x, index.y, index.z];
            for (int j = 0; j < numberOfParticleInVoxel; j++)
            {
                int otherParticleIndex = waterParticleCollisionTensor[index.x, index.y, index.z, j];

                if (i == otherParticleIndex)
                {
                    break;
                }

                WaterParticle otherParticle = waterParticles[otherParticleIndex];
                float3        diff          = otherParticle.position - currentParticle.position;

                //No collision
                if (math.lengthsq(diff) > particleRadius * particleRadius)
                {
                    continue;
                }

                //TODO custom burstable functions
                //On collision vector keep they rejection, but swap projections
                float3 currentProjection = Vector3.Project(currentParticle.velocity, diff);
                float3 currentRejection  = currentParticle.velocity - currentProjection;

                float3 otherProjection = Vector3.Project(otherParticle.velocity, diff);
                float3 otherRejection  = currentParticle.velocity - otherProjection;

                //Swap
                currentParticle.velocity = (currentRejection + otherProjection) * elasticity;
                otherParticle.velocity   = (otherRejection + currentProjection) * elasticity;

                //currentParticle.position -= diff * particleRadius;
                //otherParticle.position += diff * particleRadius;

                waterParticles[i] = currentParticle;
                waterParticles[otherParticleIndex] = otherParticle;
            }
        }
    }
예제 #11
0
 public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] short[,,,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
예제 #12
0
 public static extern af_err af_get_scalar([Out] short[,,,] output_value, IntPtr array_arr);
예제 #13
0
 public static extern af_err af_free_host([Out] short[,,,] ptr);
예제 #14
0
 public static extern af_err af_free_pinned([Out] short[,,,] ptr);
예제 #15
0
 public static extern af_err af_free_device([Out] short[,,,] ptr);
예제 #16
0
 ///<summary>Constructs a tensor with data.</summary>
 ///<param name = "data">Initial data for the tensor.</param>
 ///<param name = "dtype">The desired data type of returned tensor. Default: if not passed, infers data type from data.</param>
 ///<param name = "requires_grad">If autograd should record operations on the returned tensor. Default: false.</param>
 public static Tensor tensor(short[,,,] data, dtype dtype = torch.dtype.int16, bool requires_grad = false)
 {
     return(new Tensor(data, dtype, requires_grad));
 }
예제 #17
0
 public ArrayTypes4dim(bool[,,,] @boolean4, byte[,,,] @byte4, char[,,,] @char4, short[,,,] @short4, int[,,,] @int4, long[,,,] @long4, float[,,,] @float4, double[,,,] @double4, String[,,,] @string4, byps.test.api.prim.PrimitiveTypes[,,,] @primitiveTypes4)
 {
     this.boolean4Value        = @boolean4;
     this.byte4Value           = @byte4;
     this.char4Value           = @char4;
     this.short4Value          = @short4;
     this.int4Value            = @int4;
     this.long4Value           = @long4;
     this.float4Value          = @float4;
     this.double4Value         = @double4;
     this.string4Value         = @string4;
     this.primitiveTypes4Value = @primitiveTypes4;
 }
예제 #18
0
 internal TextureData3D16(int width, int height, int depth, int channels)
     : base(width, height, depth, channels, 16)
 {
     Raw = new short[width, height, depth, channels];
 }