Inheritance: MonoBehaviour
Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        public bool Equals(Value other)
        {
            if (Type != other.Type)
            {
                if (Type == ValueType.Float && other.Type == ValueType.Int || Type == ValueType.Int && other.Type == ValueType.Float)
                {
                    return(Float.Equals(other.Float));
                }
            }
            switch (Type)
            {
            case ValueType.Unknown:
                return(false);

            case ValueType.Bool:
                return(Bool == other.Bool);

            case ValueType.Int:
                return(Int == other.Int);

            case ValueType.Float:
                return(Float.Equals(other.Float));

            case ValueType.Float2:
                return(Float2.Equals(other.Float2));

            case ValueType.Float3:
                return(Float3.Equals(other.Float3));

            case ValueType.Float4:
                return(Float4.Equals(other.Float4));

            case ValueType.Quaternion:
                return(Quaternion.Equals(other.Quaternion));

            case ValueType.Entity:
                return(Entity == other.Entity);

            case ValueType.StringReference:
                return(StringReference.Equals(other.StringReference));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Ejemplo n.º 3
0
 public static string Print(IValue expression)
 {
     return(expression switch
     {
         Boolean boolean => boolean.Value ? "#t" : "#f",
         Integer integer => integer.Value.ToString(),
         Float floating => AddDotZeroIfInteger(floating.Value.ToString("G7",
                                                                       CultureInfo.InvariantCulture.NumberFormat)),
         Nil _ => "nil",
         String @string => $"\"{@string.Value}\"",
         Symbol symbol => symbol.Value,
         Function _ => "#<function>",
         Keyword keyword => keyword.Value,
         List list => PrintCollection("(", ")", list),
         Vector vector => PrintCollection("[", "]", vector),
         _ => throw new YungException(
             $"Tried to print a node of type {expression.GetType().Name}, but this action is not implemented.")
     });
Ejemplo n.º 4
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Byte.GetHashCode();
         hashCode = (hashCode * 397) ^ Short.GetHashCode();
         hashCode = (hashCode * 397) ^ ArrayReaderTestId;
         hashCode = (hashCode * 397) ^ Long.GetHashCode();
         hashCode = (hashCode * 397) ^ Float.GetHashCode();
         hashCode = (hashCode * 397) ^ Double.GetHashCode();
         hashCode = (hashCode * 397) ^ Decimal.GetHashCode();
         hashCode = (hashCode * 397) ^ Bool.GetHashCode();
         hashCode = (hashCode * 397) ^ String.GetHashCode();
         hashCode = (hashCode * 397) ^ Guid.GetHashCode();
         hashCode = (hashCode * 397) ^ DateTime.GetHashCode();
         return(hashCode);
     }
 }
Ejemplo n.º 5
0
        public static void Save(float saveFloat, string nameKey)
        {
            Float @float = new Float();

            @float.@float = saveFloat;

            if (!Directory.Exists(Application.dataPath + "/Saves"))
            {
                Directory.CreateDirectory(Application.dataPath + "/Saves");
            }

            FileStream fs = new FileStream(Application.dataPath + "/Saves/" + nameKey + ".sh", FileMode.Create);

            BinaryFormatter formatter = new BinaryFormatter();

            formatter.Serialize(fs, @float);
            fs.Close();
        }
Ejemplo n.º 6
0
        /**
         * Returns the version of the Java virtual machine.
         *
         * @return the Java virtual machine version.
         */
        public static float getJavaVersion()
        {
            float  ver = 0f;
            String s   = System.getProperty("java.specification.version");

            if (null == s || s.length() == 0)
            {
                s = System.getProperty("java.version");
            }
            try
            {
                ver = Float.parseFloat(s.trim());
            }
            catch (NumberFormatException ignore)
            {
            }
            return(ver);
        }
Ejemplo n.º 7
0
        public bool IsFloatValid()
        {
            bool valid = true;

            valid &= !Float.IsNaN(this.val[0]);
            valid &= !Float.IsNaN(this.val[1]);
            valid &= !Float.IsNaN(this.val[2]);

            valid &= !Float.IsNaN(this.val[3]);
            valid &= !Float.IsNaN(this.val[4]);
            valid &= !Float.IsNaN(this.val[5]);

            valid &= !Float.IsNaN(this.val[6]);
            valid &= !Float.IsNaN(this.val[7]);
            valid &= !Float.IsNaN(this.val[8]);

            return(valid);
        }
Ejemplo n.º 8
0
 private static int CompareDoubleAgainstRawType(double lhsDouble, long rhsRawBits, sbyte rhsType)
 {
     if (rhsType == BYTE || rhsType == SHORT || rhsType == INT || rhsType == LONG)
     {
         return(NumberValues.compareDoubleAgainstLong(lhsDouble, rhsRawBits));
     }
     else if (rhsType == FLOAT)
     {
         return(lhsDouble.CompareTo(Float.intBitsToFloat(( int )rhsRawBits)));
     }
     else if (rhsType == DOUBLE)
     {
         return(lhsDouble.CompareTo(Double.longBitsToDouble(rhsRawBits)));
     }
     // We can not throw here because we will visit this method inside a pageCursor.shouldRetry() block.
     // Just return a comparison that at least will be commutative.
     return(Long.compare(System.BitConverter.DoubleToInt64Bits(lhsDouble), rhsRawBits));
 }
Ejemplo n.º 9
0
 private static int CompareLongAgainstRawType(long lhs, long rhsRawBits, sbyte rhsType)
 {
     if (rhsType == BYTE || rhsType == SHORT || rhsType == INT || rhsType == LONG)
     {
         return(Long.compare(lhs, rhsRawBits));
     }
     else if (rhsType == FLOAT)
     {
         return(NumberValues.compareLongAgainstDouble(lhs, Float.intBitsToFloat(( int )rhsRawBits)));
     }
     else if (rhsType == DOUBLE)
     {
         return(NumberValues.compareLongAgainstDouble(lhs, Double.longBitsToDouble(rhsRawBits)));
     }
     // We can not throw here because we will visit this method inside a pageCursor.shouldRetry() block.
     // Just return a comparison that at least will be commutative.
     return(Long.compare(lhs, rhsRawBits));
 }
Ejemplo n.º 10
0
 public static Float Clamp(Float Val, Float v1, Float v2)
 {
     if (v1 > v2)
     {
         var tmv = v1;
         v1 = v2;
         v2 = tmv;
     }
     if (v1.iVal <= Val.iVal && Val.iVal <= v2.iVal)
     {
         return(Val);
     }
     if (Val.iVal < v1.iVal)
     {
         return(v1);
     }
     return(v2);
 }
Ejemplo n.º 11
0
        }          // write

        /*
        ** Name: write (float) at a position
        **
        ** Description:
        **	Write a float value in the output buffer.
        **
        ** Input:
        **	position        Buffer position.
        **	floatValue	    Float value.
        **
        ** Output:
        **	None.
        **
        ** Returns:
        **	void
        **
        ** History:
        **	16-Jun-99 (gordy)
        **	    Created.
        **	28-Jan-00 (gordy)
        **	    Replaced redundat code with check() method.
        **	14-Aug-02 (thoda04)
        **	    Ported for .NET Provider.
        */

        /// <summary>
        /// Write an float value in the output buffer at a particular position.
        /// </summary>
        /// <param name="position">Buffer position.</param>
        /// <param name="floatValue">float value.</param>
        public virtual void  write(int position, float floatValue)
        {
            uint  bits, man;
            short exp;
            byte  sign;

            check(position, DAM_TL_F4_LEN);

            /*
            ** Extract bits of each component.
            */
            bits = Float.floatToIntBits(floatValue);
            sign = (byte)((bits & 0x80000000) >> 31);
            exp  = (short)((bits & 0x7f800000) >> 23);
            man  = (uint)((bits & 0x007fffff) << 9);

            /*
            ** Re-bias the exponent
            */
            if (exp != 0)
            {
                exp = (short)(exp - (126 - 16382));
            }

            /*
            ** Pack the bits in network format.
            ** (note that byte pairs are swapped).
            */
            buffer[position + 1] = (byte)((sign << 7) | (exp >> 8));
            buffer[position + 0] = (byte)exp;
            buffer[position + 3] = (byte)(man >> 24);
            buffer[position + 2] = (byte)(man >> 16);
            buffer[position + 5] = (byte)(man >> 8);
            buffer[position + 4] = (byte)man;

            position += DAM_TL_F4_LEN;

            if (position > data_ptr)
            {
                data_ptr = position;
            }

            return;
        }          // write
