資源簡介
采用三元組表示稀疏矩陣,并定義矩陣的加、減、乘運算
正交鏈表表示稀疏矩陣

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
namespace?SparseMatrix
{
????public?partial?class?FmInput?:?Form
????{
????????private?Presenter?_present;
????????public?FmInput(Presenter?present)
????????{
????????????InitializeComponent();
????????????_present?=?present;
????????}
????????public?FmInput()
????????{
????????????InitializeComponent();
????????}
????????private?void?btInput_Click(object?sender?EventArgs?e)
????????{
????????????if?(_present.CurrentMatrix.RowNum?*?_present.CurrentMatrix.ColNum==0)
????????????{
????????????????MessageBox.Show(“請先設置行數和列數“);
????????????}
????????????try?{
???????????????????if?(_present.CurrentMatrix.IsOutofIndex())
????????????????{
???????????????????????MessageBox.Show(“該矩陣非零元素過多,已不屬于稀疏矩陣!“);
????????????????}
????????????????if?(_present.AddItem(Convert.ToInt32(tbRowNum.Text)?Convert.ToInt32(tbColNum.Text)?(float)Convert.ToDouble(tbValue.Text)))?{
????????????????????tbValueNum.Text?=?_present.CurrentMatrix.Terms.ToString();
????????????????????tbRatio.Text?=?_present.CurrentMatrix.Ratio.ToString();
????????????????????ListViewItem?newItem?=?new?ListViewItem(new?string[]?{?_present.CurrentMatrix.Terms.ToString()?tbRowNum.Text?tbColNum.Text?tbValue.Text?});
????????????????????lvMatrix.Items.Add(newItem);
????????????????????rTBMatrix.Text?=?_present.OutPutCurMetrix();
????????????????}
????????????}
????????????catch?
????????????{
????????????????MessageBox.Show(“請正確輸入行數、列號和值!“);
????????????????return;
????????????}
???????
????????}
????????private?void?comboBox1_SelectedIndexChanged(object?sender?EventArgs?e)
????????{
????????????_present.SetCurrentMatrix(comboBox1.SelectedIndex?+?1);
????????????Flash();
????????}
????????private?void?Flash()
????????{
????????????rTBMatrix.Text?=?_present.OutPutCurMetrix();
????????????int?i=1;
????????????lvMatrix.Items.Clear();
????????????foreach?(Trituple?node?in?_present.CurrentMatrix.TritupleExpress)
????????????{
????????????????lvMatrix.Items.Add(new?ListViewItem(new?string[]{i.ToString()node.Row.ToString()node.Col.ToString()node.Value.ToString()}));
????????????????i++;
????????????}
????????????tbValueNum.Text=_present.CurrentMatrix.Terms.ToString();
????????????tbValue.Text=““;
????????}
????????private?void?button1_Click(object?sender?EventArgs?e)
????????{
????????????int?row;
????????????int?col;
????????????try?{
????????????????row?=?Convert.ToInt32(tbRowNum.Text);
????????????????col?=?Convert.ToInt32(tbColNum.Text);?
????????????????_present.SetColAndRow(row?col);
????????????????lvMatrix.Items.Clear();
????????????????rTBMatrix.Text?=?““;
????????????????tbRatio.Text?=?““;
????????????????tbValueNum.Text?=?““;
????????????}?catch?{
????????????????MessageBox.Show(“請正確輸入行數和列數!“)
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????10354??2010-06-21?23:45??SparseMatrix\SparseMatrix\Data\Crossli
?????文件???????1862??2010-06-21?23:45??SparseMatrix\SparseMatrix\Data\Crossli
?????文件??????12498??2010-06-21?23:45??SparseMatrix\SparseMatrix\Data\SparseMatrix.cs
?????文件????????935??2010-06-21?23:45??SparseMatrix\SparseMatrix\Data\Trituple.cs
?????文件???????3186??2010-06-21?22:52??SparseMatrix\SparseMatrix\FmInput.cs
?????文件??????13647??2010-06-21?22:52??SparseMatrix\SparseMatrix\FmInput.Designer.cs
?????文件???????5814??2010-06-21?22:52??SparseMatrix\SparseMatrix\FmInput.resx
?????文件???????2760??2010-06-21?22:52??SparseMatrix\SparseMatrix\FmSparseMatrixCaculator.cs
?????文件??????11616??2010-06-21?22:52??SparseMatrix\SparseMatrix\FmSparseMatrixCaculator.Designer.cs
?????文件???????5814??2010-06-21?22:52??SparseMatrix\SparseMatrix\FmSparseMatrixCaculator.resx
?????文件????????398??2010-06-20?00:50??SparseMatrix\SparseMatrix\Form1.cs
?????文件???????5259??2010-06-20?00:50??SparseMatrix\SparseMatrix\Form1.Designer.cs
?????文件???????5814??2010-06-20?00:50??SparseMatrix\SparseMatrix\Form1.resx
?????文件???????3483??2010-06-21?23:45??SparseMatrix\SparseMatrix\Presenter.cs
?????文件????????511??2010-06-21?11:53??SparseMatrix\SparseMatrix\Program.cs
?????文件???????1368??2010-06-20?00:38??SparseMatrix\SparseMatrix\Properties\AssemblyInfo.cs
?????文件???????2857??2010-06-20?00:38??SparseMatrix\SparseMatrix\Properties\Resources.Designer.cs
?????文件???????5612??2010-06-20?00:38??SparseMatrix\SparseMatrix\Properties\Resources.resx
?????文件???????1097??2010-06-20?00:38??SparseMatrix\SparseMatrix\Properties\Settings.Designer.cs
?????文件????????249??2010-06-20?00:38??SparseMatrix\SparseMatrix\Properties\Settings.settings
?????文件???????4443??2010-06-21?23:45??SparseMatrix\SparseMatrix\SparseMatrix.csproj
?????文件????????260??2010-06-22?00:04??SparseMatrix\SparseMatrix.gpState
?????文件????????926??2010-06-20?00:38??SparseMatrix\SparseMatrix.sln
????..A..H.?????42496??2010-06-22?00:04??SparseMatrix\SparseMatrix.suo
?????目錄??????????0??2010-06-24?22:53??SparseMatrix\SparseMatrix\Data
?????目錄??????????0??2010-06-24?22:53??SparseMatrix\SparseMatrix\Properties
?????目錄??????????0??2010-06-24?22:53??SparseMatrix\SparseMatrix
?????目錄??????????0??2010-06-24?22:53??SparseMatrix
-----------?---------??----------?-----??----
???????????????143259????????????????????28
............此處省略1個文件信息
- 上一篇:WebFtp(Web 版Ftp)
- 下一篇:C# 堆棧 回溯 馬踏棋盤演示程序
評論
共有 條評論