コード例 #1
0
 public Trigger_Threshold( ManagerJob_Foraging job )
     : base(job.manager)
 {
     Op = Ops.LowerThan;
     MaxUpperThreshold = DefaultMaxUpperThreshold;
     Count = DefaultCount;
     ThresholdFilter = new ThingFilter();
     ThresholdFilter.SetDisallowAll();
 }
コード例 #2
0
 public Trigger_Threshold( ManagerJob_Forestry job )
     : base(job.manager)
 {
     Op = Ops.LowerThan;
     MaxUpperThreshold = DefaultMaxUpperThreshold;
     Count = DefaultCount;
     ThresholdFilter = new ThingFilter();
     ThresholdFilter.SetDisallowAll();
     ThresholdFilter.SetAllow( Utilities_Forestry.Wood, true );
 }
コード例 #3
0
 public TriggerThreshold(ManagerJobProduction job)
 {
     Op = Ops.LowerThan;
     MaxUpperThreshold = job.MainProduct.MaxUpperThreshold;
     Count = MaxUpperThreshold / 5;
     ThresholdFilter = new ThingFilter();
     ThresholdFilter.SetDisallowAll();
     if (job.MainProduct.ThingDef != null) ThresholdFilter.SetAllow(job.MainProduct.ThingDef, true);
     if (job.MainProduct.CategoryDef != null) ThresholdFilter.SetAllow(job.MainProduct.CategoryDef, true);
 }
コード例 #4
0
 public Trigger_Threshold( ManagerJob_Production job )
     : base(job.manager)
 {
     Op = Ops.LowerThan;
     MaxUpperThreshold = job.MainProduct.MaxUpperThreshold;
     // TODO: Better way of setting sensible defaults?
     Count = MaxUpperThreshold / 20;
     ThresholdFilter = new ThingFilter();
     ThresholdFilter.SetDisallowAll();
     if ( job.MainProduct.ThingDef != null )
     {
         ThresholdFilter.SetAllow( job.MainProduct.ThingDef, true );
     }
     if ( job.MainProduct.CategoryDef != null )
     {
         ThresholdFilter.SetAllow( job.MainProduct.CategoryDef, true );
     }
 }
コード例 #5
0
ファイル: Numbers.cs プロジェクト: roffster/clojure-clr
 public Ops combine(Ops y)
 {
     return y.opsWith(this);
 }
コード例 #6
0
            /// <summary>
            ///     Initializes propagation rules for a specific input combination.
            /// </summary>
            /// <param name="input"> Describes the elements available in the input </param>
            /// <param name="joinInsert"> Describes the rule for inserts when the operator is an inner join </param>
            /// <param name="joinDelete"> Describes the rule for deletes when the operator is an inner join </param>
            /// <param name="lojInsert"> Describes the rule for inserts when the operator is a left outer join </param>
            /// <param name="lojDelete"> Describes the rule for deletes when the operator is a left outer join </param>
            private static void InitializeRule(Ops input, Ops joinInsert, Ops joinDelete, Ops lojInsert, Ops lojDelete)
            {
                _innerJoinInsertRules.Add(input, joinInsert);
                _innerJoinDeleteRules.Add(input, joinDelete);
                _leftOuterJoinInsertRules.Add(input, lojInsert);
                _leftOuterJoinDeleteRules.Add(input, lojDelete);

                // Ensure that the right hand side of each rule contains no requests for specific row values
                // that are not also in the input.
                Debug.Assert(
                    (((joinInsert | joinDelete | lojInsert | lojDelete) &
                      (Ops.LeftInsert | Ops.LeftDelete | Ops.RightInsert | Ops.RightDelete)) & (~input)) == Ops.Nothing,
                    "(Update/JoinPropagator/Initialization) Rules can't use unavailable data");

                // An unknown value can appear in both the delete and insert rule result or neither.
                Debug.Assert(
                    ((joinInsert ^ joinDelete) & (Ops.LeftUnknown | Ops.RightUnknown)) == Ops.Nothing &&
                    ((lojInsert ^ lojDelete) & (Ops.LeftUnknown | Ops.RightUnknown)) == Ops.Nothing,
                    "(Update/JoinPropagator/Initialization) Unknowns must appear in both delete and insert rules " +
                    "or in neither (in other words, for updates only)");
            }
