Пример #1
0
        /**
         * /// Creates a SentenceHMMStateArc
         *
         * /// @param nextState               the next state
         * /// @param logLanguageProbability  the log language probability
         * /// @param logInsertionProbability the log insertion probability
         */
        public SentenceHMMStateArc(SentenceHMMState nextState,
                                   float logLanguageProbability,
                                   float logInsertionProbability)
        {
            _nextState           = nextState;
            LanguageProbability  = logLanguageProbability;
            InsertionProbability = logInsertionProbability;

            _hashCode = 111 + nextState.GetHashCode() +
                        17 * Float.FloatToIntBits(logLanguageProbability) +
                        23 * Float.FloatToIntBits(logInsertionProbability);
        }
Пример #2
0
        /// <summary>
        /// Returns the hashcode for this stroke. </summary>
        /// <returns>      a hash code for this stroke. </returns>
        public override int HashCode()
        {
            int hash = Float.FloatToIntBits(Width);

            hash = hash * 31 + Join;
            hash = hash * 31 + Cap;
            hash = hash * 31 + Float.FloatToIntBits(Miterlimit);
            if (Dash != null)
            {
                hash = hash * 31 + Float.FloatToIntBits(Dash_phase);
                for (int i = 0; i < Dash.Length; i++)
                {
                    hash = hash * 31 + Float.FloatToIntBits(Dash[i]);
                }
            }
            return(hash);
        }
        /// <summary>
        ///    Проверка спутников на столкновения с землей и друг с другом
        /// </summary>
        /// <returns>true, если столкновений не будет, false в противном случае</returns>
        private bool VerifyDistances()
        {
            if (_motionParams.Count == 0)
            {
                return(true);
            }

#pragma warning disable 618
            var earth     = Resources.GetDrawable(Resource.Drawable.globe);
            var satellite = Resources.GetDrawable(Resource.Drawable.action_satellite);
#pragma warning restore 618
            var maxEarth     = Math.Max(earth.IntrinsicWidth, earth.IntrinsicHeight);
            var maxSatellite = Math.Max(satellite.IntrinsicWidth, satellite.IntrinsicHeight);

            _motionParams.Sort(
                (satellite1, satellite2) =>
                Float.FloatToIntBits(satellite1.Distance) - Float.FloatToIntBits(satellite2.Distance));

            var satObject         = _motionParams[0];
            var thresholdDistance = Math.Sqrt(2) / 2 * (maxEarth + maxSatellite);
            if (satObject.Distance < thresholdDistance) // Спутник столкнется с землей
            {
                var errorMessage = String.Format(Resources.GetString(Resource.String.EarthCollideError),
                                                 thresholdDistance);
                AlertDialogUtil.ShowSimpleDialog(this, errorMessage);
                return(false);
            }

            for (var i = 1; i < _motionParams.Count; i++)
            {
                var currentSatellite = _motionParams[i];
                var prevSatellite    = _motionParams[i - 1];
                var diffDistance     = currentSatellite.Distance - prevSatellite.Distance;
                if (diffDistance < MinimumDistanceBetween)
                {
                    // Расстояние между спутниками меньше минимально допустимого
                    var errorMessage = String.Format(Resources.GetString(Resource.String.SatelliteCollideError),
                                                     currentSatellite.Distance, prevSatellite.Distance, MinimumDistanceBetween);
                    AlertDialogUtil.ShowSimpleDialog(this, errorMessage);
                    return(false);
                }
            }

            return(true);
        }
Пример #4
0
        public override bool Equals(Object obj)
        {
            //Note: NOT performance critical
            if (this == obj)
            {
                return(true);
            }
            if (obj == null)
            {
                return(false);
            }
            if (GetType() != obj.GetType())
            {
                return(false);
            }
            Arc other = (Arc)obj;

            if (Ilabel != other.Ilabel)
            {
                return(false);
            }
            if (NextState == null)
            {
                if (other.NextState != null)
                {
                    return(false);
                }
            }
            else if (NextState.GetId() != other.NextState.GetId())
            {
                return(false);
            }
            if (Olabel != other.Olabel)
            {
                return(false);
            }
            if (!(Weight == other.Weight))
            {
                if (Float.FloatToIntBits(Weight) != Float.FloatToIntBits(other.Weight))
                {
                    return(false);
                }
            }
            return(true);
        }
