Beispiel #1
0
        public double MaxDiff(object thatd)
        {
            DistributionCursorArray <DistributionType, DomainType> that = thatd as DistributionCursorArray <DistributionType, DomainType>;

            if (that == null)
            {
                return(Double.PositiveInfinity);
            }
            if (!IsCompatibleWith(that))
            {
                return(Double.PositiveInfinity);
            }
            double max = 0;
            IEnumerator <DistributionType> iter = that.GetEnumerator();

            foreach (DistributionType d in this)
            {
                bool ok = iter.MoveNext();
                Assert.IsTrue(ok);
                double diff = ((Diffable)d).MaxDiff(iter.Current);
                if (diff > max)
                {
                    max = diff;
                }
            }
            return(max);
        }
Beispiel #2
0
        public override bool Equals(object thatd)
        {
            DistributionCursorArray <DistributionType, DomainType> that = thatd as DistributionCursorArray <DistributionType, DomainType>;

            if (that == null)
            {
                return(false);
            }
            if (!IsCompatibleWith(that))
            {
                return(false);
            }
            IEnumerator <DistributionType> iter = that.GetEnumerator();

            foreach (DistributionType d in this)
            {
                bool ok = iter.MoveNext();
                Assert.IsTrue(ok);
                if (!d.Equals(iter.Current))
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #3
0
        public void SetTo(DistributionCursorArray <DistributionType, DomainType> that)
        {
            CheckCompatible(that);
            Action action = delegate() { cursor.SetTo(that.cursor); };

            ForEach(that, action);
        }
Beispiel #4
0
        // a and b may be the same object as this.
        public void SetToProduct(DistributionCursorArray <DistributionType, DomainType> a, DistributionCursorArray <DistributionType, DomainType> b)
        {
            CheckCompatible(a);
            CheckCompatible(b);
            Action action = delegate() { cursor.SetToProduct(a.cursor, b.cursor); };

            ForEach(a, b, action);
        }
Beispiel #5
0
        public bool IsCompatibleWith(object thatd)
        {
            DistributionCursorArray <DistributionType, DomainType> that = thatd as DistributionCursorArray <DistributionType, DomainType>;

            if (that == null)
            {
                return(false);
            }
            if (!base.IsCompatibleWith(that))
            {
                return(false);
            }
            return(true);
            //return cursor.IsCompatibleWith(that.cursor);
        }
Beispiel #6
0
        Split(IList <bool> isOuterDimension)
        {
            int outerRank = StringUtil.Sum(isOuterDimension);

            if (outerRank == 0)
            {
                throw new ArgumentException("No outer dimensions chosen");
            }
            int innerRank = Rank - outerRank;

            if (innerRank == 0)
            {
                throw new ArgumentException("No inner dimensions left");
            }
            int[] innerLengths = new int[innerRank];
            int[] innerStride  = new int[innerRank];
            int[] outerLengths = new int[outerRank];
            int[] outerStride  = new int[outerRank];
            int   innerIndex   = 0;
            int   outerIndex   = 0;
            int   i            = 0;

            foreach (bool isOuter in isOuterDimension)
            {
                if (isOuter)
                {
                    outerLengths[outerIndex] = dim[i];
                    outerStride[outerIndex]  = stride[i];
                    outerIndex++;
                }
                else
                {
                    innerLengths[innerIndex] = dim[i];
                    innerStride[innerIndex]  = stride[i];
                    innerIndex++;
                }
                i++;
            }
            DistributionCursorArray <DistributionType, DomainType> inner =
                new DistributionCursorArray <DistributionType, DomainType>
                    ((DistributionType)this[0].ReferenceClone(), innerLengths, innerStride);

            return(new DistributionCursorArray <DistributionCursorArray <DistributionType, DomainType>, DomainType[]>
                       (inner, outerLengths, outerStride));
        }