Esempio n. 1
0
        public void ToDoubleMatrixTest()
        {
            // value is null
            {
                DoubleMatrix actual = (DoubleMatrixRowCollection)(null);

                Assert.IsNull(actual);

                actual = DoubleMatrixRowCollection.ToDoubleMatrix(null);

                Assert.IsNull(actual);
            }

            // value is not null
            {
                DoubleMatrix matrix = DoubleMatrix.Dense(2, 3,
                                                         new double[6] {
                    1, 2, 3, 4, 5, 6
                });
                var rows = matrix.AsRowCollection();

                var expected = matrix;

                var actual = (DoubleMatrix)rows;
                DoubleMatrixAssert.AreEqual(expected, actual, DoubleMatrixTest.Accuracy);

                actual = DoubleMatrixRowCollection.ToDoubleMatrix(rows);
                DoubleMatrixAssert.AreEqual(expected, actual, DoubleMatrixTest.Accuracy);
            }
        }
Esempio n. 2
0
        public MainWindow()
        {
            InitializeComponent();

            this.matrixBlock.Text = this.matrix.ToString();

            this.gridBoundToIndexer.CurrentCellChanged +=
                this.GridBoundToIndexer_CurrentCellChanged;

            this.gridBoundToDataProperties.CurrentCellChanged +=
                this.GridBoundToDataProperties_CurrentCellChanged;

            this.rowCollection = this.matrix.AsRowCollection();

            this.rowCollection.XDataColumn =
                Convert.ToInt32(((ListBoxItem)this.xDataColumn.SelectedItem).Content);
            this.rowCollection.YDataColumn =
                Convert.ToInt32(((ListBoxItem)this.yDataColumn.SelectedItem).Content);
            this.rowCollection.ZDataColumn =
                Convert.ToInt32(((ListBoxItem)this.zDataColumn.SelectedItem).Content);
            this.xDataColumn.SelectionChanged += this.XDataColumn_SelectionChanged;
            this.yDataColumn.SelectionChanged += this.YDataColumn_SelectionChanged;
            this.zDataColumn.SelectionChanged += this.ZDataColumn_SelectionChanged;

            this.gridBoundToIndexer.ItemsSource        = this.rowCollection;
            this.gridBoundToDataProperties.ItemsSource = this.rowCollection;

            double gridWidth   = this.gridBoundToIndexer.Width;
            double columnWidth = .9 * gridWidth / this.matrix.NumberOfColumns;

            for (int j = 0; j < this.matrix.NumberOfColumns; j++)
            {
                DataGridTextColumn column = new()
                {
                    Binding = new Binding("[" + j + "]")
                    {
                        Mode = BindingMode.TwoWay,
                    },
                    Header = j,
                    Width  = columnWidth
                };

                this.gridBoundToIndexer.Columns.Add(column);
            }
        }