public static GaNumFrame CreateOrthonormal(IEnumerable <char> frameSigSignList) { var psgCount = 0; var nsgCount = 0; var s = new StringBuilder(); var sigList = new List <bool>(GMacMathUtils.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(false); s.Append("+"); psgCount++; break; case '-': sigList.Add(true); s.Append("-"); nsgCount++; break; default: throw new GMacNumericException("Invalid orthonormal frame signature"); } } var vSpaceDim = psgCount + nsgCount; VerifyVSpaceDim(vSpaceDim); var frameSig = s.ToString(); GaNumFrame 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 GaNumFrameEuclidean(vSpaceDim); } //Else create an orthonormal frame else { gaFrame = new GaNumFrameOrthonormal(sigList.ToArray()); } OrthonormalFramesCache.Add(frameSig, gaFrame); return(gaFrame); }
public static GaNumFrameEuclidean CreateEuclidean(int vSpaceDim) { VerifyVSpaceDim(vSpaceDim); GaNumFrame gaFrame; var frameSig = GetOrthonormalSignatureString(vSpaceDim); if (OrthonormalFramesCache.TryGetValue(frameSig, out gaFrame)) { return((GaNumFrameEuclidean)gaFrame); } gaFrame = new GaNumFrameEuclidean(vSpaceDim); OrthonormalFramesCache.Add(frameSig, gaFrame); return((GaNumFrameEuclidean)gaFrame); }