52 lines
No EOL
1.1 KiB
C++
52 lines
No EOL
1.1 KiB
C++
#pragma once
|
|
#include <cmath>
|
|
#include <iostream>
|
|
#include <vector>
|
|
using namespace std;
|
|
|
|
class ProductMatrix
|
|
{
|
|
private:
|
|
vector<double> u;
|
|
vector<double> v;
|
|
size_t n;
|
|
size_t m;
|
|
|
|
public:
|
|
vector<double> Mult(const vector<double> &x) const
|
|
{
|
|
vector<double> y(n,0);
|
|
for(int i = 0; i < n; ++i)
|
|
{
|
|
for(int j = 0; j < m; ++j)
|
|
{
|
|
y[i] += v[j]*x[j];
|
|
}
|
|
y[i] *= u[i];
|
|
}
|
|
return y;
|
|
}
|
|
|
|
vector<double> MultT(const vector<double> &y) const
|
|
{
|
|
vector<double> x(m,0);
|
|
for(int j = 0; j < m; ++j)
|
|
{
|
|
for(int i = 0; i < n; ++i)
|
|
{
|
|
x[j] += y[i]*u[i];
|
|
}
|
|
x[j] *= v[j];
|
|
}
|
|
return x;
|
|
}
|
|
|
|
ProductMatrix(const vector<double> &u, const vector<double> &v)
|
|
{
|
|
n = u.size();
|
|
m = v.size();
|
|
this->u = u;
|
|
this->v = v;
|
|
|
|
}
|
|
}; |