Ejemplo n.º 12
0
        // REVIEW: Maybe need revamping. As values get closer to 0 , the tolerance needs to increase.
        // REVIEW: Every test should be able to override the RelativeToleranceStepSize.
        private double GetTolerance(Float value)
        {
            double stepSizeMultiplier;
            if (value == 0)
                stepSizeMultiplier = 1;
            else
                stepSizeMultiplier = Math.Log((double)Math.Abs(value));

            if (stepSizeMultiplier <= 0)
            {
                stepSizeMultiplier = Math.Max(1, Math.Abs(stepSizeMultiplier));
                // tolerance needs to increase faster as we start going towards smaller values.
                stepSizeMultiplier *= stepSizeMultiplier;
            }
            else
                stepSizeMultiplier = Math.Min(1, 1 / stepSizeMultiplier);

            return stepSizeMultiplier * RelativeToleranceStepSize;
        }
Ejemplo n.º 13
0
        public override IAlgorithmOutput Withdraw(double amount)
        {
            if (SufficientFunds(amount))
            {
                var orderedFloat = Float.OrderByDescending(o => o.Value).ToArray();

                var sb = new StringBuilder();

                Array.ForEach(orderedFloat, item =>
                {
                    if (amount >= item.Value)
                    {
                        int noteCount = (int)Math.Floor(amount / item.Value);
                        if (noteCount <= item.Total)
                        {
                            item.Total -= noteCount;
                            amount     -= noteCount * item.Value;
                            amount      = Math.Round(amount, 2);
                            if (sb.Length > 0)
                            {
                                sb.Append(", ");
                            }

                            sb.Append($"{item.Display} x {noteCount}");
                        }
                    }
                });

                return(new BaseAlgorithmOutput
                {
                    Balance = Balance,
                    Output = sb.ToString().Trim()
                });
            }
            else
            {
                return(new BaseAlgorithmOutput
                {
                    Balance = Balance,
                    Output = "Insufficient funds!"
                });
            }
        }
