Esempio n. 1
0
 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;
 }
Esempio n. 2
0
 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;
 }