コード例 #1
0
            private TArray Cirklev(TArray rx, TArray ry, TArray rz)
            {
                var r2        = Sqrt.Apply(rx * rx + ry * ry + rz * rz);
                var numerator = (TData)((6.67e-11) * 1e6 * SOLARMASS);

                return(Sqrt.Apply(numerator / r2));
            }
コード例 #2
0
        private static NdArray ComputeTargets(NdArray src, NdArray targets)
        {
            var @base  = src[R.All, R.NewAxis];
            var target = src[R.All, R.All, R.NewAxis];

            var tmp = (@base - target).Pow(2);

            tmp = Add.Reduce(tmp);
            Sqrt.Apply(tmp, tmp);

            return(Max.Reduce(tmp));
        }
コード例 #3
0
            protected void Reset(long size)
            {
                this.x = Generate.Random(size);
                this.y = Generate.Random(size);
                this.z = Generate.Random(size) * (TData)0.01;

                var dist = 1f / Sqrt.Apply((this.x.Pow(2f) + this.y.Pow(2f) + this.z.Pow(2f)));

                dist = dist - (TData)(0.8f - (new Random().NextDouble() * 0.1f));

                this.x = XMAX * this.x * dist * Sign.Apply(.5f - Generate.Random(size));
                this.y = YMAX * this.y * dist * Sign.Apply(.5f - Generate.Random(size));
                this.z = ZMAX * this.z * dist * Sign.Apply(.5f - Generate.Random(size));

                var magv     = Cirklev(this.x, this.y, this.z);
                var absangle = Atan.Apply(Abs.Apply(this.y / this.x));
                var thetav   = (TData)(Math.PI / 2) - absangle;

                this.vx = (TData)(-1) * Sign.Apply(this.y) * Cos.Apply(thetav) * magv;
                this.vy = Sign.Apply(this.x) * Sin.Apply(thetav) * magv;
                this.vz = Generate.Zeroes(size);
            }