Ejemplo n.º 14
0
        public void FloatTest()
        {
            Float minusOne = new Float(-1f);
            Float zero     = new Float(0f);
            Float half     = new Float(0.5f);
            Float one      = new Float(1f);
            Float oneHalf  = new Float(1.5f);
            Float two      = new Float(2f);

            Assert.AreEqual(zero, mul.Execute(zero, one));
            Assert.AreEqual(zero, mul.Execute(zero, two));
            Assert.AreEqual(zero, mul.Execute(two, zero));
            Assert.AreEqual(one, mul.Execute(one, one));
            Assert.AreEqual(two, mul.Execute(two, one));
            Assert.AreEqual(new Float(4), mul.Execute(two, two));
            Assert.AreEqual(one, mul.Execute(two, half));

            Assert.AreEqual(minusOne, mul.Execute(minusOne, one));
        }
Ejemplo n.º 15
0
 public Float osList2Double(list src, integer index)
 {
     if (index >= src.Count)
     {
         Verbose("osList2Double({0}, {1})={2}", src.ToVerboseString(), index, -1);
         return(-1);
     }
     else if (src[index].GetType() == typeof(string))
     {
         Verbose("osList2Double({0}, {1})={2}", src.ToVerboseString(), index, float.Parse((string)src[index]));
         return((Float)float.Parse((string)src[index]));
     }
     else
     {
         Float f = float.Parse(src[index].ToString());
         Verbose("osList2Double({0}, {1})={2}", src.ToVerboseString(), index, src[index]);
         return(f);
     }
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Initialises a new instance of the <see cref="SecondLife"/> class.
        /// </summary>
        public SecondLife()
        {
            this.host = null;
            rdmRandom = new Random();
            dtDateTimeScriptStarted = DateTime.Now.ToUniversalTime();
            htLandPassList          = new Hashtable();
            htLandBanList           = new Hashtable();
            fVolume         = 0.0;
            sObjectName     = null;
            vPosition       = new vector(127, 128, 20);
            rRotation       = rotation.ZERO_ROTATION;
            rRotationlocal  = rotation.ZERO_ROTATION;
            vScale          = vector.ZERO_VECTOR;
            sSitText        = "sittext";
            fSoundRadius    = 1.0;
            iStartParameter = 0;

            vRegionCorner = vector.ZERO_VECTOR;
        }
Ejemplo n.º 17
0
        private void Branch(Cylinder parent, Float size)
        {
            Cylinder branch = new Cylinder();

            branch.Texture = Library.Textures.DarkWood;
            Vector end = (new PovRandom().Vector() + (-0.5, 0, -0.5)) * (size * 3);

            branch.BasePoint = parent.CapPoint;
            branch.CapPoint  = parent.CapPoint + end;
            branch.Radius    = size * 0.1;

            this.Add(branch);

            size = size * 0.5;
            if (size > 1)
            {
                this.AddBranches(branch, size);
            }
        }
Ejemplo n.º 18
0
        // EaseInOutOver(lenをはみ出すEaseInOut)
        //  len: 補間の長さ
        //  sec: 補間時間(秒)
        //  m  : はみ出し強度(0-1)
        //  deltaCallback< sec, t, dt, delta >
        //   sec  : 経過秒
        //   t    : 経過補間係数(0~1)
        //   dt   : 前回からの差分時間
        //   delta: 差分値
        static public Result easeInOutOver(float len, float sec, float m, System.Func <float, float, float, float, bool> deltaCallback, System.Action finishCallback = null)
        {
            float preSec = 0.0f;
            float m2     = m * 0.2f + 0.8f;
            float p      = len / (sec * (6.0f * m2 * m2 - 6.0f * m2 + 1.0f));
            float a      = -2.0f / (sec * sec);
            float b      = 3.0f / sec;
            float c      = 6.0f * m2 * (m2 - 1);
            var   res    = new Float(() => {
                return(updateTime(ref preSec, len, sec, deltaCallback, finishCallback, (_preSec, _dt) => {
                    float s = _preSec;
                    float sd = _preSec + _dt;
                    return p * (a * (sd * sd * sd - s * s * s) + b * (sd * sd - s * s) + c * (sd - s));
                }));
            });

            DeltaLerpUpdater.getInstance().add(res);
            return(res);
        }
Ejemplo n.º 19
0
        public override float getProbability(WordSequence wordSequence)
        {
            int num = wordSequence.size();

            if (num > this.maxDepth)
            {
                string text = new StringBuilder().append("Unsupported NGram: ").append(wordSequence.size()).toString();

                throw new Error(text);
            }
            if (num == this.maxDepth)
            {
                Float @float = (Float)this.ngramProbCache.get(wordSequence);
                if (@float != null)
                {
                    this.ngramHits++;
                    return(@float.floatValue());
                }
                this.ngramMisses++;
            }
            float num2 = this.applyWeights(this.getProbabilityRaw(wordSequence));

            if (num == this.maxDepth)
            {
                this.ngramProbCache.put(wordSequence, Float.valueOf(num2));
            }
            if (this.logFile != null)
            {
                PrintWriter   printWriter   = this.logFile;
                StringBuilder stringBuilder = new StringBuilder();
                string        text2         = wordSequence.toString();
                object        obj           = "][";
                object        obj2          = " ";
                object        _ref          = obj;
                CharSequence  charSequence  = CharSequence.Cast(_ref);
                CharSequence  charSequence2 = charSequence;
                _ref         = obj2;
                charSequence = CharSequence.Cast(_ref);
                printWriter.println(stringBuilder.append(String.instancehelper_replace(text2, charSequence2, charSequence)).append(" : ").append(Float.toString(num2)).toString());
            }
            return(num2);
        }
Ejemplo n.º 20
0
        public override float getSmear(WordSequence wordSequence)
        {
            float num = 0f;

            if (this.fullSmear)
            {
                this.smearCount++;
                int num2 = wordSequence.size();
                if (num2 == 1)
                {
                    int num3 = this.getWordID(wordSequence.getWord(0));
                    num = this.unigramSmearTerm[num3];
                }
                else if (num2 >= 2)
                {
                    int   num3      = wordSequence.size();
                    int   wordID    = this.getWordID(wordSequence.getWord(num3 - 2));
                    int   wordID2   = this.getWordID(wordSequence.getWord(num3 - 1));
                    Float smearTerm = this.getSmearTerm(wordID, wordID2);
                    if (smearTerm == null)
                    {
                        num = this.unigramSmearTerm[wordID2];
                    }
                    else
                    {
                        num = smearTerm.floatValue();
                        this.smearBigramHit++;
                    }
                }
                bool flag = this.smearCount != 0;
                int  num4 = 100000;
                if (num4 == -1 || (flag ? 1 : 0) % num4 == 0)
                {
                    [email protected](new StringBuilder().append("Smear hit: ").append(this.smearBigramHit).append(" tot: ").append(this.smearCount).toString());
                }
            }
            if (this.fullSmear && this.logger.isLoggable(Level.FINE))
            {
                this.logger.fine(new StringBuilder().append("SmearTerm: ").append(num).toString());
            }
            return(num);
        }
Ejemplo n.º 21
0
        static IC()
        {
            var m = typeof(IC).GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static);
            foreach (MethodInfo method in m)
            {
                Type t = method.ReturnType;
                string s = method.Name.Substring(1);

                int i;
                if (!int.TryParse(s, System.Globalization.NumberStyles.Number, CultureInfo.InvariantCulture, out i))
                    continue;

                if (t == typeof(bool))
                    Bit.Add(i, (Func<bool>)Delegate.CreateDelegate(typeof(Func<bool>), method));
                else if (t == typeof(int))
                    Basic.Add(i, (Func<int>)Delegate.CreateDelegate(typeof(Func<int>), method));
                else if (t == typeof(float))
                    Float.Add(i, (Func<float>)Delegate.CreateDelegate(typeof(Func<float>), method));
            }
        }
