Example #1
0
 protected  AccumulatorBase(IAccumulator src, IAccumulator joined)
 {
     Columns = new List<string>(src.Columns);
     IsBound = src.IsBound.Select((x, i) => x || joined.IsBound[i]).ToArray();
     HighestBoundColumnIndex = Math.Max(src.HighestBoundColumnIndex, joined.HighestBoundColumnIndex);
     BoundVariables = IsBound.Where(x => x).Select((x, i) => Columns[i]).ToList();
     SortOrder = new List<int>(src.SortOrder);
 }
Example #2
0
 protected AccumulatorBase(IAccumulator src  )
 {
     Columns = new List<string>(src.Columns);
     IsBound = new bool[src.IsBound.Length]; 
     src.IsBound.CopyTo(IsBound, 0);
     HighestBoundColumnIndex = src.HighestBoundColumnIndex;
     BoundVariables = new List<string>(src.BoundVariables);
     SortOrder = new List<int>(src.SortOrder);
 }
        public IncrementalRenderer()
        {
            ViewsPerFrame = 1;

            SampleCount = 16;
            TotalSampleCount = MaxTotalSampleCount;
            ShuffleLensSamples = true;

            // draw all views at once
            //viewsPerFrame = maxIterations;

            //accumulator = new BufferAccumulator();
            accumulator = new FboAccumulator();
        }
Example #4
0
        public virtual IAccumulator Join(IAccumulator inner)
        {
            if (inner.HighestBoundColumnIndex < HighestBoundColumnIndex)
            {
                // Swap the join order
                return inner.Join(this);
            }

            // Inner needs to be materialized to allow rewinds
            if (inner is VirtualizingAccumulator)
            {
                inner = (inner as VirtualizingAccumulator).Materialize();
            }
            
            bool haveOverlap = false;
            for(int i = 0; i < IsBound.Length && !haveOverlap; i++)
            {
                haveOverlap = IsBound[i] && inner.IsBound[i];
            }

            if (!haveOverlap)
            {
                return Product(inner);
            }
            var sortedOuter = Sort(Columns.Where((x, i) => IsBound[i] && inner.IsBound[i]));
            var sortedInner = inner.Sort(Columns.Where((x, i) => IsBound[i] && inner.IsBound[i]));
            return JoinSorted(sortedOuter, sortedInner);

        }
Example #5
0
        private IAccumulator Product(IAccumulator other)
        {
            var product = new Accumulator(Columns, BoundVariables.Union(other.BoundVariables));
            /*
            IEnumerable<ulong[]> outerEnumerator, innerEnumerator;
            if (this.HighestBoundColumnIndex < other.HighestBoundColumnIndex)
            {
                outerEnumerator = this.Rows;
                innerEnumerator = other.Rows;
            }
            else
            {
                // This accumulator needs to be inner, so if it is a virtual one we need to materialize it first
                if (this is VirtualizingAccumulator)
                {
                    return (this as VirtualizingAccumulator).Materialize().Product(other);
                }
                outerEnumerator = other.Rows;
                innerEnumerator = this.Rows;
            }
            foreach(var outer in outerEnumerator)
            {
                foreach(var inner in innerEnumerator)
                {
                    product.AddRow(RowJoin(outer, inner));
                }
            }
             */

            IEnumerable<ulong[]> outerEnumerator = this.Rows;
            IEnumerable<ulong[]> innerEnumerator = other.Rows;
            foreach(var outer in outerEnumerator)
            {
                foreach(var inner in innerEnumerator)
                {
                    product.AddRow(RowJoin(outer, inner));
                }
            }

            // Update the sort order for the product
            product.SortOrder = this.SortOrder;
            foreach(var sortCol in other.SortOrder)
            {
                if(!product.SortOrder.Contains(sortCol)) product.SortOrder.Add(sortCol);
            }

            return product;
        }
