Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: ConfigFile SDFileSystem mbed
Fork of LAURUS_program by
Vector/Vector_Matrix_operator.cpp
- Committer:
- ojan
- Date:
- 2015-06-24
- Revision:
- 23:79cdc1432160
- Parent:
- 3:5358a691a100
File content as of revision 23:79cdc1432160:
#include "Vector_Matrix_operator.h"
Vector operator*(const Matrix& lhm, const Vector& rhv) {
if (lhm.GetCol() != rhv.GetDim()) error("Irregular Dimention");
Vector retVec(lhm.GetRow());
for (int i = 1; i <= lhm.GetRow(); i++) {
float temp = 0.0f;
for (int j = 1; j <= rhv.GetDim(); j++) {
temp += lhm.GetComp(i, j)*rhv.GetComp(j);
}
retVec.SetComp(i, temp);
}
retVec.CleanUp();
return retVec;
}
Vector operator*(const Vector& lhv, const Matrix& rhm) {
if (lhv.GetDim() != rhm.GetRow()) error("Irregular Dimention");
Vector retVec(rhm.GetCol());
for (int i = 1; i <= rhm.GetCol(); i++) {
float temp = 0.0f;
for (int j = 1; j <= lhv.GetDim(); j++) {
temp += lhv.GetComp(j) * rhm.GetComp(j, i);
}
retVec.SetComp(i, temp);
}
retVec.CleanUp();
return retVec;
}
