本文介绍了在方形二维数组上创建逆矩阵并在datagridview中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个二维数组(方形矩阵),我想找到二维数组的逆矩阵,然后使用datagridview控件显示逆矩阵
下面的代码在datagridview控件中显示2d矩阵
I have a 2-D array (square matrix) that i want to find the inverse matrix of the 2d array then display the inverse matrix with using datagridview control
The code below displays the 2d matrix in the datagridview control
Dim myArray(,) As Double
myArray = New Double(2, 2) {{"0,0", "0,1", "0,3"}, {"1,0", "1,1", "1,3"}, {"2,0", "2,1", "2,3"}}
Dim myTable As New DataTable
Dim iRows As Integer = myArray.GetLength(0)
Dim iCols As Integer = myArray.GetLength(1)
For i As Integer = 1 To iCols
myTable.Columns.Add()
Next
For iRow As Integer = 0 To iRows - 1
Dim newRow As DataRow = myTable.NewRow
For iCol As Integer = 0 To iCols - 1
newRow(iCol) = myArray(iRow, iCol)
Next
myTable.Rows.Add(newRow)
Next
DataGridView1.DataSource = myTable
推荐答案
这篇关于在方形二维数组上创建逆矩阵并在datagridview中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!