.NET开发

本类阅读TOP10

·NHibernate快速指南(翻译)
·vs.net 2005中文版下载地址收藏
·【小技巧】一个判断session是否过期的小技巧
·VB/ASP 调用 SQL Server 的存储过程
·?dos下编译.net程序找不到csc.exe文件
·通过Web Services上传和下载文件
·学习笔记(补)《.NET框架程序设计(修订版)》--目录
·VB.NET实现DirectDraw9 (2) 动画
·VB.NET实现DirectDraw9 (1) 托管的DDraw
·建站框架规范书之——文件命名

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
Matrix 计算之旅1---初等行变换

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

'初等行变换之互换两行
Public Sub Matrix_Specify_Tow_Row_Exchange(Row_A_Index As Integer, Row_B_Index As Integer, temp_matrix() As Single)
Dim i As Integer
For i = 1 To UBound(temp_matrix, 2)
    swap temp_matrix(Row_A_Index, i), temp_matrix(Row_B_Index, i)
Next i
End Sub
'初等行变换之一行自乘一个数后加至另一行上去
Public Sub Matrix_Single_Row_ShuChen_Addition_To_Other_Row(temp_matrix() As Single, Row_A_Index As Integer, Row_B_Index As Integer, k As Single)
Dim i As Integer
For i = 1 To UBound(temp_matrix, 2)
    temp_matrix(Row_B_Index, i) = temp_matrix(Row_B_Index, i) + k * temp_matrix(Row_A_Index, i)
Next i
End Sub
'初等行变换之某一行的全体自乘一个数
Public Sub Matrix_Single_Row_ShuChen(k As Single, temp_a() As Single, Row_Index As Integer)
Dim i As Integer
For i = 1 To UBound(temp_a, 2)
    temp_a(Row_Index, i) = k * temp_a(Row_Index, i)
Next i
End Sub

'最简行阶梯阵的计算。
Option Explicit
Public Function Matrix_Basic_Row_Transformation(temp_matrix() As Single)
    Dim Row_Index As Integer, col_index As Integer, Row_Num As Integer, Col_Num As Integer
    Dim i As Integer, j As Integer, Not_Zero_Row_Index As Integer
    Dim temp_chen As Single
    Dim flag As Boolean
    Row_Num = UBound(temp_matrix, 1)
    Col_Num = UBound(temp_matrix, 2)
    Row_Index = 1: col_index = 1
    Do While (Row_Index <= Row_Num And col_index <= Col_Num)
    'Do While (col_index <= Col_Num)
         
          flag = If_Specify_Col_Zero(temp_matrix, col_index, Row_Index, Not_Zero_Row_Index)
          If (flag = False) Then
                'FormTest.Print "did it!"
                'If col_index = 2 And Row_Index = 2 Then output_matrix temp_matrix
                If (Not_Zero_Row_Index <> Row_Index) Then
                       Matrix_Specify_Tow_Row_Exchange Row_Index, Not_Zero_Row_Index, temp_matrix
                End If
               
                'FormTest.List1.AddItem Row_Index
                'FormTest.List2.AddItem col_index
                For i = 1 To Row_Num
                        If (i <> Row_Index) Then
                              Matrix_Single_Row_ShuChen_Addition_To_Other_Row temp_matrix, Row_Index, i, -temp_matrix(i, col_index) / temp_matrix(Row_Index, col_index)
                        End If
                        'If Row_Index = 2 Then FormTest.List1.AddItem temp_matrix(i, Col_Num)
                Next i
               
                Matrix_Single_Row_ShuChen 1 / temp_matrix(Row_Index, col_index), temp_matrix, Row_Index
               
                Row_Index = Row_Index + 1
                col_index = col_index + 1
          Else
                'FormTest.Print col_index, Row_Index
                col_index = col_index + 1
          End If
    Loop
End Function

 




相关文章

相关软件