Example #6
0
        private static IAccumulator JoinSorted(IAccumulator outer, IAccumulator inner)
        {
            var output = new Accumulator(outer, inner);
            IEnumerator<ulong[]> outerEnumerator = outer.Rows.GetEnumerator();
            if (inner is VirtualizingAccumulator) inner = (inner as VirtualizingAccumulator).Materialize();
            var innerAcc = inner as Accumulator;
            RewindableListEnumerator<ulong[]> innerEnumerator = innerAcc.RewindableEnumerator;
            //IEnumerator<ulong[]> innerEnumerator = inner.Rows.GetEnumerator();

            bool keepGoing = outerEnumerator.MoveNext() && innerEnumerator.MoveNext();
            while (keepGoing)
            {
                while (keepGoing && RowMatch(outerEnumerator.Current, innerEnumerator.Current))
                {
                    output.AddRow(RowJoin(outerEnumerator.Current, innerEnumerator.Current));
                    innerEnumerator.SetMark();
                    bool innerKeepGoing = innerEnumerator.MoveNext();
                    while (innerKeepGoing && RowMatch(outerEnumerator.Current, innerEnumerator.Current))
                    {
                        output.AddRow(RowJoin(outerEnumerator.Current, innerEnumerator.Current));
                        innerKeepGoing = innerEnumerator.MoveNext();
                    }
                    innerEnumerator.RewindToMark();
                    keepGoing = outerEnumerator.MoveNext();
                }
                if (keepGoing)
                {
                    var cmp = RowCompare(outerEnumerator.Current, innerEnumerator.Current);
                    while (cmp != 0 && keepGoing)
                    {
                        keepGoing = cmp > 0 ? innerEnumerator.MoveNext() : outerEnumerator.MoveNext();
                        if (keepGoing) cmp = RowCompare(outerEnumerator.Current, innerEnumerator.Current);
                    }
                }
                if (!keepGoing)
                {
                    keepGoing = outerEnumerator.MoveNext();
                    if (keepGoing)
                    {
                        innerEnumerator.Reset();
                        keepGoing &= innerEnumerator.MoveNext();
                    }
                }
                /*
                while (keepGoing && RowCompare(outerEnumerator.Current, innerEnumerator.Current) < 0)
                    keepGoing = outerEnumerator.MoveNext();
                while (keepGoing && RowCompare(outerEnumerator.Current, innerEnumerator.Current) > 0)
                    keepGoing = innerEnumerator.MoveNext();
                     */
            }
            return output;
        }
 public DefaultAccelerometer(string name, IAnalogInput acceleration, IAccumulator velocity, IAccumulator position) : base(name, DeviceType.Accelerometer) {
    this.acceleration = acceleration;
    this.velocity = velocity;
    this.position = position;
 }
 public DefaultGyroscope(string name, IAnalogInput angularAcceleration, IAccumulator angularVelocity, IAccumulator angularPosition) : base(name, DeviceType.Gyroscope) {
    this.angularAcceleration = angularAcceleration;
    this.angularVelocity = angularVelocity;
    this.angularPosition = angularPosition;
 }
Example #9
0
        private void rollDetail(string pair, int offset, TimeFrame baseTimeFrame, 
            IAccumulator accumHi, IAccumulator accumLo, PriceComponent highComp, PriceComponent lowComp)
        {
            double high = Double.NaN;
            double low = Double.NaN;

            IAccumulator accumHi2 = getAccum(pair, baseTimeFrame, highComp);
            IAccumulator accumLo2 = getAccum(pair, baseTimeFrame, lowComp);

            List<double> ldh = accumHi2.getList();
            if (ldh.Count >= offset)
            {
                List<double> ldh2 = ldh.GetRange(ldh.Count - offset, offset);
                high = ldh2.Max();
            }
            List<double> ldl = accumLo2.getList();
            if (ldl.Count >= offset)
            {
                List<double> ldl2 = ldh.GetRange(ldh.Count - offset, offset);
                low = ldl2.Min();
            }
            if (!Double.IsNaN(high))
                accumHi.addLast(high);
            if (!Double.IsNaN(low))
                accumLo.addLast(low);
        }
Example #10
0
 private void debugList(string title, string pair, TimeFrame timeFrame, IAccumulator accum)
 {
     if (!debug) return;
     log.debug("roll "+title+":" + pair + ":" + ExpertFactory.timeFrameMap[timeFrame]);
     StringBuilder sb = new StringBuilder();
     writeShortenedList(accum.getList(), sb);
     log.debug(title + "(" + accum.getList().Count + ")=" + sb.ToString());
 }