Ejemplo n.º 22
0
        // ===========================================================
        // Getter & Setter
        // ===========================================================

        // ===========================================================
        // Methods for/from SuperClass/Interfaces
        // ===========================================================

        // ===========================================================
        // Methods
        // ===========================================================

        public /*synchronized*/ void Update(float pX1, float pY1, float pX2, float pY2)
        {
            lock (_methodLock)
            {
                int[] bufferData = this.mBufferData;

                bufferData[0] = Float.FloatToRawIntBits(pX1);
                bufferData[1] = Float.FloatToRawIntBits(pY1);

                bufferData[2] = Float.FloatToRawIntBits(pX2);
                bufferData[3] = Float.FloatToRawIntBits(pY2);

                FastFloatBuffer buffer = this.GetFloatBuffer();
                buffer.Position(0);
                buffer.Put(bufferData);
                buffer.Position(0);

                base.SetHardwareBufferNeedsUpdate();
            }
        }
Ejemplo n.º 23
0
        public void testFloat()
        {
            var f  = new Float(20f);
            var cp = f.copy();

            Assert.AreEqual(f.get(), 20f);
            Assert.AreEqual(f.get(), cp.get());
            Assert.AreEqual(f.nulo(), 0f);

            f.add(20f);
            f.reduce(10f);
            Assert.AreEqual(f.get(), 30f);
            Assert.AreNotEqual(f.get(), cp.get());

            f.mult(10f);
            Assert.AreEqual(f.get(), 300f);

            f.set(200f);
            Assert.AreEqual(f.get(), 200f);
        }
