C#實(shí)現(xiàn)矩陣乘法實(shí)例分析
更新時(shí)間:2015年04月21日 09:07:49 作者:gogo
這篇文章主要介紹了C#實(shí)現(xiàn)矩陣乘法的方法,實(shí)例分析了通過(guò)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)文章
C#實(shí)現(xiàn)通過(guò)ffmpeg從flv視頻文件中截圖的方法
這篇文章主要介紹了C#實(shí)現(xiàn)通過(guò)ffmpeg從flv視頻文件中截圖的方法,實(shí)例分析了C#使用ffmpeg操作flv文件的技巧,需要的朋友可以參考下2015-03-03C#實(shí)現(xiàn)帶進(jìn)度條的ListView
這篇文章主要介紹了C#實(shí)現(xiàn)帶進(jìn)度條的ListView 的相關(guān)資料,需要的朋友可以參考下2016-02-02c# winform時(shí)鐘的實(shí)現(xiàn)代碼
這篇文章主要介紹了c# winform時(shí)鐘的實(shí)現(xiàn)代碼,有需要的朋友可以參考一下2014-01-01關(guān)于C# 5.0 CallerMemberName CallerFilePath CallerLineNumber 在.
本篇文章,小編為大家介紹關(guān)于C# 5.0 CallerMemberName CallerFilePath CallerLineNumber 在.NET4中的使用介紹方法,有需要的朋友可以參考一下2013-04-04