double DenseMatrix::InnerProduct(const DenseMatrix& mat) const { double res = 0; const std::vector<double>& dataMat = mat.GetValues(); for (int dataId = 0; dataId < mValues.size(); dataId++) { res += mValues.at(dataId) * dataMat.at(dataId); } return res; }
DenseMatrix DenseMatrix::operator - (const DenseMatrix& mat) const { DenseMatrix matRes(mRowNum, mColNum, 0); int dataCount = mRowNum * mColNum; std::vector<double>& dataRes = matRes.GetValues(); const std::vector<double>& dataMat = mat.GetValues(); for (int dataId = 0; dataId < dataCount; dataId++) { dataRes.at(dataId) = mValues.at(dataId) - dataMat.at(dataId); } return matRes; }