資源簡介
處理間接平差
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Text;
namespace?NameMatrix
{
????class?Matrix
????{
????????///?矩陣的乘?
????????public?static?void?MatrixMultiply(double[]?a?double[]?b?double[]?c)
????????{
????????????if?(a.GetLength(1)?!=?b.GetLength(0))
????????????????return;
????????????if?(a.GetLength(0)?!=?c.GetLength(0)?||?b.GetLength(1)?!=?c.GetLength(1))
????????????????return;
????????????for?(int?i?=?0;?i?????????????{
????????????????for?(int?j?=?0;?j?????????????????{
????????????????????c[i?j]?=?0;
????????????????????for?(int?k?=?0;?k?????????????????????{
????????????????????????c[i?j]?+=?a[i?k]?*?b[k?j];
????????????????????}
????????????????}
????????????}
????????}
????????///?矩陣的加?
????????public?static?void?MatrixAdd(double[]?a?double[]?bdouble[]?c)
????????{
????????????if?(a.GetLength(0)?!=?b.GetLength(0)?||?a.GetLength(1)?!=?b.GetLength(1)
????????????||?a.GetLength(0)?!=?c.GetLength(0)?||?a.GetLength(1)?!=?c.GetLength(1))
????????????????return;
????????????for?(int?i?=?0;?i?????????????{
????????????????for?(int?j?=?0;?j?????????????????{
????????????????????c[i?j]?=?a[i?j]?+?b[i?j];
????????????????}
????????????}
????????????return;
????????}
????????///?矩陣的減?
????????public?static?void?MatrixSubtration(double[]?a?double[]?b?double[]?c)
????????{
????????????if?(a.GetLength(0)?!=?b.GetLength(0)?||?a.GetLength(1)?!=?b.GetLength(1)
????????????||?a.GetLength(0)?!=?c.GetLength(0)?||?a.GetLength(1)?!=?c.GetLength(1))
????????????????return;
????????????for?(int?i?=?0;?i?????????????{
????????????????for?(int?j?=?0;?j?????????????????{
????????????????????c[i?j]?=?a[i?j]?-?b[i?j];
????????????????}
????????????}
????????????return;
????????}
????????///?矩陣的行列式的值?
????????public?static?double?MatrixSurplus(double[]?a)
????????{
????????????int?i?j?k?p?r?m?n;
????????????m?=?a.GetLength(0);
????????????n?=?a.GetLength(1);
????????????double?X?temp?=?1?temp1?=?1?s?=?0?s1?=?0;
????????????if?(n?==?2)
????????????{
????????????????for?(i?=?0;?i?????????????????????for?(j?=?0;?j?????????????????????????if?((i?+?j)?%?2?>?0)?temp1?*=?a[i?j];
????????????????????????else?temp?*=?a[i?j];
????????????????X?=?temp?-?temp1;
????????????}
????????????else
????????????{
????????????????for?(k?=?0;?k?
評論
共有 條評論