没有合适的资源?快使用搜索试试~ 我知道了~
内含常用矩阵算法,包括矩阵加法,减法,乘法及求逆运算
资源推荐
资源详情
资源评论
public double[,] MatrixAdd(double[,] Array0, double[,] Array1)
{
//矩阵加法
int rowsCount0 = Array0.GetLength(0);
int colsCount0 = Array0.GetLength(1);
int rowsCount1 = Array1.GetLength(0);
int colsCount1 = Array1.GetLength(1);
double[,] arrReturn = new double[rowsCount0, colsCount0];
if (rowsCount0 != rowsCount1 || colsCount0 != colsCount1)
{
//错误处理
MessageBox.Show("维数不等,矩阵无法相加!");
}
int i = 0;
int j = 0;
for (i = 0; i < rowsCount0; i++)
for (j = 0; j < colsCount0; j++)
{
arrReturn[i, j] = Array0[i, j] + Array1[i, j];
}
return arrReturn;
}
public double[,] MatrixMethod(double[,] Array0, double[,] Array1)
{
//矩阵减法
int rowsCount0 = Array0.GetLength(0);
int colsCount0 = Array0.GetLength(1);
int rowsCount1 = Array1.GetLength(0);
int colsCount1 = Array1.GetLength(1);
double[,] arrReturn = new double[rowsCount0, colsCount0];
{
//矩阵加法
int rowsCount0 = Array0.GetLength(0);
int colsCount0 = Array0.GetLength(1);
int rowsCount1 = Array1.GetLength(0);
int colsCount1 = Array1.GetLength(1);
double[,] arrReturn = new double[rowsCount0, colsCount0];
if (rowsCount0 != rowsCount1 || colsCount0 != colsCount1)
{
//错误处理
MessageBox.Show("维数不等,矩阵无法相加!");
}
int i = 0;
int j = 0;
for (i = 0; i < rowsCount0; i++)
for (j = 0; j < colsCount0; j++)
{
arrReturn[i, j] = Array0[i, j] + Array1[i, j];
}
return arrReturn;
}
public double[,] MatrixMethod(double[,] Array0, double[,] Array1)
{
//矩阵减法
int rowsCount0 = Array0.GetLength(0);
int colsCount0 = Array0.GetLength(1);
int rowsCount1 = Array1.GetLength(0);
int colsCount1 = Array1.GetLength(1);
double[,] arrReturn = new double[rowsCount0, colsCount0];
if (rowsCount0 != rowsCount1 || colsCount0 != colsCount1)
{
//错误处理
MessageBox.Show("维数不等,矩阵无法相减!");
}
int i = 0;
int j = 0;
for (i = 0; i < rowsCount0; i++)
for (j = 0; j < colsCount0; j++)
{
arrReturn[i, j] = Array0[i, j] - Array1[i, j];
}
return arrReturn;
}
public double[,] MatrixTranspose(double[,] Array)
{
//矩阵转置
int rowsCount = Array.GetLength(0);
int colsCount = Array.GetLength(1);
double[,] arrReturn = new double[colsCount, rowsCount];
int i = 0;
int j = 0;
for (i = 0; i < colsCount; i++)
for (j = 0; j < rowsCount; j++)
{
arrReturn[i, j] = Array[j, i];
}
return arrReturn;
}
public double[,] MatrixMulti(double[,] Array0, double[,] Array1)
{
//错误处理
MessageBox.Show("维数不等,矩阵无法相减!");
}
int i = 0;
int j = 0;
for (i = 0; i < rowsCount0; i++)
for (j = 0; j < colsCount0; j++)
{
arrReturn[i, j] = Array0[i, j] - Array1[i, j];
}
return arrReturn;
}
public double[,] MatrixTranspose(double[,] Array)
{
//矩阵转置
int rowsCount = Array.GetLength(0);
int colsCount = Array.GetLength(1);
double[,] arrReturn = new double[colsCount, rowsCount];
int i = 0;
int j = 0;
for (i = 0; i < colsCount; i++)
for (j = 0; j < rowsCount; j++)
{
arrReturn[i, j] = Array[j, i];
}
return arrReturn;
}
public double[,] MatrixMulti(double[,] Array0, double[,] Array1)
剩余10页未读,继续阅读
资源评论
qwerdota2
- 粉丝: 0
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功