Ejemplo n.º 24
0
 public object Apply(object a, object b)
 {
     return(a switch {
         // Integral types
         byte bt => Byte?.Invoke(bt, Convert.ToByte(b)),
         sbyte sb => SByte?.Invoke(sb, Convert.ToSByte(b)),
         short sh => Short?.Invoke(sh, Convert.ToInt16(b)),
         ushort ush => UShort?.Invoke(ush, Convert.ToUInt16(b)),
         int i => Int?.Invoke(i, Convert.ToInt32(b)),
         uint ui => UInt?.Invoke(ui, Convert.ToUInt32(b)),
         long l => Long?.Invoke(l, Convert.ToInt64(b)),
         ulong ul => ULong?.Invoke(ul, Convert.ToUInt64(b)),
         float f => Float?.Invoke(f, Convert.ToSingle(b)),
         double d => Double?.Invoke(d, Convert.ToDouble(b)),
         decimal dec => Decimal?.Invoke(dec, Convert.ToDecimal(b)),
         string str => String?.Invoke(str, Convert.ToString(b)),
         DateTime dt => DateTime?.Invoke(dt, TimeUtils.TimeSpanOf(b)),
         TimeSpan ts => TimeSpan?.Invoke(ts, b),
         _ => throw new ArgumentException($"I don't know how to coercively operate on {a.GetType()} and {b.GetType()}!")
     } ?? throw DoesNotApply(a, b));
Ejemplo n.º 25
0
        private static void GetCPUDetails()
        {
            Java.Lang.Process p;
            try
            {
                p = Runtime.GetRuntime().Exec("cat sys/class/thermal/thermal_zone0/temp");
                p.WaitForAsync();

                BufferedReader reader = new BufferedReader(new InputStreamReader(p.InputStream));

                string line = reader.ReadLine();
                float  temp = Float.ParseFloat(line) / 1000.0f;
                resultStatistic.CpuTemp = temp;
                result = "CPU Temp: " + temp.ToString() + "oC\n";
            }
            catch (System.Exception e)
            {
                //return 0.0f;
            }
        }
Ejemplo n.º 26
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = Sbyte.GetHashCode();
         hashCode = (hashCode * 397) ^ Short.GetHashCode();
         hashCode = (hashCode * 397) ^ Int;
         hashCode = (hashCode * 397) ^ Long.GetHashCode();
         hashCode = (hashCode * 397) ^ Byte.GetHashCode();
         hashCode = (hashCode * 397) ^ UShort.GetHashCode();
         hashCode = (hashCode * 397) ^ (int)UInt;
         hashCode = (hashCode * 397) ^ ULong.GetHashCode();
         hashCode = (hashCode * 397) ^ Char.GetHashCode();
         hashCode = (hashCode * 397) ^ Float.GetHashCode();
         hashCode = (hashCode * 397) ^ Double.GetHashCode();
         hashCode = (hashCode * 397) ^ Decimal.GetHashCode();
         hashCode = (hashCode * 397) ^ Boolean.GetHashCode();
         return(hashCode);
     }
 }
Ejemplo n.º 27
0
        protected bool Equals(object other)
        {
            if (this == other)
            {
                return(true);
            }
            if (other == null)
            {
                return(false);
            }
            if (GetType() != other.GetType())
            {
                return(false);
            }
            var class2 = (Class2)other;

            return(Bool == class2.Bool && Byte == class2.Byte && Char == class2.Char && Double.Equals(class2.Double) &&
                   Float.Equals(class2.Float) && Int == class2.Int && Long == class2.Long && Sbyte == class2.Sbyte &&
                   Short == class2.Short && UInt == class2.UInt && Ulong == class2.Ulong && Ushort == class2.Ushort);
        }