Пример #5
0
        /** Queues pending data to be written on next cycle. (only valid if start() has been called). */
        public void SetValue(String value)
        {
            byte[] data = null;
            if (IsBE())
            {
                switch (Size)
                {
                case TagType.Bit: data = new byte[] { (byte)(value.Equals("0") ? 0 : 1) }; break;

                case TagType.Int8: data = new byte[] { Byte.ValueOf(value) }; break;

                case TagType.Int16: data = new byte[2]; BE.setuint16(data, 0, Int32.ValueOf(value)); break;

                case TagType.Int32: data = new byte[4]; BE.setuint32(data, 0, Int32.ValueOf(value)); break;

                case TagType.Float32: data = new byte[4]; BE.setuint32(data, 0, Float.FloatToIntBits(Float.ValueOf(value))); break;

                case TagType.Float64: data = new byte[4]; BE.setuint64(data, 0, Double.DoubleToLongBits(Double.ValueOf(value))); break;
                }
            }
            else
            {
                switch (Size)
                {
                case TagType.Bit: data = new byte[] { (byte)(value.Equals("0") ? 0 : 1) }; break;

                case TagType.Int8: data = new byte[] { Byte.ValueOf(value) }; break;

                case TagType.Int16: data = new byte[2]; LE.setuint16(data, 0, Int32.ValueOf(value)); break;

                case TagType.Int32: data = new byte[4]; LE.setuint32(data, 0, Int32.ValueOf(value)); break;

                case TagType.Float32: data = new byte[4]; LE.setuint32(data, 0, Float.FloatToIntBits(Float.ValueOf(value))); break;

                case TagType.Float64: data = new byte[4]; LE.setuint64(data, 0, Double.DoubleToLongBits(Double.ValueOf(value))); break;
                }
            }
            lock (pendingLock) {
                pending = data;
            }
        }
Пример #6
0
        /*
         * /// (non-Javadoc)
         * ///
         * /// @see java.lang.Object#equals(java.lang.Object)
         */

        public override bool Equals(Object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            if (obj == null)
            {
                return(false);
            }
            if (GetType() != obj.GetType())
            {
                return(false);
            }
            var other = (State)obj;

            if (Id != other.Id)
            {
                return(false);
            }
            if (!(FinalWeight == other.FinalWeight))
            {
                if (Float.FloatToIntBits(FinalWeight) != Float.FloatToIntBits(other.FinalWeight))
                {
                    return(false);
                }
            }
            if (_arcs == null)
            {
                if (other._arcs != null)
                {
                    return(false);
                }
            }
            else if (!Arrays.AreEqual(_arcs, other._arcs))
            {
                return(false);
            }
            return(true);
        }
Пример #7
0
 public void Write(Float aFloat)
 {
     WriteInteger32ToByteArray(Float.FloatToIntBits(aFloat.FloatValue()));
 }
Пример #8
0
 internal static void PutFloat(sbyte[] b, int off, float val)
 {
     PutInt(b, off, Float.FloatToIntBits(val));
 }
Пример #9
0
 private void writefloat(float f)
 {
     writeuint32(Float.FloatToIntBits(f));
 }
Пример #10
0
 // ReSharper disable PossibleNullReferenceException
 public int Compare(Satellite x, Satellite y)
 => Float.FloatToIntBits(x.Distance) - Float.FloatToIntBits(y.Distance);
Пример #11
0
        /// <summary>
        /// Converts the float argument to an <code>int</code> using the
        /// <code>floatToIntBits</code> method in class <code>Float</code>,
        /// and then writes that <code>int</code> value to the underlying
        /// output stream as a 4-byte quantity, high byte first. If no
        /// exception is thrown, the counter <code>written</code> is
        /// incremented by <code>4</code>.
        /// </summary>
        /// <param name="v">   a <code>float</code> value to be written. </param>
        /// <exception cref="IOException">  if an I/O error occurs. </exception>
        /// <seealso cref=        java.io.FilterOutputStream#out </seealso>
        /// <seealso cref=        java.lang.Float#floatToIntBits(float) </seealso>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public final void writeFloat(float v) throws IOException
        public void WriteFloat(float v)
        {
            WriteInt(Float.FloatToIntBits(v));
        }
Пример #12
0
 public static uint FloatToIntBits(float value)
 {
     return(Float.FloatToIntBits(value));
 }
Пример #13
0
 /// <summary>
 /// Returns the hashcode for this composite. </summary>
 /// <returns>      a hash code for this composite. </returns>
 public override int HashCode()
 {
     return(Float.FloatToIntBits(ExtraAlpha) * 31 + Rule_Renamed);
 }