Beispiel #1
0
        public void Initialize_CheckDimension_EqualsGivenDimension(uint givenDimension)
        {
            var vec = new DirectSum <T, TStruct>(givenDimension);

            Assert.IsNotNull(vec);

            Assert.AreEqual(givenDimension, vec.Dimension);
        }
Beispiel #2
0
        public void Indexer_SettingToHighDimension_ThrowsVectorException(
            uint dimension,
            uint index)
        {
            var value = default(T);
            var vec   = new DirectSum <T, TStruct>(dimension);

            Assert.IsNotNull(vec);

            Assert.Throws <LinearAlgebraException>(() => vec[index] = value);
        }
Beispiel #3
0
        public void Parse_ValidParse_EqualsExpected <TSet, TStruct, TParser> (
            TSet hack1,
            TStruct hack2,
            TParser hack3,
            DirectSumParser <TSet, TStruct, TParser> parser,
            String stringInput,
            DirectSum <TSet, TStruct> expected)
            where TStruct : IStructure, new()
            where TParser : IParser <TSet>, new()
        {
            var result = parser.Parse(stringInput);

            Assert.IsNotNull(result);

            Assert.AreEqual(expected, result);
        }
Beispiel #4
0
        /// <summary>
        /// Parse the specified stringInput.
        /// </summary>
        /// <param name="inputString">String input.</param>
        /// <returns>A new direct sum with the specified values in the string.</returns>
        /// <exception cref="NotSupportedException">Thrown if the string is not valid to parse.</exception>
        public DirectSum <T, TStruct> Parse(String inputString)
        {
            var matchArray = Regex.Split(inputString, ",");

            if (matchArray.Length <= 0)
            {
                throw new NotSupportedException("No match");
            }

            var tuple = new DirectSum <T, TStruct>((uint)matchArray.Length);

            for (uint i = 0; i < matchArray.Length; i++)
            {
                tuple[i] = this._typeParser.Parse(matchArray[i]);
            }

            return(tuple);
        }