Пример #1
0
        public void Space()
        {
            var S = new Space(2, 3, 4);

            Assert.AreEqual(2, S.PositiveDimension);
            Assert.AreEqual(3, S.NegativeDimension);
            Assert.AreEqual(4, S.NilpotentDimension);
            Assert.AreEqual(9, S.Dimension);

            Assert.AreEqual(0b000, S.IndexFromBladeBasis(0, 0));
            Assert.AreEqual(0b001, S.IndexFromBladeBasis(1, 0));
            Assert.AreEqual(0b010, S.IndexFromBladeBasis(1, 1));
            Assert.AreEqual(0b100, S.IndexFromBladeBasis(1, 2));
            Assert.AreEqual(0b011, S.IndexFromBladeBasis(2, 0));
            Assert.AreEqual(0b101, S.IndexFromBladeBasis(2, 1));
            Assert.AreEqual(0b110, S.IndexFromBladeBasis(2, 8));
            Assert.AreEqual(0b111, S.IndexFromBladeBasis(3, 0));
            Assert.AreEqual(0b111111111, S.IndexFromBladeBasis(9, 0));

            Assert.AreEqual((0, 0), S.BladeBasisFromIndex(0b000));
            Assert.AreEqual((1, 0), S.BladeBasisFromIndex(0b001));
            Assert.AreEqual((1, 1), S.BladeBasisFromIndex(0b010));
            Assert.AreEqual((1, 2), S.BladeBasisFromIndex(0b100));
            Assert.AreEqual((2, 0), S.BladeBasisFromIndex(0b011));
            Assert.AreEqual((2, 1), S.BladeBasisFromIndex(0b101));
            Assert.AreEqual((2, 8), S.BladeBasisFromIndex(0b110));
            Assert.AreEqual((3, 0), S.BladeBasisFromIndex(0b111));
            Assert.AreEqual((9, 0), S.BladeBasisFromIndex(0b111111111));

            Assert.AreEqual(new Multivector(S), S.Zero);

            Assert.AreEqual(1, S.BasisSquared(0, 0));
            Assert.AreEqual(1, S.BasisSquared(1, 0));
            Assert.AreEqual(1, S.BasisSquared(1, 1));
            Assert.AreEqual(-1, S.BasisSquared(1, 2));
            Assert.AreEqual(-1, S.BasisSquared(1, 3));
            Assert.AreEqual(-1, S.BasisSquared(1, 4));
            Assert.AreEqual(0, S.BasisSquared(1, 5));
            Assert.AreEqual(0, S.BasisSquared(1, 6));
            Assert.AreEqual(0, S.BasisSquared(1, 7));
            Assert.AreEqual(0, S.BasisSquared(1, 8));

            Assert.Throws <IndexOutOfRangeException>(() => S.BasisSquared(1, 9), "Base number out of range");

            for (uint i = 0; i < 1 << 9; i++)
            {
                Assert.AreEqual(
                    (0, S.BasisSquared(i)),
                    S.BasisMultiply(i, i)
                    );
            }

            Assert.AreEqual(1, S.BasisSquared(0b000010111));
            Assert.AreEqual(-1, S.BasisSquared(0b000011001));
            Assert.AreEqual(-1, S.BasisSquared(0b000001101));
            Assert.AreEqual(0, S.BasisSquared(0b110100110));
            Assert.AreEqual(0, S.BasisSquared(0b010010001));

            Assert.AreEqual((0b011111, 1), S.BasisMultiply(0b001101, 0b010010));
            Assert.AreEqual((0b100110, 1), S.BasisMultiply(0b110101, 0b010011));
            Assert.AreEqual(0, S.BasisMultiply(0b101110, 0b110101).Sign);
        }