コード例 #7
0
ファイル: Controller.cs プロジェクト: alexdad/Sagadata
 public void ChangeOperMode(Ops op)
 {
     CurrentType.EndSelectionMode();
     tabControlOps.SelectedIndex = (int)op;
 }
コード例 #8
0
 public void CleanCache()
 {
     Ops.Fill(TCache, 0.0f);
     //    Ops.Fill(TLrW, 0.0f);
 }
コード例 #9
0
 public Trigger_Threshold( ManagerJob_Hunting job )
 {
     Op = Ops.LowerThan;
     MaxUpperThreshold = DefaultMaxUpperThreshold;
     Count = DefaultCount;
     ThresholdFilter = new ThingFilter();
     ThresholdFilter.SetDisallowAll();
     ThresholdFilter.SetAllow( Utilities_Hunting.RawMeat, true );
 }
コード例 #10
0
 public static object Multiply(int x, object other)
 {
     if (other is int)
     {
         int y = (int)other;
         try {
             return(Ops.Int2Object(checked (x * y)));
         } catch (OverflowException) {
             return(BigInteger.Create(x) * y);
         }
     }
     else if (other is BigInteger)
     {
         return(BigInteger.Create(x) * (BigInteger)other);
     }
     else if (other is double)
     {
         return(x * (double)other);
     }
     else if (other is Complex64)
     {
         return(ComplexOps.Multiply(Complex64.MakeReal(x), other));
     }
     else if (other is bool)
     {
         bool b = (bool)other;
         return(x * (b ? 1 : 0));
     }
     else if (other is long)
     {
         long y = (long)other;
         try {
             return(checked (x * y));
         } catch (OverflowException) {
             return(BigInteger.Create(x) * y);
         }
     }
     else if (other is float)
     {
         return(x * (float)other);
     }
     else if (other is byte)
     {
         return(x * (byte)other);
     }
     else if (other is ExtensibleInt)
     {
         int y = ((ExtensibleInt)other).value;
         try {
             return(Ops.Int2Object(checked (x * y)));
         } catch (OverflowException) {
             return(BigInteger.Create(x) * y);
         }
     }
     else if (other is ExtensibleFloat)
     {
         return(x * ((ExtensibleFloat)other).value);
     }
     else if (other is ExtensibleComplex)
     {
         return(ComplexOps.Multiply(Complex64.MakeReal(x), (ExtensibleComplex)other));
     }
     else if (other is byte)
     {
         int y = (byte)other;
         try {
             return(Ops.Int2Object(checked (x * y)));
         } catch (OverflowException) {
             return(BigInteger.Create(x) * y);
         }
     }
     return(Ops.NotImplemented);
 }
