Exemplo n.º 1
0
        public static HtmModuleTopology Deserialize(StreamReader sr)
        {
            HtmModuleTopology htm = new HtmModuleTopology();

            HtmSerializer2 ser = new HtmSerializer2();

            while (sr.Peek() >= 0)
            {
                string data = sr.ReadLine();
                if (data == ser.LineDelimiter || data == ser.ReadBegin(nameof(HtmModuleTopology)) || data == ser.ReadEnd(nameof(SegmentActivity)))
                {
                    continue;
                }
                else if (data == ser.ReadEnd(nameof(HtmModuleTopology)))
                {
                    break;
                }
                else
                {
                    string[] str = data.Split(HtmSerializer2.ParameterDelimiter);
                    for (int i = 0; i < str.Length; i++)
                    {
                        switch (i)
                        {
                        case 0:
                        {
                            htm.Dimensions = ser.ReadArrayInt(str[i]);
                            break;
                        }

                        case 1:
                        {
                            htm.IsMajorOrdering = ser.ReadBoolValue(str[i]);
                            break;
                        }

                        case 2:
                        {
                            htm.DimensionMultiplies = ser.ReadArrayInt(str[i]);
                            break;
                        }

                        default:
                        { break; }
                        }
                    }
                }
            }

            return(htm);
        }
Exemplo n.º 2
0
        public static SparseObjectMatrix <T> Deserialize(StreamReader sr)
        {
            SparseObjectMatrix <T> sparse = new SparseObjectMatrix <T>();

            HtmSerializer2 ser = new HtmSerializer2();

            while (sr.Peek() >= 0)
            {
                string data = sr.ReadLine();
                if (data == String.Empty || data == ser.ReadBegin(nameof(SparseObjectMatrix <T>)))
                {
                    continue;
                }
                else if (data == ser.ReadBegin(nameof(HtmModuleTopology)))
                {
                    sparse.ModuleTopology = HtmModuleTopology.Deserialize(sr);
                }
                //else if (data == ser.ReadBegin(nameof(InMemoryDistributedDictionary<TKey, TValue>) <{ nameof(TKey}>))
                //{
                //    sparse.m_SparseMap = InMemoryDistributedDictionary<TKey, TValue>.Deserialize(sr);
                //}
                else if (data == ser.ReadEnd(nameof(SparseObjectMatrix <T>)))
                {
                    break;
                }
                else
                {
                    string[] str = data.Split(HtmSerializer2.ParameterDelimiter);
                    for (int i = 0; i < str.Length; i++)
                    {
                        switch (i)
                        {
                        case 0:
                        {
                            //sparse.IsRemotelyDistributed = ser.ReadBoolValue(str[i]);
                            break;
                        }

                        default:
                        { break; }
                        }
                    }
                }
            }
            return(sparse);
        }
Exemplo n.º 3
0
        public static SparseBinaryMatrix Deserialize(StreamReader sr)
        {
            SparseBinaryMatrix sparse = new SparseBinaryMatrix();
            HtmSerializer2     ser    = new HtmSerializer2();

            while (sr.Peek() >= 0)
            {
                string data = sr.ReadLine();
                if (data == String.Empty || data == ser.ReadBegin(nameof(SparseBinaryMatrix)))
                {
                    continue;
                }
                else if (data == ser.ReadBegin(nameof(InMemoryArray)))
                {
                    sparse.backingArray = InMemoryArray.Deserialize(sr);
                }
                else if (data == ser.ReadBegin(nameof(HtmModuleTopology)))
                {
                    sparse.ModuleTopology = HtmModuleTopology.Deserialize(sr);
                }
                else if (data == ser.ReadEnd(nameof(SparseBinaryMatrix)))
                {
                    break;
                }
                else
                {
                    string[] str = data.Split(HtmSerializer2.ParameterDelimiter);
                    for (int i = 0; i < str.Length; i++)
                    {
                        switch (i)
                        {
                        case 0:
                        {
                            sparse.trueCounts = ser.ReadArrayInt(str[i]);
                            break;
                        }

                        default:
                        { break; }
                        }
                    }
                }
            }
            return(sparse);
        }
Exemplo n.º 4
0
        public bool Equals(HtmModuleTopology obj)
        {
            if (this == obj)
            {
                return(true);
            }
            if (obj == null)
            {
                return(false);
            }
            if ((obj.GetType() != this.GetType()))
            {
                return(false);
            }

            //HtmModuleTopology other = (HtmModuleTopology)obj;
            if (this.IsMajorOrdering != obj.IsMajorOrdering)
            {
                return(false);
            }
            if (obj.Dimensions != null && this.Dimensions != null)
            {
                if (!obj.Dimensions.SequenceEqual(this.Dimensions))
                {
                    return(false);
                }
            }
            if (obj.DimensionMultiplies != null && this.DimensionMultiplies != null)
            {
                if (!obj.DimensionMultiplies.SequenceEqual(this.DimensionMultiplies))
                {
                    return(false);
                }
            }
            return(true);
        }