Ejemplo n.º 28
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Id;
         hashCode = (hashCode * 397) ^ NullableId.GetHashCode();
         hashCode = (hashCode * 397) ^ Byte.GetHashCode();
         hashCode = (hashCode * 397) ^ Short.GetHashCode();
         hashCode = (hashCode * 397) ^ Int;
         hashCode = (hashCode * 397) ^ Long.GetHashCode();
         hashCode = (hashCode * 397) ^ UShort.GetHashCode();
         hashCode = (hashCode * 397) ^ (int)UInt;
         hashCode = (hashCode * 397) ^ ULong.GetHashCode();
         hashCode = (hashCode * 397) ^ Float.GetHashCode();
         hashCode = (hashCode * 397) ^ Double.GetHashCode();
         hashCode = (hashCode * 397) ^ Decimal.GetHashCode();
         hashCode = (hashCode * 397) ^ (String != null ? String.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ DateTime.GetHashCode();
         hashCode = (hashCode * 397) ^ TimeSpan.GetHashCode();
         hashCode = (hashCode * 397) ^ DateTimeOffset.GetHashCode();
         hashCode = (hashCode * 397) ^ Guid.GetHashCode();
         hashCode = (hashCode * 397) ^ Bool.GetHashCode();
         hashCode = (hashCode * 397) ^ Char.GetHashCode();
         hashCode = (hashCode * 397) ^ NullableDateTime.GetHashCode();
         hashCode = (hashCode * 397) ^ NullableTimeSpan.GetHashCode();
         hashCode = (hashCode * 397) ^ (ByteArray != null ? ByteArray.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (CharArray != null ? CharArray.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (StringArray != null ? StringArray.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (IntArray != null ? IntArray.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (LongArray != null ? LongArray.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (StringList != null ? StringList.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (StringMap != null ? StringMap.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (IntStringMap != null ? IntStringMap.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (SubType != null ? SubType.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (SubTypes != null ? SubTypes.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (CustomText != null ? CustomText.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (MaxText != null ? MaxText.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ CustomDecimal.GetHashCode();
         return(hashCode);
     }
 }
Ejemplo n.º 29
0
        public Node Simple()
        {
            if (CurrentToken == Token.FLOAT)
            {
                var floa = new Float();
                floa.lexeme = lex.curlex;
                //floa.lexeme = CurrentToken.lexeme;
                Console.WriteLine(floa.lexeme);
                //Console.WriteLine(floa.lexeme);
                //floa.AnchorToken =
                //Console.WriteLine("aqui4");
                Expect(Token.FLOAT);
                //var exp1 = MaxList();
                ////console.writeLine(CurrentToken);
                return(floa);
            }
            if (CurrentToken == Token.DUP)
            {
                var dup = new Dup();
                //dup.AnchorToken =
                //Console.WriteLine("aqui5");
                Expect(Token.DUP);
                var exp1 = Simple();
                dup.Add(exp1);
                return(dup);
            }
            else if (CurrentToken == Token.OPEN)
            {
                Expect(Token.OPEN);
                var dup = MaxList();

                //dup.AnchorToken =
                //Console.WriteLine("aqui6");
                //xpect(Token.DUP);
                Expect(Token.CLOSE);
                return(dup);
            }
            //console.writeLine("aqui");
            throw new SyntaxError();
            return(null);
        }
Ejemplo n.º 30
0
            public void SetValue(Type type, object value)
            {
                if (type == Type.Bool)
                {
                    m_Bool = (bool)value;
                }
                else if (type == Type.Int)
                {
                    m_Int = (Int)value;
                }
                else if (type == Type.Float)
                {
                    m_Float = (Float)value;
                }
                else if (type == Type.FloatRange)
                {
                    m_FloatRange = (FloatRange)value;
                }
                else if (type == Type.IntRange)
                {
                    m_IntRange = (IntRange)value;
                }
                else if (type == Type.RandomFloat)
                {
                    m_RandomFloat = (RandomFloat)value;
                }
                else if (type == Type.RandomInt)
                {
                    m_RandomInt = (RandomInt)value;
                }
                else if (type == Type.String)
                {
                    m_String = (string)value;
                }
                else if (type == Type.None)
                {
                    return;
                }

                Changed.Send(this);
            }
 /// <summary>
 /// floats a raster
 /// </summary>
 /// <param name="inRaster">input raster can be a constant, raster, or string (full path)</param>
 /// <param name="outRst">string full path</param>
 public void floatRaster(object inRaster, string outRst)
 {
     Float fl = new Float();
     fl.in_raster_or_constant = inRaster;
     fl.out_raster = outRst;
     string rsl = getMessages(gpExecute(fl));
 }
Ejemplo n.º 32
0
	public Float(Float xx){
		x = xx.x;
	}
	public static Float test(Float f) {
		return ++f;
	}
		/// <summary> Internal parse method </summary>
		/// <param name="parseImplicitMappings">
		///   Avoids ethernal loops while parsing implicit mappings. Implicit mappings are
		///   not rocognized by a leading character. So while trying to parse the key of
		///   something we think that could be a mapping, we're sure that if it is a mapping,
		///   the key of this implicit mapping is not a mapping itself.
		///
		///   NOTE: Implicit mapping still belong to unstable code and require the UNSTABLE and
		///         IMPLICIT_MAPPINGS preprocessor flags.
		/// </param>
		/// <param name="stream"></param>
		protected static Node Parse (ParseStream stream, bool parseImplicitMappings)
		{
			// ----------------
			// Skip Whitespace
			// ----------------
			if (! stream.EOF)
			{
				// Move the firstindentation pointer after the whitespaces of this line
				stream.SkipSpaces ();
				while (stream.Char == '\n' && ! stream.EOF)
				{
					// Skip newline and next whitespaces
					stream.Next ();
					stream.SkipSpaces ();
				}
			}

			// -----------------
			// No remaining chars (Null/empty stream)
			// -----------------
			if (stream.EOF)
				return new Null ();

			// -----------------
			// Explicit type
			// -----------------

#if SUPPORT_EXPLICIT_TYPES
			stream.BuildLookaheadBuffer ();

			char a = '\0', b = '\0';

			a = stream.Char; stream.Next ();
			b = stream.Char; stream.Next ();

			// Starting with !!
			if (a == '!' && b == '!' && ! stream.EOF)
			{
				stream.DestroyLookaheadBuffer ();

				// Read the tagname
				string tag = "";

				while (stream.Char != ' ' && stream.Char != '\n' && ! stream.EOF)
				{
					tag += stream.Char;
					stream.Next ();
				}

				// Skip Whitespace
				if (! stream.EOF)
				{
					stream.SkipSpaces ();
					while (stream.Char == '\n' && ! stream.EOF)
					{
						stream.Next ();
						stream.SkipSpaces ();
					}
				}

				// Parse
				Node n;
				switch (tag)
				{
					// Mappings and sequences
					// NOTE:
					// - sets are mappings without values
					// - Ordered maps are ordered sequence of key: value
					//   pairs without duplicates.
					// - Pairs are ordered sequence of key: value pairs
					//   allowing duplicates.

					// TODO: Create new datatypes for omap and pairs
					//   derived from sequence with a extra duplicate
					//   checking.

					case "seq":       n = new Sequence  (stream); break;
					case "map":       n = new Mapping   (stream); break;
					case "set":       n = new Mapping   (stream); break;
					case "omap":      n = new Sequence  (stream); break;
					case "pairs":     n = new Sequence  (stream); break;

					// Scalars
					//
					// TODO: do we have to move this to Scalar.cs
					// in order to get the following working:
					//
					// !!str "...": "..."
					// !!str "...": "..."

					case "timestamp": n = new Timestamp (stream); break;
					case "binary":    n = new Binary    (stream); break;
					case "null":      n = new Null      (stream); break;
					case "float":     n = new Float     (stream); break;
					case "int":       n = new Integer   (stream); break;
					case "bool":      n = new Boolean   (stream); break;
					case "str":       n = new String    (stream); break;

					// Unknown data type
					default:
						throw  new Exception ("Incorrect tag '!!" + tag + "'");
				}

				return n;
			}
			else
			{
				stream.RewindLookaheadBuffer ();
				stream.DestroyLookaheadBuffer ();
			}
#endif
			// -----------------
			// Sequence
			// -----------------

			if (stream.Char == '-' || stream.Char == '[')
				return new Sequence (stream);

			// -----------------
			// Mapping
			// -----------------

			if (stream.Char == '?' || stream.Char == '{')
				return new Mapping (stream);

			// -----------------
			// Try implicit mapping
			// -----------------

			// This are mappings which are not preceded by a question
			// mark. The keys have to be scalars.

#if (UNSTABLE && SUPPORT_IMPLICIT_MAPPINGS)

			// NOTE: This code can't be included in Mapping.cs
			// because of the way we are using to rewind the buffer.

			Node key, val;

			if (parseImplicitMappings)
			{
				// First Key/value pair

				stream.BuildLookaheadBuffer ();

				stream.StopAt (new char [] {':'});

				// Keys of implicit mappings can't be sequences, or other mappings
				// just look for scalars
				key = Scalar.Parse (stream, false); 
				stream.DontStop ();

Console.WriteLine ("key: " + key);

				// Followed by a colon, so this is a real mapping
				if (stream.Char == ':')
				{
					stream.DestroyLookaheadBuffer ();

					Mapping mapping = new Mapping ();

					// Skip colon and spaces
					stream.Next ();
					stream.SkipSpaces ();

					// Parse the value
Console.Write ("using  buffer: " + stream.UsingBuffer ());
					stream.Indent ();
Console.Write ("using  buffer: " + stream.UsingBuffer ());
//					val = Parse (stream, false);
Console.Write ("<<");
while (!stream.EOF) {Console.Write (stream.Char);stream.Next (true);}
Console.Write (">>");

val = new  String (stream);


Console.Write ("using  buffer: " + stream.UsingBuffer ());
					stream.UnIndent ();
Console.Write ("using  buffer: " + stream.UsingBuffer ());

Console.Write ("<<");
while (!stream.EOF) {Console.Write (stream.Char);stream.Next (true);}
Console.Write (">>");




Console.WriteLine ("val: " + val);
					mapping.AddMappingNode (key, val);

					// Skip possible newline
					// NOTE: this can't be done by the drop-newline
					// method since this is not the end of a block
					while (stream.Char == '\n')
						stream.Next (true);

					// Other key/value pairs
					while (! stream.EOF)
					{
						stream.StopAt (new char [] {':'} );
						stream.Indent ();
						key = Scalar.Parse (stream);
						stream.UnIndent ();
						stream.DontStop ();

Console.WriteLine ("key 2: " + key);
						if (stream.Char == ':')
						{
							// Skip colon and spaces
							stream.Next ();
							stream.SkipSpaces ();

							// Parse the value
							stream.Indent ();
							val = Parse (stream);
							stream.UnIndent ();

Console.WriteLine ("val 2: " + val);
							mapping.AddMappingNode (key, val);
						}
						else // TODO: Is this an error?
						{
							// NOTE: We can't recover from this error,
							// the last buffer has been destroyed, so
							// rewinding is impossible.
							throw new ParseException (stream,
								"Implicit mapping without value node");
						}

						// Skip possible newline
						while (stream.Char == '\n')
							stream.Next ();
					}

					return mapping;
				}

				stream.RewindLookaheadBuffer ();
				stream.DestroyLookaheadBuffer ();
			}

#endif
			// -----------------
			// No known data structure, assume this is a scalar
			// -----------------

			Scalar scalar = Scalar.Parse (stream);

			// Skip trash
			while (! stream.EOF)
				stream.Next ();
		

			return scalar;
		}
Ejemplo n.º 35
0
public Float2 pow(Float2 asd,Float p){
	asd.x = Mathf.Pow(asd.x,p);
	asd.y = Mathf.Pow(asd.y,p);
	return asd;
}
		/// <summary>
		///   Parses a scalar
		///   <list type="bullet">
		///     <item>Integer</item>
		///     <item>String</item>
		///     <item>Boolean</item>
		///     <item>Null</item>
		///     <item>Timestamp</item>
		///     <item>Float</item>
		///     <item>Binary</item>
		///   </list>
		/// </summary>
		/// <remarks>
		///   Binary is only parsed behind an explicit !!binary tag (in Node.cs)
		/// </remarks>
		public static new Scalar Parse (ParseStream stream)
		{
			// -----------------
			// Parse scalars
			// -----------------

			stream.BuildLookaheadBuffer ();

			// Try Null
#if SUPPORT_NULL_NODES
			try
			{
				Scalar s = new Null (stream);
				stream.DestroyLookaheadBuffer ();
				return s;
			} catch { }
#endif
			// Try boolean
#if SUPPORT_BOOLEAN_NODES
			stream.RewindLookaheadBuffer ();
			try
			{
				Scalar scalar = new Boolean (stream);
				stream.DestroyLookaheadBuffer ();
				return scalar;
			} 
			catch { }
#endif
			// Try integer
#if SUPPORT_INTEGER_NODES
			stream.RewindLookaheadBuffer ();
			try
			{
				Scalar scalar = new Integer (stream);
				stream.DestroyLookaheadBuffer ();
				return scalar;
			} catch { }
#endif
			// Try Float
#if SUPPORT_FLOAT_NODES
			stream.RewindLookaheadBuffer ();
			try
			{
				Scalar scalar = new Float (stream);
				stream.DestroyLookaheadBuffer ();
				return scalar;
			} 
			catch { }
#endif
			// Try timestamp
#if SUPPORT_TIMESTAMP_NODES
			stream.RewindLookaheadBuffer ();
			try {
				Scalar scalar = new Timestamp (stream);
				stream.DestroyLookaheadBuffer ();
				return scalar;
			} catch { }
#endif
			// Other scalars are strings
			stream.RewindLookaheadBuffer ();
			stream.DestroyLookaheadBuffer ();

			return new String (stream);
		}
Ejemplo n.º 37
0
Float DotFalloff( Float xsq ) { xsq = 1.0f - xsq; return xsq.Square().Square(); }
Ejemplo n.º 38
0
Float DotNoise(Float X,Float Y,Float Val1,Float Val2,Float Val3)
{
	Float3 Rad = new Float3(Val1,Val2,Val3);
	Float2 P = new Float2(X,Y);
	Float radius_low = Rad.x;
	Float radius_high = Rad.y;
	Float2 Pi = floor(P,true);
	Float2 Pf = P-Pi;

	Float4 Hash = FastHash2D(Pi);
	
	Float Radius = max(0.0f,radius_low+Hash.z*(radius_high-radius_low),true);
	Float Value = Radius/max(radius_high,radius_low,true);
	
	Radius = 2.0f/Radius;
	Pf *= Radius;
	Pf -= (Radius - 1.0f);
	Pf += Hash.xy*(Radius - 2f);
	Pf = pow(Pf,Rad.z);
	return DotFalloff(min(dot(Pf,Pf),1.0f,true))*Value;
}
Ejemplo n.º 39
0
	public Float3(Float xx){
		x = xx.x;
		y = xx.x;
		z = xx.x;
	}
Ejemplo n.º 40
0
	public Float3(Float xx,Float yy,Float zz){
		x = xx.x;
		y = yy.x;
		z = zz.x;
	}
Ejemplo n.º 41
0
	public Float4(Float xx){
		x = xx.x;
		y = xx.x;
		z = xx.x;
		w = xx.x;
	}
Ejemplo n.º 42
0
	public Float4(Float xx,Float yy,Float zz,Float ww){
		x = xx.x;
		y = yy.x;
		z = zz.x;
		w = ww.x;
	}