コード例 #11
0
        // Computes  c := alpha * a * b  +  beta * c
        public static void GemmBatch(TSCudaContext context, float alpha, Tensor a, Tensor b, float beta, Tensor c)
        {
            if (a.Sizes[1] != c.Sizes[1] || b.Sizes[2] != c.Sizes[2] || a.Sizes[2] != b.Sizes[1])
            {
                throw new InvalidOperationException("Size mismatch");
            }

            var aOp   = default(BlasOp);
            var bOp   = default(BlasOp);
            var copyC = false;

            Tensor aClone = null;
            Tensor bClone = null;
            Tensor cClone = null;


            if (c.Strides[1] == 1 &&
                c.Strides[2] != 0 && c.Strides[2] != 1)
            {
                // If c is contiguous in dimension 0 (column-major)
                aClone = a.CopyRef();
                bClone = b.CopyRef();
                cClone = c.CopyRef();
            }
            else if (c.Strides[2] == 1 &&
                     c.Strides[1] != 0 && c.Strides[1] != 1)
            {
                // If c is contiguous in dimension 1 (row-major)
                // using (a * b)' == b' * a'
                // we can pass row-major matrices to BLAS functions that expect column-major by swapping A and B,
                // and transposing all 3 matrices

                cClone = c.Transpose(1, 2);
                aClone = b.Transpose(1, 2); // Note swap of a and b
                bClone = a.Transpose(1, 2);
            }
            else
            {
                var cNew = new Tensor(c.Allocator, c.ElementType, c.Sizes[0], c.Sizes[2], c.Sizes[1]);
                cClone = cNew.Transpose(1, 2);
                Ops.Copy(cClone, c);
                cNew.Dispose();
                copyC = true;

                aClone = a.CopyRef();
                bClone = b.CopyRef();
            }

            try
            {
                if (aClone.Strides[1] == 1 &&
                    aClone.Strides[2] != 0 && aClone.Strides[2] != 1)
                {
                    // If a is contiguous in dimension 0 (column-major)
                    aOp = BlasOp.NonTranspose;
                }
                else if (aClone.Strides[2] == 1 &&
                         aClone.Strides[1] != 0 && aClone.Strides[1] != 1)
                {
                    aOp = BlasOp.Transpose;
                    var aNew = aClone.Transpose(1, 2);
                    aClone.Dispose();
                    aClone = aNew;
                }
                else
                {
                    var aNew    = new Tensor(aClone.Allocator, aClone.ElementType, aClone.Sizes[0], aClone.Sizes[2], aClone.Sizes[1]);
                    var aClone2 = aNew.Transpose(1, 2);
                    Ops.Copy(aClone2, aClone);
                    aClone.Dispose();
                    aClone = aClone2;
                    aNew.Dispose();

                    aOp = BlasOp.NonTranspose;
                }

                if (bClone.Strides[1] == 1 &&
                    bClone.Strides[2] != 0 && bClone.Strides[2] != 1)
                {
                    // If a is contiguous in dimension 0 (column-major)
                    bOp = BlasOp.NonTranspose;
                }
                else if (bClone.Strides[2] == 1 &&
                         bClone.Strides[1] != 0 && bClone.Strides[1] != 1)
                {
                    bOp = BlasOp.Transpose;
                    var bNew = bClone.Transpose(1, 2);
                    bClone.Dispose();
                    bClone = bNew;
                }
                else
                {
                    var bNew    = new Tensor(bClone.Allocator, bClone.ElementType, bClone.Sizes[0], bClone.Sizes[2], bClone.Sizes[1]);
                    var bClone2 = bNew.Transpose(1, 2);
                    Ops.Copy(bClone2, bClone);
                    bClone.Dispose();
                    bClone = bClone2;
                    bNew.Dispose();

                    bOp = BlasOp.NonTranspose;
                }

                GemmOpBatch(context, aOp, bOp, alpha, aClone, bClone, beta, cClone);

                if (copyC)
                {
                    Ops.Copy(c, cClone);
                }
            }
            finally
            {
                aClone.Dispose();
                bClone.Dispose();
                cClone.Dispose();
            }
        }
コード例 #12
0
ファイル: Importer.cs プロジェクト: weimingtom/IronPythonMod
        /// <summary>
        /// Gateway into importing ... called from Ops.  Performs the initial import of
        /// a module and returns the module.
        /// </summary>
        internal static object Import(PythonModule mod, string fullName, List from)
        {
            object importFunction = FindImportFunction(mod);

            return(Ops.CallWithContext(mod, importFunction, fullName, null, null, from));
        }
コード例 #13
0
        public void CopyWeights(IWeightMatrix src)
        {
            WeightTensor m = src as WeightTensor;

            Ops.Copy(TWeight, m.TWeight);
        }
コード例 #14
0
 public void ClearWeight()
 {
     Ops.Fill(TWeight, 0.0f);
 }
コード例 #15
0
 public void ClearGradient()
 {
     Ops.Fill(TGradient, 0.0f);
 }
コード例 #16
0
ファイル: Numbers.cs プロジェクト: roffster/clojure-clr
 public abstract Ops combine(Ops y);
コード例 #17
0
ファイル: Numbers.cs プロジェクト: roffster/clojure-clr
 public override Ops combine(Ops y)
 {
     return y.opsWith(this);
 }
コード例 #18
0
 public void Setup()
 {
     ops = new Ops();
 }