最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

C#實(shí)現(xiàn)矩陣乘法實(shí)例分析

 更新時(shí)間:2015年04月21日 09:07:49   作者:gogo  
這篇文章主要介紹了C#實(shí)現(xiàn)矩陣乘法的方法,實(shí)例分析了通過C#數(shù)組構(gòu)造矩陣及實(shí)現(xiàn)矩陣乘法的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了C#實(shí)現(xiàn)矩陣乘法的方法。分享給大家供大家參考。具體如下:

static double[][] MatrixMultiplication(double[][] matrixOne, double[][] matrixTwo)
{
 int aRows = matrixOne.Length; int aCols = matrixOne[0].Length;
 int bRows = matrixTwo.Length; int bCols = matrixTwo[0].Length;
 if (aCols != bRows)
 throw new Exception("Out of shape matrices");
 double[][] result = CreateMatrix(aRows, bCols);
 for (int i = 0; i < aRows; ++i) // each row of MatrixOne
 for (int j = 0; j < bCols; ++j) // each col of MatrixTwo
  for (int k = 0; k < aCols; ++k)
 result[i][j] += matrixOne[i][k] * matrixTwo[k][j];
 return result;
}
static double[][] CreateMatrix(int rows, int cols)
{
 double[][] result = new double[rows][];
 for (int i = 0; i < rows; ++i)
 result[i] = new double[cols]; 
 return result;
}

希望本文所述對(duì)大家的C#程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論

吉木乃县| 定结县| 卫辉市| 大兴区| 樟树市| 比如县| 澄江县| 米林县| 外汇| 扎兰屯市| 汶川县| 将乐县| 长春市| 卓尼县| 林芝县| 万载县| 察雅县| 磴口县| 莱西市| 策勒县| 巨野县| 福泉市| 嵊州市| 个旧市| 五大连池市| 九寨沟县| 无锡市| 桂东县| 邻水| 疏勒县| 瑞安市| 南乐县| 上犹县| 栾川县| 仪陇县| 勐海县| 宁远县| 新建县| 红桥区| 永平县| 琼结县|