Esempio n. 1
0
        public void TestAddColumnValues2()
        {
            ObjectMatrix <int> matrix = GetTestMatrix();

            int columnCount = matrix.Columns;
            int rowCount    = matrix.Rows;

            matrix.AddColumn(0, -1, -2);

            Assert.AreEqual(matrix.Columns, columnCount + 1);
            Assert.AreEqual(matrix.Rows, rowCount);

            for (int i = 0; i < rowCount; i++)
            {
                for (int j = 0; j < columnCount; j++)
                {
                    Assert.AreEqual(matrix[i, j], i + j);
                }
            }

            Assert.AreEqual(matrix[0, columnCount], 0);
            Assert.AreEqual(matrix[1, columnCount], -1);
            Assert.AreEqual(matrix[2, columnCount], -2);
            Assert.AreEqual(matrix[3, columnCount], 0);
        }
Esempio n. 2
0
        /// <summary>
        /// Evaluates the node, using the variables provided in the <paramref name="Variables"/> collection.
        /// </summary>
        /// <param name="Variables">Variables collection.</param>
        /// <returns>Result.</returns>
        public override IElement Evaluate(Variables Variables)
        {
            IElement        E        = this.Argument.Evaluate(Variables);
            object          Obj      = E.AssociatedObjectValue;
            List <IElement> Elements = new List <IElement>();

            if (Obj is Type T)
            {
                foreach (FieldInfo FI in T.GetRuntimeFields())
                {
                    Elements.Add(new StringValue(FI.Name));
                }

                return(new ObjectVector(Elements));
            }
            else
            {
                T = Obj.GetType();

                foreach (FieldInfo FI in T.GetRuntimeFields())
                {
                    Elements.Add(new StringValue(FI.Name));
                    Elements.Add(Expression.Encapsulate(FI.GetValue(Obj)));
                }

                ObjectMatrix M = new ObjectMatrix(Elements.Count / 2, 2, Elements)
                {
                    ColumnNames = new string[] { "Name", "Value" }
                };

                return(M);
            }
        }
Esempio n. 3
0
 void Start()
 {
     om      = GameObject.Find("GameController").GetComponent <ObjectMatrix> ();
     rows    = om.rows;
     columns = om.columns;
     effective_alpha_value = alpha_value / 255;
 }
Esempio n. 4
0
        public void ConstructorExample()
        {
            var matrix = new ObjectMatrix <double>(2, 3);

            Assert.AreEqual(2, matrix.Rows);
            Assert.AreEqual(3, matrix.Columns);
        }
Esempio n. 5
0
        protected override void WriteData(DataBuffer buf, FileFormat fmt)
        {
            buf.Write(ModelIndex);
            buf.Write(Handle);
            buf.Write(Matrix.Compress());
            if ((fmt.IsPS2 && fmt.IsJapanese) || !fmt.IsPS2)
            {
                buf.Skip(4);
            }
            buf.Write(UprootLimit);
            buf.Write(ObjectMatrix.Compress());
            if ((fmt.IsPS2 && fmt.IsJapanese) || !fmt.IsPS2)
            {
                buf.Skip(4);
            }
            buf.Write((byte)CreatedBy);
            buf.Write(IsPickup);
            buf.Write(IsPickupInShop);
            buf.Write(IsPickupOutOfStock);
            buf.Write(IsGlassCracked);
            buf.Write(IsGlassBroken);
            buf.Write(HasBeenDamaged);
            buf.Write(UseCarColors);
            buf.Write(CostValue);
            buf.Write(BonusValue);
            buf.Skip(1);
            buf.Write(CollisionDamageMultiplier);
            buf.Write(CollisionDamageEffect);
            buf.Write(SpecialCollisionResponseCases);
            buf.Write(EndOfLifeTime);
            SaveEntityFlags(buf, fmt);

            Debug.Assert(buf.Offset == SizeOfType <PhysicalObject>(fmt));
        }
Esempio n. 6
0
        public void GetSubMatrixExample()
        {
            var matrix = new ObjectMatrix <double>(3, 3);

            matrix[0, 0] = 1;
            matrix[0, 1] = 2;
            matrix[0, 2] = 3;
            matrix[1, 0] = 4;
            matrix[1, 1] = 5;
            matrix[1, 2] = 6;
            matrix[2, 0] = 7;
            matrix[2, 1] = 8;
            matrix[2, 2] = 9;


            var result1 = matrix.GetSubMatrix(0, 0, 1, 1);

            Assert.AreEqual(1, result1.Rows);
            Assert.AreEqual(1, result1.Columns);

            var result2 = matrix.GetSubMatrix(1, 2, 2, 1);

            Assert.AreEqual(2, result2.Rows);
            Assert.AreEqual(1, result2.Columns);
        }
