Пример #1
0
        public WaveletPacket FindSubspace(WaveletSubspace subspace)
        {
            // if this isn't the top of the tree move to the top of the tree
            WaveletPacket top = this;

            while (top.Parent != null)
            {
                top = top.Parent;
            }

            if (subspace.DecompositionLevel == top.DecompositionLevel)
            {
                return(top);
            }
            // do a recursive tree search for the desired subspace and return it
            return(SearchSubspace(top, subspace));
        }
Пример #2
0
        private WaveletPacket SearchSubspace(WaveletPacket top, WaveletSubspace subspace)
        {
            if (subspace.DecompositionLevel == top.LeftChild.DecompositionLevel)
            {
                if (subspace.SubspaceIndex == top.LeftChild.SubspaceIndex)
                {
                    return(top.LeftChild);
                }
                return(top.RightChild);
            }
            else
            {
                int levelDiff    = (subspace.DecompositionLevel - top.LeftChild.DecompositionLevel);
                int maxLeftIndex = top.LeftChild.SubspaceIndex * (levelDiff * 2) + ((int)Math.Pow(2, levelDiff) - 1);

                if (subspace.SubspaceIndex <= maxLeftIndex)
                {
                    return(SearchSubspace(top.LeftChild, subspace));
                }
                return(SearchSubspace(top.RightChild, subspace));
            }
        }