Пример #1
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);
        }
Пример #2
0
        public bool Equals(SparseBinaryMatrix obj)
        {
            if (this == obj)
            {
                return(true);
            }

            if (obj == null)
            {
                return(false);
            }

            if (backingArray == null)
            {
                if (obj.backingArray != null)
                {
                    return(false);
                }
            }
            else if (!backingArray.Equals(obj.backingArray))
            {
                return(false);
            }

            if (ModuleTopology == null)
            {
                if (obj.ModuleTopology != null)
                {
                    return(false);
                }
            }
            else if (!ModuleTopology.Equals(obj.ModuleTopology))
            {
                return(false);
            }
            if (this.trueCounts != obj.trueCounts)
            {
                return(false);
            }

            return(true);
        }
Пример #3
0
        public static Column Deserialize(StreamReader sr)
        {
            Column column = new Column();

            HtmSerializer2 ser = new HtmSerializer2();


            while (!sr.EndOfStream)
            {
                string data = sr.ReadLine();
                if (data == String.Empty || data == ser.ReadBegin(nameof(Column)) || data == ser.ValueDelimiter)
                {
                    continue;
                }
                else if (data == ser.ReadBegin(nameof(SparseBinaryMatrix)))
                {
                    column.connectedInputCounter = SparseBinaryMatrix.Deserialize(sr);
                }
                //else if (data == ser.ReadBegin(nameof(SparseBinaryMatrix)))
                //{
                //    column.ConnectedInputCounterMatrix = SparseBinaryMatrix.Deserialize(sr);
                //}
                else if (data == ser.ReadBegin(nameof(ProximalDendrite)))
                {
                    column.ProximalDendrite = ProximalDendrite.Deserialize(sr);
                }
                else if (data == ser.ReadBegin(nameof(Cell)))
                {
                    column.Cells = ser.DeserializeCellArray(data, sr);
                }
                else if (data == ser.ReadEnd(nameof(Column)))
                {
                    break;
                }
                else
                {
                    string[] str = data.Split(HtmSerializer2.ParameterDelimiter);
                    for (int i = 0; i < str.Length; i++)
                    {
                        switch (i)
                        {
                        case 0:
                        {
                            column.CellId = ser.ReadIntValue(str[i]);
                            break;
                        }

                        case 1:
                        {
                            column.Index = ser.ReadIntValue(str[i]);
                            break;
                        }

                        default:
                        { break; }
                        }
                    }
                }
            }
            return(column);
        }