Excercises_GeorgMandl/BSP_1_G/matrixprod.cpp

48 lines
864 B
C++

#include "matrixprod.h"
#include "sigmoid.h"
MatrixProd::MatrixProd()
{
//ctor
}
MatrixProd::MatrixProd(vector<double> uc, vector<double> vc)
{
nrow = uc.size();
mcol = vc.size();
u = uc;
v = vc;
}
vector<double> MatrixProd::Mult(const vector<double> &x) const
{
vector<double> y(nrow,0);
for(int n=0; n<nrow; ++n)
{
for(int m=0; m<mcol; ++m)
{
y[n] += v[m]*x[m];
}
y[n] *= u[n];
}
return y;
}
vector<double> MatrixProd::MultT(const vector<double> &x) const
{
vector<double> y(mcol,0);
for(int m=0; m<mcol; ++m) // over columns
{
for(int n=0; n<nrow; ++n) // over rows
{
y[m] += u[n]*x[n];
}
y[m] *= v[m];
}
return y;
}
MatrixProd::~MatrixProd()
{
//dtor
}