Dateien nach „BSP_1_G“ hochladen
This commit is contained in:
parent
174e3841cd
commit
a77a9f9fca
4 changed files with 102 additions and 0 deletions
48
BSP_1_G/matrixprod.cpp
Normal file
48
BSP_1_G/matrixprod.cpp
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
#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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue