Esempio n. 1
0
        public Expr this[int id]
        {
            get
            {
                IGaTreeMultivectorNode node = this;
                for (var i = 0; i < VSpaceDimension - 1; i++)
                {
                    node = node.GetChild(id);

                    if (ReferenceEquals(node, null))
                    {
                        return(Expr.INT_ZERO);
                    }

                    id >>= 1;
                }

                var leafNode = node.GetChild(id) as GaTreeMultivectorLeaf;
                return(ReferenceEquals(leafNode, null)
                    ? Expr.INT_ZERO
                    : leafNode.Value.Expression);
            }
            set
            {
                IGaTreeMultivectorNode node = this;
                for (var i = 0; i < VSpaceDimension - 1; i++)
                {
                    node = node.GetOrSetChildToInternalNode(id);

                    Debug.Assert(!ReferenceEquals(node, null));

                    id >>= 1;
                }

                var leafNode = node.GetOrSetChildToLeafNode(id, value.ToMathematicaScalar());
                Debug.Assert(!ReferenceEquals(leafNode, null));
            }
        }