Exemplo n.º 1
0
        public static GaFrame CreateOrthonormal(IEnumerable <char> frameSigSignList)
        {
            var psgCount = 0;
            var nsgCount = 0;
            var s        = new StringBuilder();
            var sigList  = new List <int>(FrameUtils.MaxVSpaceDimension);

            //Convert the string signature into a list of integers with values of 1 and -1.
            foreach (var c in frameSigSignList)
            {
                switch (c)
                {
                case '+':
                    sigList.Add(1);
                    s.Append("+");
                    psgCount++;
                    break;

                case '-':
                    sigList.Add(-1);
                    s.Append("-");
                    nsgCount++;
                    break;

                default:
                    throw new GMacSymbolicException("Invalid orthonormal frame signature");
                }
            }

            var vSpaceDim = psgCount + nsgCount;

            VerifyVSpaceDim(vSpaceDim);

            var     frameSig = s.ToString();
            GaFrame gaFrame;

            if (OrthonormalFramesCache.TryGetValue(frameSig, out gaFrame))
            {
                return(gaFrame);
            }

            //The frame signature has no vectors with negative signature; create a Euclidean frame
            if (nsgCount == 0)
            {
                gaFrame = new GaFrameEuclidean(vSpaceDim);
            }

            //Else create an orthonormal frame
            else
            {
                gaFrame = new GaFrameOrthonormal(sigList.ToArray());
            }

            OrthonormalFramesCache.Add(frameSig, gaFrame);

            return(gaFrame);
        }
Exemplo n.º 2
0
        public static GaFrameEuclidean CreateEuclidean(int vSpaceDim)
        {
            VerifyVSpaceDim(vSpaceDim);

            GaFrame gaFrame;
            var     frameSig = GetOrthonormalSignatureString(vSpaceDim);

            if (OrthonormalFramesCache.TryGetValue(frameSig, out gaFrame))
            {
                return((GaFrameEuclidean)gaFrame);
            }

            gaFrame = new GaFrameEuclidean(vSpaceDim);

            OrthonormalFramesCache.Add(frameSig, gaFrame);

            return((GaFrameEuclidean)gaFrame);
        }