Esempio n. 7
0
        public void TestAddColumnValues1()
        {
            ObjectMatrix <int> matrix = GetTestMatrix();

            int columnCount = matrix.Columns;
            int rowCount    = matrix.Rows;

            matrix.AddColumn(0, -1, -2, -3, -4, -5, -6, -7, -8, -9);

            Assert.AreEqual(matrix.Columns, columnCount + 1);
            Assert.AreEqual(matrix.Rows, rowCount);

            for (int i = 0; i < rowCount; i++)
            {
                for (int j = 0; j < columnCount; j++)
                {
                    Assert.AreEqual(matrix[i, j], i + j);
                }
            }

            for (int i = 0; i < rowCount; i++)
            {
                Assert.AreEqual(matrix[i, columnCount], -1 * i);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Evaluates the node, using the variables provided in the <paramref name="Variables"/> collection.
        /// </summary>
        /// <param name="Variables">Variables collection.</param>
        /// <returns>Result.</returns>
        public override IElement Evaluate(Variables Variables)
        {
            IElement        E        = this.Argument.Evaluate(Variables);
            object          Obj      = E.AssociatedObjectValue;
            List <IElement> Elements = new List <IElement>();

            if (Obj is Type T)
            {
                foreach (MethodInfo MI in T.GetTypeInfo().DeclaredMethods)
                {
                    Elements.Add(new StringValue(ToString(MI)));
                }

                return(new ObjectVector(Elements));
            }
            else
            {
                T = Obj.GetType();

                foreach (MethodInfo MI in T.GetTypeInfo().DeclaredMethods)
                {
                    Elements.Add(new StringValue(MI.Name));
                    Elements.Add(new ObjectValue(new MethodLambda(Obj, MI)));
                }

                ObjectMatrix M = new ObjectMatrix(Elements.Count / 2, 2, Elements)
                {
                    ColumnNames = new string[] { "Name", "Lambda" }
                };

                return(M);
            }
        }
Esempio n. 9
0
        public void TestInterfaceGetEnumerator()
        {
            ObjectMatrix <int> m = GetTestMatrix();

            List <int> l = new List <int>();

            IEnumerator enumerator = ((IEnumerable)m).GetEnumerator();

            {
                while (enumerator.MoveNext())
                {
                    l.Add((int)enumerator.Current);
                }
            }

            Assert.AreEqual(l.Count, m.Columns * m.Rows);

            for (int i = 0; i < m.Rows; i++)
            {
                for (int j = 0; j < m.Columns; j++)
                {
                    Assert.AreEqual(l.Contains(i + j), true);
                }
            }
        }
Esempio n. 10
0
        public void TestGetSubMatrix()
        {
            ObjectMatrix <int> matrix = GetTestMatrix();

            ObjectMatrix <int> result = matrix.GetSubMatrix(0, 0, 3, 3);

            Assert.AreEqual(result.Rows, 3);
            Assert.AreEqual(result.Columns, 3);

            for (int i = 0; i < result.Rows; i++)
            {
                for (int j = 0; j < result.Columns; j++)
                {
                    Assert.AreEqual(result[i, j], i + j);
                }
            }

            result = matrix.GetSubMatrix(1, 2, 3, 3);

            for (int i = 0; i < result.Rows; i++)
            {
                for (int j = 0; j < result.Columns; j++)
                {
                    Assert.AreEqual(result[i, j], i + 1 + j + 2);
                }
            }
        }
Esempio n. 11
0
        private void Test(string Script, object[][] ExpectedOutput)
        {
            Variables  v   = new Variables();
            Expression Exp = new Expression(Script);
            object     Obj = Exp.Evaluate(v);

            Console.Out.WriteLine(Expression.ToString(Obj));

            ObjectMatrix M = Obj as ObjectMatrix;
            int          NrRows, RowIndex;
            int          NrColumns, ColumnIndex;

            Assert.IsNotNull(M, "Object matrix expected.");
            Assert.AreEqual(NrRows = ExpectedOutput.Length, M.Rows, "Number of rows in response incorrect.");

            for (RowIndex = 0; RowIndex < NrRows; RowIndex++)
            {
                object[]     ExpectedRow = ExpectedOutput[RowIndex];
                ObjectVector Row         = M.GetRow(RowIndex) as ObjectVector;

                Assert.IsNotNull(Row, "Object row vector expected.");
                Assert.AreEqual(NrColumns = ExpectedRow.Length, Row.Dimension, "Number of columns in response incorrect.");

                for (ColumnIndex = 0; ColumnIndex < NrColumns; ColumnIndex++)
                {
                    Assert.AreEqual(ExpectedRow[ColumnIndex], Row.GetElement(ColumnIndex).AssociatedObjectValue);
                }
            }
        }
Esempio n. 12
0
        public void TestGetRow()
        {
            ObjectMatrix <int> matrix = GetTestMatrix();

            int columnCount = matrix.Columns;
            int rowCount    = matrix.Rows;

            int[] row = matrix.GetRow(0);

            Assert.AreEqual(matrix.Columns, columnCount);
            Assert.AreEqual(matrix.Rows, rowCount);

            Assert.AreEqual(row.Length, matrix.Columns);

            for (int i = 0; i < row.Length; i++)
            {
                Assert.AreEqual(row[i], i);
            }

            row = matrix.GetRow(1);

            Assert.AreEqual(row.Length, matrix.Columns);

            for (int i = 0; i < row.Length; i++)
            {
                Assert.AreEqual(row[i], i + 1);
            }
        }
Esempio n. 13
0
        public void TestInterchangeColumns()
        {
            ObjectMatrix <int> matrix = GetTestMatrix();

            int columnCount = matrix.Columns;
            int rowCount    = matrix.Rows;

            matrix.InterchangeColumns(0, 1);

            Assert.AreEqual(matrix.Columns, columnCount);
            Assert.AreEqual(matrix.Rows, rowCount);

            for (int i = 0; i < matrix.Rows; i++)
            {
                for (int j = 0; j < matrix.Columns; j++)
                {
                    if (j == 0)
                    {
                        Assert.AreEqual(matrix[i, j], (i) + (j + 1));
                    }
                    else if (j == 1)
                    {
                        Assert.AreEqual(matrix[i, j], (i) + (j - 1));
                    }
                    else
                    {
                        Assert.AreEqual(matrix[i, j], i + j);
                    }
                }
            }
        }
Esempio n. 14
0
        public void TestResizeLarger()
        {
            ObjectMatrix <int> matrix = GetTestMatrix();

            int columnCount = matrix.Columns;
            int rowCount    = matrix.Rows;

            matrix.Resize(20, 20);

            Assert.AreEqual(matrix.Columns, 20);
            Assert.AreEqual(matrix.Rows, 20);

            for (int i = 0; i < rowCount; i++)
            {
                for (int j = 0; j < columnCount; j++)
                {
                    Assert.AreEqual(matrix[i, j], i + j);
                }
            }

            for (int i = rowCount; i < 20; i++)
            {
                for (int j = columnCount; j < 20; j++)
                {
                    Assert.AreEqual(matrix[i, j], default(double));
                }
            }
        }
Esempio n. 15
0
        public void TestGetColumn()
        {
            ObjectMatrix <int> matrix = GetTestMatrix();

            int columnCount = matrix.Columns;
            int rowCount    = matrix.Rows;

            int[] column = matrix.GetColumn(0);

            Assert.AreEqual(matrix.Columns, columnCount);
            Assert.AreEqual(matrix.Rows, rowCount);

            Assert.AreEqual(column.Length, matrix.Rows);

            for (int i = 0; i < column.Length; i++)
            {
                Assert.AreEqual(column[i], i);
            }

            column = matrix.GetColumn(1);

            Assert.AreEqual(column.Length, matrix.Rows);

            for (int i = 0; i < column.Length; i++)
            {
                Assert.AreEqual(column[i], i + 1);
            }
        }
Esempio n. 16
0
        public void Exception6()
        {
            var matrix = new ObjectMatrix <int>(10, 15);
            int i;

            Assert.Throws <ArgumentOutOfRangeException>(() => i = matrix[9, -1]);
        }
Esempio n. 17
0
        public void TestAddColumn()
        {
            ObjectMatrix <int> matrix = GetTestMatrix();

            int columnCount = matrix.Columns;
            int rowCount    = matrix.Rows;

            matrix.AddColumn();

            Assert.AreEqual(matrix.Columns, columnCount + 1);
            Assert.AreEqual(matrix.Rows, rowCount);

            for (int i = 0; i < rowCount; i++)
            {
                for (int j = 0; j < columnCount; j++)
                {
                    Assert.AreEqual(matrix[i, j], i + j);
                }
            }

            for (int i = 0; i < rowCount; i++)
            {
                Assert.AreEqual(matrix[i, columnCount], default(double));
            }
        }
Esempio n. 18
0
        public void TestInvalidCopyTo2()
        {
            ObjectMatrix <int> matrix = GetTestMatrix();

            int[] array = new int[matrix.Rows * matrix.Columns - 1];

            matrix.CopyTo(array, 0);
        }
Esempio n. 19
0
        public void Simple()
        {
            var matrix = new ObjectMatrix<int>(5, 5);
            Assert.IsFalse(matrix.IsReadOnly);

            matrix = GetTestMatrix();
            Assert.IsFalse(matrix.IsReadOnly);
        }
Esempio n. 20
0
        public void Simple()
        {
            ICollection<int> matrix = new ObjectMatrix<int>(10, 15);

            Assert.AreEqual(matrix.Count, 150);

            matrix = new ObjectMatrix<int>(3, 3);
            Assert.AreEqual(matrix.Count, 9);
        }
Esempio n. 21
0
        public void TestIsReadOnly()
        {
            ObjectMatrix <int> m = new ObjectMatrix <int>(5, 5);

            Assert.AreEqual(m.IsReadOnly, false);

            m = GetTestMatrix();
            Assert.AreEqual(m.IsReadOnly, false);
        }
Esempio n. 22
0
        public void Simple()
        {
            var matrix = new ObjectMatrix <int>(5, 5);

            Assert.IsFalse(matrix.IsReadOnly);

            matrix = GetTestMatrix();
            Assert.IsFalse(matrix.IsReadOnly);
        }
Esempio n. 23
0
        public void IsReadOnlyExample()
        {
            var matrix = new ObjectMatrix <double>(4, 5);

            //IsReadOnly is always false for ObjectMatrix<double>
            Assert.IsFalse(matrix.IsReadOnly);
            matrix[2, 3] = 5;
            Assert.IsFalse(matrix.IsReadOnly);
        }
Esempio n. 24
0
        public void TestInvalidAddMultipleRows2()
        {
            ObjectMatrix <int> matrix = GetTestMatrix();

            int columnCount = matrix.Columns;
            int rowCount    = matrix.Rows;

            matrix.AddRows(0);
        }
Esempio n. 25
0
        public void Simple()
        {
            ICollection <int> matrix = new ObjectMatrix <int>(10, 15);

            Assert.AreEqual(matrix.Count, 150);

            matrix = new ObjectMatrix <int>(3, 3);
            Assert.AreEqual(matrix.Count, 9);
        }
Esempio n. 26
0
        public void TestCount()
        {
            ObjectMatrix <int> m = new ObjectMatrix <int>(10, 15);

            Assert.AreEqual(m.Count, 150);

            m = new ObjectMatrix <int>(3, 3);
            Assert.AreEqual(m.Count, 9);
        }
Esempio n. 27
0
        public void TestIsFixedSize()
        {
            ObjectMatrix <int> m = new ObjectMatrix <int>(5, 5);

            Assert.AreEqual(m.IsFixedSize, true);

            m = GetTestMatrix();
            Assert.AreEqual(m.IsFixedSize, true);
        }
Esempio n. 28
0
        public void ExcetionInvalid()
        {
            var matrix = new ObjectMatrix<int>(10, 15);

            matrix[0, 0] = 5;
            Assert.AreEqual(matrix[0, 0], 5);

            matrix[3, 2] = 99;
            Assert.AreEqual(matrix[3, 2], 99);
        }
Esempio n. 29
0
        public void IndexExample()
        {
            var matrix = new ObjectMatrix <double>(4, 5);

            // Set the item
            matrix[2, 3] = 5;

            // Item is 5
            Assert.AreEqual(5, matrix[2, 3]);
        }
Esempio n. 30
0
        public void ExcetionInvalid()
        {
            var matrix = new ObjectMatrix <int>(10, 15);

            matrix[0, 0] = 5;
            Assert.AreEqual(matrix[0, 0], 5);

            matrix[3, 2] = 99;
            Assert.AreEqual(matrix[3, 2], 99);
        }
Esempio n. 31
0
        public void DeleteColumnExample()
        {
            var matrix = new ObjectMatrix <int>(4, 5);

            // Delete the second row from the matrix
            matrix.DeleteRow(2);

            // Only 3 rows left...
            Assert.AreEqual(matrix.Rows, 3);
        }
Esempio n. 32
0
        public void TestIndexing()
        {
            ObjectMatrix <int> m = new ObjectMatrix <int>(10, 15);

            m[0, 0] = 5;
            Assert.AreEqual(m[0, 0], 5);

            m[3, 2] = 99;
            Assert.AreEqual(m[3, 2], 99);
        }
Esempio n. 33
0
        public void DeleteRowExample()
        {
            var matrix = new ObjectMatrix <int>(4, 5);

            // Delete the second column from the matrix
            matrix.DeleteColumn(2);

            // Only 4 columns left...
            Assert.AreEqual(matrix.Columns, 4);
        }
Esempio n. 34
0
        public void AcceptExample()
        {
            var matrix = new ObjectMatrix<double>(2, 2);
            matrix[0, 0] = -2;
            matrix[0, 1] = 3;
            matrix[1, 0] = 4;
            matrix[1, 1] = 6;
            var visitor = new CountingVisitor<double>();

            matrix.AcceptVisitor(visitor);

            Assert.AreEqual(4, visitor.Count);
        }
Esempio n. 35
0
        internal static void TestIfEqual(ObjectMatrix<int> l, ObjectMatrix<int> r)
        {
            Assert.AreEqual(l.Columns, r.Columns);
            Assert.AreEqual(l.Rows, r.Rows);

            for (var i = 0; i < l.Rows; i++)
            {
                for (var j = 0; j < l.Columns; j++)
                {
                    Assert.AreEqual(l[i, j], r[i, j]);
                }
            }
        }
Esempio n. 36
0
        public void Simple()
        {
            var matrix = new ObjectMatrix<int>(10, 15);
            Assert.IsFalse(matrix.IsSquare);

            matrix = new ObjectMatrix<int>(3, 3);
            Assert.IsTrue(matrix.IsSquare);

            matrix = new ObjectMatrix<int>(9, 9);
            Assert.IsTrue(matrix.IsSquare);

            matrix = new ObjectMatrix<int>(2, 3);
            Assert.IsFalse(matrix.IsSquare);
        }
Esempio n. 37
0
        internal static ObjectMatrix<int> GetTestMatrix()
        {
            var matrix = new ObjectMatrix<int>(10, 15);

            for (var i = 0; i < 10; i++)
            {
                for (var j = 0; j < 15; j++)
                {
                    matrix[i, j] = i + j;
                }
            }

            return matrix;
        }
Esempio n. 38
0
        public void Simple()
        {
            var matrix = new ObjectMatrix<int>(10, 15);

            matrix[5, 5] = 13;

            Assert.IsTrue(matrix.Contains(13));
            Assert.IsFalse(matrix.Contains(15));

            matrix[2, 3] = 15;

            Assert.IsTrue(matrix.Contains(13));
            Assert.IsTrue(matrix.Contains(15));
            Assert.IsFalse(matrix.Contains(17));
        }
Esempio n. 39
0
        public void AddColumnsExample()
        {
            var matrix = new ObjectMatrix<double>(2, 2);
            matrix[0, 0] = 1;
            matrix[0, 1] = 2;
            matrix[1, 0] = 3;
            matrix[1, 1] = 4;

            Assert.AreEqual(2, matrix.Columns);
            Assert.AreEqual(2, matrix.Rows);

            matrix.AddColumns(2);

            Assert.AreEqual(4, matrix.Columns);
            Assert.AreEqual(2, matrix.Rows);
        }
Esempio n. 40
0
        public void AddColumnValuesExample()
        {
            var matrix = new ObjectMatrix<double>(2, 2);
            matrix[0, 0] = 1;
            matrix[0, 1] = 2;
            matrix[1, 0] = 3;
            matrix[1, 1] = 4;

            Assert.AreEqual(2, matrix.Columns);
            Assert.AreEqual(2, matrix.Rows);

            matrix.AddColumn(5, 6);

            Assert.AreEqual(3, matrix.Columns);
            Assert.AreEqual(2, matrix.Rows);

            Assert.AreEqual(5, matrix[0, 2]);
            Assert.AreEqual(6, matrix[1, 2]);
        }
Esempio n. 41
0
        public void IndexExample()
        {
            var matrix = new ObjectMatrix<double>(4, 5);

            // Set the item
            matrix[2, 3] = 5;

            // Item is 5
            Assert.AreEqual(5, matrix[2, 3]);
        }
Esempio n. 42
0
 public void Exception6()
 {
     var matrix = new ObjectMatrix<int>(10, 15);
     var i = matrix[9, -1];
 }
Esempio n. 43
0
 public void RowsExample()
 {
     var matrix = new ObjectMatrix<double>(2, 3);
     Assert.AreEqual(2, matrix.Rows);
 }
Esempio n. 44
0
        public void IsSquareExample()
        {
            var matrix = new ObjectMatrix<double>(10, 10);

            Assert.IsTrue(matrix.IsSquare);

            matrix = new ObjectMatrix<double>(3, 4);
            Assert.IsFalse(matrix.IsSquare);

            matrix = new ObjectMatrix<double>(35, 35);
            Assert.IsTrue(matrix.IsSquare);

            matrix = new ObjectMatrix<double>(45, 44);
            Assert.IsFalse(matrix.IsSquare);
        }
Esempio n. 45
0
        public void ResizeExample()
        {
            var matrix = new ObjectMatrix<double>(3, 3);
            matrix[0, 0] = 1;
            matrix[0, 1] = 2;
            matrix[0, 2] = 3;
            matrix[1, 0] = 4;
            matrix[1, 1] = 5;
            matrix[1, 2] = 6;
            matrix[2, 0] = 7;
            matrix[2, 1] = 8;
            matrix[2, 2] = 9;

            matrix.Resize(2, 2);

            Assert.AreEqual(matrix.Columns, 2);
            Assert.AreEqual(matrix.Rows, 2);

            Assert.AreEqual(1, matrix[0, 0]);
            Assert.AreEqual(2, matrix[0, 1]);
            Assert.AreEqual(4, matrix[1, 0]);
            Assert.AreEqual(5, matrix[1, 1]);
        }
Esempio n. 46
0
        public void InterchangeRowsExample()
        {
            var matrix = new ObjectMatrix<double>(2, 2);
            matrix[0, 0] = 1;
            matrix[0, 1] = 2;
            matrix[1, 0] = 3;
            matrix[1, 1] = 4;

            matrix.InterchangeRows(0, 1);

            Assert.AreEqual(3, matrix[0, 0]);
            Assert.AreEqual(4, matrix[0, 1]);
            Assert.AreEqual(1, matrix[1, 0]);
            Assert.AreEqual(2, matrix[1, 1]);
        }
Esempio n. 47
0
        public void IsReadOnlyExample()
        {
            var matrix = new ObjectMatrix<double>(4, 5);

            //IsReadOnly is always false for ObjectMatrix<double>
            Assert.IsFalse(matrix.IsReadOnly);
            matrix[2, 3] = 5;
            Assert.IsFalse(matrix.IsReadOnly);
        }
Esempio n. 48
0
        public void ContainsExample()
        {
            var matrix = new ObjectMatrix<double>(2, 2);
            matrix[0, 0] = -2;
            matrix[0, 1] = 3;
            matrix[1, 0] = 4;
            matrix[1, 1] = 6;

            Assert.IsTrue(matrix.Contains(-2));
            Assert.IsTrue(matrix.Contains(3));
            Assert.IsFalse(matrix.Contains(-5));
        }
Esempio n. 49
0
 public void ConstructorExample()
 {
     var matrix = new ObjectMatrix<double>(2, 3);
     Assert.AreEqual(2, matrix.Rows);
     Assert.AreEqual(3, matrix.Columns);
 }
Esempio n. 50
0
        public void CopyToExample()
        {
            var matrix = new ObjectMatrix<double>(2, 2);
            matrix[0, 0] = 1;
            matrix[0, 1] = 2;
            matrix[1, 0] = 3;
            matrix[1, 1] = 4;

            var array = new double[matrix.Rows * matrix.Columns];

            matrix.CopyTo(array, 0);

            Assert.AreEqual(1, array[0]);
            Assert.AreEqual(4, array[3]);
        }
Esempio n. 51
0
 public void CountExample()
 {
     var matrix = new ObjectMatrix<double>(2, 2);
     ICollection<double> collection = matrix;
     matrix[0, 0] = 1;
     matrix[0, 1] = 2;
     matrix[1, 1] = 3;
     matrix[1, 0] = 4;
     Assert.AreEqual(4, ((ICollection<double>)matrix).Count);
 }
Esempio n. 52
0
 public void Exception5()
 {
     var matrix = new ObjectMatrix<int>(10, 15);
     var i = matrix[-1, 0];
 }
Esempio n. 53
0
        public void DeleteColumnExample()
        {
            var matrix = new ObjectMatrix<int>(4, 5);

            // Delete the second row from the matrix
            matrix.DeleteRow(2);

            // Only 3 rows left...
            Assert.AreEqual(matrix.Rows, 3);
        }
Esempio n. 54
0
        public void DeleteRowExample()
        {
            var matrix = new ObjectMatrix<int>(4, 5);

            // Delete the second column from the matrix
            matrix.DeleteColumn(2);

            // Only 4 columns left...
            Assert.AreEqual(matrix.Columns, 4);
        }
Esempio n. 55
0
        public void GetRowExample()
        {
            var matrix = new ObjectMatrix<double>(2, 2);
            matrix[0, 0] = 1;
            matrix[0, 1] = 2;
            matrix[1, 0] = 3;
            matrix[1, 1] = 4;

            var row1 = matrix.GetRow(0);

            Assert.AreEqual(1, row1[0]);
            Assert.AreEqual(2, row1[1]);

            var row2 = matrix.GetRow(1);

            Assert.AreEqual(3, row2[0]);
            Assert.AreEqual(4, row2[1]);
        }
Esempio n. 56
0
        public void ClearExample()
        {
            var matrix = new ObjectMatrix<double>(4, 5);

            // Set the item
            matrix[2, 3] = 5;

            // Item is 5
            Assert.AreEqual(5, matrix[2, 3]);

            // Clear the matrix
            matrix.Clear();

            // Item is now 0
            Assert.AreEqual(0, matrix[2, 3]);
        }
Esempio n. 57
0
        public void GetSubMatrixExample()
        {
            var matrix = new ObjectMatrix<double>(3, 3);
            matrix[0, 0] = 1;
            matrix[0, 1] = 2;
            matrix[0, 2] = 3;
            matrix[1, 0] = 4;
            matrix[1, 1] = 5;
            matrix[1, 2] = 6;
            matrix[2, 0] = 7;
            matrix[2, 1] = 8;
            matrix[2, 2] = 9;

            var result1 = matrix.GetSubMatrix(0, 0, 1, 1);

            Assert.AreEqual(1, result1.Rows);
            Assert.AreEqual(1, result1.Columns);

            var result2 = matrix.GetSubMatrix(1, 2, 2, 1);

            Assert.AreEqual(2, result2.Rows);
            Assert.AreEqual(1, result2.Columns);
        }
Esempio n. 58
0
 public void Exception2()
 {
     var matrix = new ObjectMatrix<int>(10, 15);
     matrix[9, 15] = 5;
 }
Esempio n. 59
0
        public void GetColumnExample()
        {
            var matrix = new ObjectMatrix<double>(2, 2);
            matrix[0, 0] = 1;
            matrix[0, 1] = 2;
            matrix[1, 0] = 3;
            matrix[1, 1] = 4;

            var column1 = matrix.GetColumn(0);

            Assert.AreEqual(1, column1[0]);
            Assert.AreEqual(3, column1[1]);

            var column2 = matrix.GetColumn(1);

            Assert.AreEqual(2, column2[0]);
            Assert.AreEqual(4, column2[1]);
        }
Esempio n. 60
0
        public void GetEnumeratorExample()
        {
            var matrix = new ObjectMatrix<double>(2, 2);
            matrix[0, 0] = 1;
            matrix[0, 1] = 2;
            matrix[1, 1] = 3;
            matrix[1, 0] = 4;

            var enumerator = matrix.GetEnumerator();
            while (enumerator.MoveNext())
            {
                Console.WriteLine(enumerator.Current);
            }
        }